set facts from an arry with white space

10 views
Skip to first unread message

ATHIRA sanoj

unread,
May 19, 2019, 4:13:21 AM5/19/19
to Ansible Project
Hello Team

i am trying to set facts from a json array, since the key contains space i am unable to parse, can someone help me here,
i want to set fact as
"name": "IN-FG-04" when "vdom": "vdom-shop"





  - name: Iterate JSON
    set_fact
:
      app_item: "{{ item['scope member'] }}"
    with_items: "{{ result.results }}"
   
register: app_result








{
   
"msg": {
       
"ansible_facts": {
           
"discovered_interpreter_python": "/usr/bin/python"
       
},
       
"changed": false,
       
"failed": false,
       
"msg": "Custom Query Success",
       
"results": [
           
{
               
"name": "FG-04-Policy",
               
"obj ver": 3,
               
"oid": 1196,
               
"package settings": {
                   
"central-nat": "disable",
                   
"fwpolicy-implicit-log": "disable",
                   
"fwpolicy6-implicit-log": "disable",
                   
"inspection-mode": "proxy"
               
},
               
"scope member": [
                   
{
                       
"name": "IN-FG-04",
                       
"vdom": "vdom-shop"
                   
}
               
],
               
"type": "pkg"
           
},
           
{
               
"name": "FG-04-DC",
               
"obj ver": 23,
               
"oid": 1216,
               
"package settings": {
                   
"central-nat": "disable",
                   
"fwpolicy-implicit-log": "disable",
                   
"fwpolicy6-implicit-log": "disable",
                   
"inspection-mode": "proxy"
               
},
               
"scope member": [
                   
{
                       
"name": "IN-FG-04",
                       
"vdom": "vdom1-dc"
                   
}
               
],
               
"type": "pkg"
           
}
       
]
   
}
}



Reply all
Reply to author
Forward
0 new messages