-1

In the following Ansible playbook, with the task I am trying to extract the specific version using the software image task at the bottom but it fails with an error.

---
- name: GRAB F5 FACTS
  hosts: lab-ltm
  connection: local
  gather_facts: false
  collections:
    - f5networks.f5_modules

  tasks:
    - name: Runtime product_version
      ansible.builtin.debug:
        msg:
        - "Version 1.6"
        - "Used for Debug Iteration only"

    - name: Setting up provider values
      set_fact:
        provider:
          server: "{{ansible_host}}"
          server_port: "443"
          user: "{{ansible_user}}"
          password: "{{ansible_ssh_pass}}"
          validate_certs: "False"
    
    - name: COLLECT BIG-IP FACTS
      bigip_device_info:
        provider: "{{ provider }}"      
        gather_subset:
          - software-images
      delegate_to: localhost
      register: device_facts

    - name: DISPLAY COMPLETE BIG-IP SYSTEM INFORMATION
      debug:
        var: device_facts['software_images']
        
    - name: software images
      debug:
        var: device_facts.software_images.version[0]

The DISPLAY COMPLETE BIG-IP SYSTEM SYSTEM INFORMATION task gives me this below and in the bottom task I am trying to extract the version only. I have tried all different combinations with no luck. Can anyone help?`

   "device_facts['software_images']": [
        {
            "build": "0.0.28",
            "build_date": "2022-04-07T13:32:41",
            "checksum": "57a051b654e807dadd445ccd88d32c4b",
            "file_size": 2571,
            "full_path": "BIGIP-16.1.2.2-0.0.28.iso",
            "last_modified": "2022-12-13T15:41:43",
            "name": "BIGIP-16.1.2.2-0.0.28.iso",
            "product": "BIG-IP",
            "verified": "yes",
            "version": "16.1.2.2"
        }


For it to simply show the version number, but the task produces this..

ok: [DEVICE1.com.au] => {
    "device_facts.software_images.version[0]": "VARIABLE IS NOT DEFINED!"
}
ok: [DEVICE2.com.au] => {
    "device_facts.software_images.version[0]": "VARIABLE IS NOT DEFINED!"
Rustylee
  • 11
  • 1

1 Answers1

0

Ok, after a few more hours I found a handy tool...

https://codebeautify.org/jsonviewer

which gave me the answer.

device_facts['software_images'].0.version

enter image description here

Rustylee
  • 11
  • 1