我正在尝试从NetApp ONTAP9.8P6 上的 n a_ontap_command ansible 模块获取 stdout_lines 输出。
这给了我完整的输出:
tasks:
- name: Version CLI Command
na_ontap_command:
command: ['version']
return_dict: yes
<<: *login
register: cluster_version
- name: Print Output
debug:
msg: "{{ cluster_version }}"
输出:
ok: [localhost] => {
"msg": {
"changed": true,
"failed": false,
"msg": {
"invoked_command": "version",
"result_value": 1,
"status": "passed",
"stdout": "NetApp Release 9.8P6: Tue Aug 03 16:21:11 UTC 2021\n",
"stdout_lines": [
"NetApp Release 9.8P6: Tue Aug 03 16:21:11 UTC 2021"
],
"xml_dict": {
"active_element": "",
"cli-output": {
"attrs": {},
"data": "NetApp Release 9.8P6: Tue Aug 03 16:21:11 UTC 2021\n"
},
"cli-result-value": {
"attrs": {},
"data": "'1'"
},
"last_element": "results",
"results": {
"attrs": {
"status": "passed",
"xmlns": "http://www.netapp.com/filer/admin"
},
"data": ""
}
}
}
}
}
我怎样才能打印例如 stdout 或 stdout_lines?
我找到了带有 msg: "{{ cluster_version.stdout }}" 或循环结果的示例。
味精:“{{ cluster_version.stdout }}”以以下错误味精结尾:
"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\
在我的案例中,我不知道如何使用循环,因为在我的剧本的输出中找不到结果关键项。
也许有人经历过这种情况并可以提供想法或解决方案?谢谢!