A 最小可重现示例
---
- hosts: localhost
become: false
gather_facts: false
vars:
results: [
{
"ansible loop var": "item",
"changed": false,
"exists": true,
"failed": false,
"item": [
"TMS",
"InterThread"
],
"properties": {
"Audit": {
"raw value": 1,
"type": "REG_DWORD",
"value": 1
},
"Authenticator": {
"raw_value": "111",
"type": "REG_SZ",
"value": "111"
},
}
}
]
tasks:
- name: Audit
debug:
msg: 'value: "{{ (results | first).properties.Audit.value }}" has type: "{{ (results | first).properties.Audit.type }}"'
- name: Auth
debug:
msg: 'value: "{{ (results | first).properties.Authenticator.value }}" has type: "{{ (results | first).properties.Authenticator.type }}"'
将产生
的输出TASK [Audit] ****************************
ok: [localhost] =>
msg: 'value: "1" has type: "REG_DWORD"'
TASK [Auth] *****************************
ok: [localhost] =>
msg: 'value: "111" has type: "REG_SZ"'