ansible - 在 ansible play 中调试不使用_items
问题描述
需要一些帮助来调试寄存器任务中的特定值。
- debug:
msg: "{{ item.stdout }}"
with_items: path_result.results
这是行不通的
{
"changed": false,
"path_result": {
"msg": "All items completed",
"changed": true,
"results": [
{
"_ansible_parsed": true,
"stderr_lines": [],
"_ansible_item_result": true,
"end": "2019-04-10 14:55:18.726270",
"_ansible_no_log": false,
"_ansible_delegated_vars": {
"ansible_delegated_host": "**.***.***.***",
"ansible_host": "**.***.***.***"
},
"cmd": "cat /tmp/abc.conf | grep apple",
"rc": 0,
"stdout": "fruit=apple",
"item": "**.***.***.***",
"delta": "0:00:00.021499",
"stderr": "",
"changed": true,
"invocation": {
"module_args": {
"creates": null,
"executable": null,
"_uses_shell": true,
"_raw_params": "cat /tmp/abc.conf | grep apple",
"removes": null,
"warn": true,
"chdir": null,
"stdin": null
}
},
"stdout_lines": [
"fruit=apple"
],
"start": "2019-04-10 14:55:18.704771",
"_ansible_ignore_errors": null,
"failed": false
}
]
},
"_ansible_verbose_always": true,
"_ansible_no_log": false
}
我想调试这个特定的输出:
"stdout": "fruit=apple"
解决方案
看起来你已经register
编辑了一个游戏的结果:register: path_result
。该变量也包含path_result
在其中。这就是我认为你拥有的:
- command: cat /tmp/abc.conf | grep apple
register: path_result
- debug:
msg: "{{ item.stdout }}"
with_items: "{{ path_result.results }}"
这是我认为你需要的:
- command: cat /tmp/abc.conf | grep apple
register: path_result
- debug:
msg: "{{ item.stdout }}"
with_items: "{{ path_result.path_result.results }}"
注意 中添加的.path_result
部分with_items
。
推荐阅读
- cypress - 赛普拉斯测试未运行。错误 - 节点缓存目录
- javascript - MathJax 自动换行不起作用
- svn - VDFS 存储库复制的 SVN 服务器通信详细信息
- go - 为什么 Go 中的地图最初根据地图的大小有空值?
- javascript - setTimeout _idleStart 与 Date.now() 的区别?
- object - Flutter 使用动态键访问模型属性
- java - 唯一索引或主键违规:“PRIMARY KEY ON PUBLIC.xxx”;SQL 语句
- php - 如何在模板中显示另一个数据对象
- javascript - 两个对象数组的打字稿差异
- c++ - 遍历结构 C++ 中的结构