Hello All,

I am filtering out the JSON Output but I tried multiple times sometimes it 
gives error and sometimes it will not give any output. Find the below JSON 
Output and from output, i need only the Installed details. 

Playbook:

---
- hosts: localhost
  gather_facts: no
  vars:
    contents: "{{ lookup('file', '/ansible/linuxpatch.json') | from_json }}"
  tasks:
    - name: calling file
      debug:
        msg={{ contents.msg | list }}
      register: msg
      #debug: msg

    - name: update
      set_fact:
        result: "{{msg | to_json | from_json | 
json_query('msg.true[*].Installed') }}"


JSON Output:

{
    "msg": [
        "",
        true,
        [
            "Installed: NetworkManager-tui-1:1.44.0-4.el9_3.x86_64",
            "Installed: NetworkManager-team-1:1.44.0-4.el9_3.x86_64",
            "Installed: NetworkManager-libnm-1:1.44.0-4.el9_3.x86_64",
            "Installed: NetworkManager-1:1.44.0-4.el9_3.x86_64",
            "Installed: libxml2-2.9.13-5.el9_3.x86_64",
            "Installed: policycoreutils-3.5-3.el9_3.x86_64",
            "Installed: kernel-tools-libs-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: kernel-tools-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: kernel-modules-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: kernel-core-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: kernel-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: 
grub2-tools-minimal-1:2.06-70.el9_3.2.rocky.0.2.x86_64",
            "Installed: 
grub2-tools-extra-1:2.06-70.el9_3.2.rocky.0.2.x86_64",
            "Installed: grub2-tools-efi-1:2.06-70.el9_3.2.rocky.0.2.x86_64",
            "Installed: grub2-tools-1:2.06-70.el9_3.2.rocky.0.2.x86_64",
            "Installed: kernel-modules-core-5.14.0-362.18.1.el9_3.x86_64",
            "Installed: grub2-efi-x64-1:2.06-70.el9_3.2.rocky.0.2.x86_64",
            "Installed: openssl-libs-1:3.0.7-25.el9_3.x86_64",
            "Installed: openssl-1:3.0.7-25.el9_3.x86_64",
            "Installed: rocky-repos-9.3-1.2.el9.noarch",
            "Installed: rocky-release-9.3-1.2.el9.noarch",
            "Installed: rocky-gpg-keys-9.3-1.2.el9.noarch",
            "Installed: python-unversioned-command-3.9.18-1.el9_3.1.noarch",
            "Installed: python3-libs-3.9.18-1.el9_3.1.x86_64",
            "Installed: python3-3.9.18-1.el9_3.1.x86_64",
            "Installed: gnutls-3.7.6-23.el9_3.3.x86_64",
            "Installed: grub2-common-1:2.06-70.el9_3.2.rocky.0.2.noarch",
            "Installed: selinux-policy-targeted-38.1.23-1.el9_3.1.noarch",
            "Installed: sqlite-libs-3.34.1-7.el9_3.x86_64",
            "Installed: systemd-udev-252-18.el9.0.1.rocky.x86_64",
            "Installed: systemd-rpm-macros-252-18.el9.0.1.rocky.noarch",
            "Installed: selinux-policy-38.1.23-1.el9_3.1.noarch",
            "Installed: systemd-pam-252-18.el9.0.1.rocky.x86_64",
            "Installed: systemd-libs-252-18.el9.0.1.rocky.x86_64",
            "Installed: systemd-252-18.el9.0.1.rocky.x86_64",
            "Installed: tzdata-2024a-1.el9.noarch",
            "Installed: nss-util-3.90.0-4.el9_3.x86_64",
            "Installed: nss-softokn-freebl-3.90.0-4.el9_3.x86_64",
            "Installed: nss-softokn-3.90.0-4.el9_3.x86_64",
            "Installed: python3-firewall-1.2.5-2.el9_3.noarch",
            "Installed: firewalld-filesystem-1.2.5-2.el9_3.noarch",
            "Installed: firewalld-1.2.5-2.el9_3.noarch",
            "Installed: nspr-4.35.0-4.el9_3.x86_64",
            "Removed: NetworkManager-1:1.44.0-3.el9.x86_64",
            "Removed: NetworkManager-libnm-1:1.44.0-3.el9.x86_64",
            "Removed: NetworkManager-team-1:1.44.0-3.el9.x86_64",
            "Removed: NetworkManager-tui-1:1.44.0-3.el9.x86_64",
            "Removed: selinux-policy-38.1.23-1.el9.noarch",
            "Removed: selinux-policy-targeted-38.1.23-1.el9.noarch",
            "Removed: gnutls-3.7.6-23.el9.x86_64",
            "Removed: sqlite-libs-3.34.1-6.el9_1.x86_64",
            "Removed: grub2-common-1:2.06-70.el9_3.1.rocky.0.2.noarch",
            "Removed: grub2-tools-1:2.06-70.el9_3.1.rocky.0.2.x86_64",
            "Removed: libxml2-2.9.13-4.el9.x86_64",
            "Removed: grub2-tools-extra-1:2.06-70.el9_3.1.rocky.0.2.x86_64",
            "Removed: 
grub2-tools-minimal-1:2.06-70.el9_3.1.rocky.0.2.x86_64",
            "Removed: grub2-tools-efi-1:2.06-70.el9_3.1.rocky.0.2.x86_64",
            "Removed: grub2-efi-x64-1:2.06-70.el9_3.1.rocky.0.2.x86_64",
            "Removed: systemd-252-18.el9.x86_64",
            "Removed: systemd-libs-252-18.el9.x86_64",
            "Removed: systemd-pam-252-18.el9.x86_64",
            "Removed: systemd-rpm-macros-252-18.el9.noarch",
            "Removed: systemd-udev-252-18.el9.x86_64",
            "Removed: tzdata-2023c-1.el9.noarch",
            "Removed: policycoreutils-3.5-2.el9.x86_64",
            "Removed: nspr-4.35.0-3.el9_2.x86_64",
            "Removed: nss-softokn-3.90.0-3.el9_2.x86_64",
            "Removed: nss-softokn-freebl-3.90.0-3.el9_2.x86_64",
            "Removed: python-unversioned-command-3.9.18-1.el9_3.noarch",
            "Removed: python3-3.9.18-1.el9_3.x86_64",
            "Removed: nss-util-3.90.0-3.el9_2.x86_64",
            "Removed: python3-firewall-1.2.1-1.el9.noarch",
            "Removed: kernel-tools-5.14.0-362.8.1.el9_3.x86_64",
            "Removed: kernel-tools-libs-5.14.0-362.8.1.el9_3.x86_64",
            "Removed: python3-libs-3.9.18-1.el9_3.x86_64",
            "Removed: openssl-1:3.0.7-24.el9.x86_64",
            "Removed: openssl-libs-1:3.0.7-24.el9.x86_64",
            "Removed: firewalld-1.2.1-1.el9.noarch",
            "Removed: firewalld-filesystem-1.2.1-1.el9.noarch",
            "Removed: rocky-gpg-keys-9.3-1.1.el9.noarch",
            "Removed: rocky-release-9.3-1.1.el9.noarch",
            "Removed: rocky-repos-9.3-1.1.el9.noarch"
        ],
        0,
        false
    ]
}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3802a591-3317-4434-9b16-2717d7797d58n%40googlegroups.com.

Reply via email to