团队
我正在遍历特定清单组中的所有主机,以检查文件中stat输出的键值响应,但无法映射它。 有人可以提示如何映射吗?
- debug:
var: result
- debug:
msg: "FOUND: /etc/cachefilesd.conf exists..."
when: result.results.stat.exists
delegate_to: "{{ item }}"
with_items: "{{ groups['gpu_node'] }}"
输出:
TASK [services-pre-install-checks : debug]
ok: [localhost] => {[0m
"result": {[0m
"changed": false,[0m
"msg": "All items completed",[0m
"results": [[0m
{[0m
"ansible_loop_var": "item",[0m
"changed": false,[0m
"invocation": {[0m
"module_args": {[0m
"checksum_algorithm": "sha1",[0m
"path": "/etc/cachefilesd.conf"[0m
} },"item": "hostA",[0m
"stat": {[0m
"atime": 1573005811.023855,[0m
exists": true,[0m
}[0m
},[0m
{[0m
"ansible_loop_var": "item",[0m
"failed": false,[0m
"path": "/etc/cachefilesd.conf"[0m
}[0m
},[0m
"item": "hostB",[0m
错误:
[localhost]: FAILED! => {"msg": "The conditional check 'result.results.stat.exists' failed. The error was: error while evaluating conditional (result.results.stat.exists): 'list object' has no attribute 'stat'\n\nThe error appears to be in '/home/run_ansible_playbook/tasks/main.yml':