Ok. here's my playbook.

when I use -vvv option, I see those outputs. 
+++++++++++++++++++++++++++++++++
---
- hosts: mdhd
  connection: local
  gather_facts: no
  vars_files:
    - /etc/ansible/var.yml
  tasks:
  - name: Checking PSU status
    imc_rest:
      hostname: "{{ imc_hostname }}"
      username: "{{ imc_username }}"
      password: "{{ imc_password }}"
      protocol: https
      timeout: 60
      validate_certs: no
      content: |
           <configResolveClass inHierarchical="false" 
classId="equipmentPsu"/>
    register: result
  - set_fact:
      PSU: "{{ 
result.configResolveClass.children|json_query(my_query1)|json_query(my_query2)|json_query(my_query3)
 
}}"
    vars:
      my_query1: "[].outConfigs.children"
      my_query2: "[].equipmentPsu.attributes"
      my_query3: "[].{dn: dn, id: id, operability: operability, presence: 
presence}"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

TASK [set_fact] 
**********************************************************************************************************************************
task path: /etc/ansible/validation_psu.yml:19
ok: [host1] => {
    "ansible_facts": {
        "PSU": [
            {
                "dn": "sys/rack-unit-1/psu-1",
                "id": "1",
                "operability": "operable",
                "presence": "equipped"
            },
            {
                "dn": "sys/rack-unit-1/psu-2",
                "id": "2",
                "operability": "operable",
                "presence": "equipped"
            }
        ]
    },
    "changed": false
}
META: ran handlers
META: ran handlers

Thanks,
Ramesh

On Thursday, 31 December 2020 at 10:42:19 UTC-5 vbo...@gmail.com wrote:

> On Thu, 31 Dec 2020 07:23:27 -0800 (PST) 
> Ramesh AR <rames...@gmail.com> wrote: 
>
> > Thanks for the help. however, I set fact on my playbook and doesn't show 
> > any output. 
>
> > > https://gist.github.com/vbotka/7ed043e08550e83a929593e3ebd510b9 
>
> This is strange. I added the file with the data. Both versions of the 
> code work for me 
>
> PSU: 
> - dn: sys/rack-unit-1/psu-1 
> id: '1' 
> operability: operable 
> presence: equipped 
> - dn: sys/rack-unit-1/psu-2 
> id: '2' 
> operability: operable 
> presence: equipped 
>
> -- 
> Vladimir Botka 
>

-- 
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/4b52e2c5-0ba0-4469-8c08-7739cef352f4n%40googlegroups.com.

Reply via email to