I'm sorry I just don't plain get iteration through JSON. I need help please. I am doing simple shell module commands to get processor, memory, and disk space.
I create a set_fact: and add that information in. This is what the running playbook spits out. It is a fact called payload_list.
"ansible_facts": {
"payload_list": [
{
"name": "Hostname",
"output": "test_server",
"rc": "0",
"threshold": "0"
},
{
"name": "Uname",
"output": "Linux 2.6.32-431.29.2.el6.x86_64",
"rc": "0",
"threshold": "0"
},
{
"name": "Uptime",
"output": "22:09:17 up 91 days 3:44",
"rc": "0",
"threshold": "0"
},
{
"name": "CPU",
"output": "99.05",
"rc": "0",
"threshold": "1"
},
{
"name": "Memory",
"output": "4GB",
"rc": "0",
"threshold": "1"
},
{
"name": "Disk Usage",
"output": "40",
"rc": "0",
"threshold": "1"
}
]
},
"changed": false,
"invocation": {
"module_args": {
"payload_list": [
{
"name": "Hostname",
"output": "test_server",
"rc": "0",
"threshold": "0"
},
{
"name": "Uname",
"output": "Linux 2.6.32-431.29.2.el6.x86_64",
"rc": "0",
"threshold": "0"
},
{
"name": "Uptime",
"output": "22:09:17 up 91 days 3:44",
"rc": "0",
"threshold": "0"
},
{
"name": "CPU",
"output": "99.05",
"rc": "0",
"threshold": "1"
},
{
"name": "Memory",
"output": "",
"rc": "0",
"threshold": "1"
},
{
"name": "Disk Usage",
"output": "",
"rc": "0",
"threshold": "1"
}
]
},
"module_name": "set_fact"
}
}
How to I pull out a single key:value or even a value. I cannot use json_query because it expects something to be installed so that is not an option for me. Using Ansible version 2.2.1.
Thanks in advance for clearing this up so I can learn.