PaloAltoNetworks/pan-os-ansible

Create a list of downloaded software versions

Closed this issue · 2 comments

Is there a way to list the downloaded software versions?
I want to to a clean up.
But I want first to read a list of download versions so we can remove the older ones

I is not posible to use the 'debug swm list' because debug not available to xmlapi client

Are there any other options

Hi @daemenseth !

You can use the OP command of request system software info - then parse the outputs properly using xpath:

  tasks:
    - name: show list of all software
      paloaltonetworks.panos.panos_op:
        provider: "{{ firewall_provider }}"
        cmd: "request system software info"
      register: software_status
    - name: Print software status
      ansible.builtin.debug:
        var: software_status
    - name: Parse software list
      community.general.xml:
        xmlstring: "{{ software_status.stdout_xml}}"
        xpath: "/response/result/sw-updates/versions/entry/downloaded | /response/result/sw-updates/versions/entry/version"
        content: text
      register: parsed_software_xml

    - name: Print parsed xml
      ansible.builtin.debug:
        var: parsed_software_xml.matches

That matches will give you a list like this:

TASK [Print parsed xml] *******************************************************************
ok: [panorama-mgmt-main] => {
    "parsed_software_xml.matches": [
        {
            "version": "11.1.2"
        },
        {
            "downloaded": "yes"
        },
        {
            "version": "11.1.2-h1"
        },
        {
            "downloaded": "no"
        },
        {
            "version": "11.1.1"
        },
        {
            "downloaded": "no"
        },
        {
            "version": "11.1.0-h2"
        },
        {
            "downloaded": "no"
        },
    ]
}

Hope that helps!

@horiagunica thx for your response.
I solved almost on the same way, only my parsing was some complexer. This is a easier and better way..