我正在使用Asible-2.4.5.0
尝试将安装的yum list的结果插入模板生成的文件时出现问题。我收到以下错误:
'dict object' has no attribute 'stdout_lines'
这是任务
- name: Capture output of currently installed RPMs
yum:
list=installed
register: yum_list_installed
- debug:
msg: " {{ yum_list_installed }} "
- template:
src: yumlistinstalled.j2
dest: /var/tmp/{{backupDir}}/yum_list_installed
这是我的模板文件。
{% for i in yum_list_installed.stdout_lines %}
{{ i }}
{% endfor %}
我的屏幕上的调试输出显示信息没有问题。问题是当我尝试将数据插入模板生成的文件中时。下面是输出示例。
TASK [Capture output of currently installed RPMs]
ok: [192.168.100.138] => {
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"allow_downgrade": false,
"conf_file": null,
"disable_gpg_check": false,
"disablerepo": null,
"enablerepo": null,
"exclude": null,
"install_repoquery": true,
"installroot": "/",
"list": "installed",
"name": null,
"security": false,
"skip_broken": false,
"state": "installed",
"update_cache": false,
"validate_certs": true
}
},
TASK [debug]
task path: /root/code/playbooks/someclient/master2.yml:250
ok: [192.168.100.138] => {
"msg": "Hello world!"
}
TASK [template] ******************************************************************************************************************************************
task path: /root/code/playbooks/someclient/master2.yml:252
fatal: [192.168.100.138]: FAILED! => {
"changed": false,
"failed": true,
"msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'stdout_lines'"
}