我正在运行 panos_op ansible 模块并努力解析输出。
ok: [localhost] => {
"result": {
"changed": true,
"failed": false,
"msg": "Done",
"stdout": "{\"response\": {\"@status\": \"success\", \"result\": \"no\"}}",
"stdout_lines": [
"{\"response\": {\"@status\": \"success\", \"result\": \"no\"}}"
],
"stdout_xml": "<response status=\"success\"><result>no</result></response>"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我可以为“结果”分配值的最接近的结果。
ok: [localhost] => {
"result.stdout": {
"response": {
"@status": "success",
"result": "no"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的目标是为 ansible 任务设置一个条件循环。
tasks:
- name: Checking for pending changes
panos_op:
ip_address: '{{ host }}'
password: '{{ operator_pw }}'
username: '{{ operator_user}}'
cmd: 'check pending-changes'
register: result
until: result.stdout.result …Run Code Online (Sandbox Code Playgroud)