Ok got it . I figured out .. 

just added in mypalybook 
- debug: var=PSU

PLAY [mdhd] 
**************************************************************************************************************************************

TASK [Checking PSU status] 
***********************************************************************************************************************
ok: [host1]

TASK [set_fact] 
**********************************************************************************************************************************
ok: [host1]

TASK [debug] 
*************************************************************************************************************************************
ok: [host1] => {
    "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"
        }
    ]
}

PLAY RECAP 
***************************************************************************************************************************************
host1              : ok=3    changed=0    unreachable=0    failed=0    
skipped=0    rescued=0    ignored=0


On Thursday, 31 December 2020 at 10:48:04 UTC-5 Ramesh AR wrote:

> 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/fefbcb8a-5f20-4530-a50e-ccbb53dfc691n%40googlegroups.com.

Reply via email to