Ansible

Ansible:為什麼我不能得到調試輸出

  • June 23, 2022

我有以下劇本,我想獲得調試輸出:

---
- 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

如何修復獲取調試輸出的劇本?

改變

- 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 模組

引用自:https://serverfault.com/questions/1103978