【发布时间】:2020-04-19 02:14:00
【问题描述】:
我正在使用 ansible 2.9.2 并且我有这个剧本:
register: output
- debug: msg={{ output.instance }}
给出这个输出:
TASK [debug] ***************************************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"annotation": "",
"current_snapshot": null,
"customvalues": {},
"guest_consolidation_needed": false,
"guest_question": null,
"guest_tools_version": "0",
"hw_cluster": null,
"hw_datastores": [
"V1",
],
"hw_esxi_host": "10.10.101.10",
"hw_eth0": {
"addresstype": "assigned",
"ipaddresses": null,
"label": "",
"macaddress": "00:00:00:00:00:51",
"portgroup_key": null,
"portgroup_portkey": null,
"summary": "Vlan1"
我怎样才能让输出只给我"ipaddresses": null?
我试过这个:
- 调试:msg={{ output.instance | json_query('hw_eth0{}.ipaddresses') }}
但出现错误
FAILED! => {"msg": "JMESPathError in json_query filter plugin:\\ninvalid token: Parse error at column 7, token \\"{\\" (LBRACE), for expression:\\n\\"hw_eth0{}.ipaddresses
【问题讨论】:
-
是否正确 "hw_datastores": [ "V1", ], ?
-
@SaeidBabaei 不,我删除了真正的,为什么?
标签: json ansible ansible-2.x