我有以下剧本,我想获得调试输出:
---
- name: Install and configure chrony
hosts: '{{ hostgroup }}'
gather_facts: no
become: yes
become_method: sudo
tasks:
- name: make sure chronyd is installed
yum:
name: chrony
state: latest
update_cache: yes
register: command_output
- name: Print result of install chronyd
debug:
var: command_output.stdout_lines
但这是我得到的:
[WARNING]: log file at /var/log/ansible.log is not writeable and we cannot create it, aborting
/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn't match a supported version!
RequestsDependencyWarning)
PLAY [Install and configure chrony] *********************************************************************************************************************************************************************************************************
TASK [make sure chronyd is installed] *******************************************************************************************************************************************************************************************************
ok: [serv8]
TASK [Print result of install chronyd] ******************************************************************************************************************************************************************************************************
ok: [serv8] => {
"command_output.stdout_lines": "VARIABLE IS NOT DEFINED!"
}
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
serv8 : ok=2 changed=0 unreachable=0 failed=0
我该如何修复剧本以获取调试输出?
答案1
改变
- name: Print result of install chronyd
debug:
var: command_output.stdout_lines
到
- name: Print result of install chronyd
debug:
var: command_output
stdout_lines
属性仅存在于shell
/command
模块上