0

I have the following playbook, and I'd like to get the debug oupput:

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

But this what I get:

[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

How can I fix the playbook for getting the debug output?

U880D
  • 1,017
  • 2
  • 12
  • 18
sebelk
  • 682
  • 4
  • 13
  • 32

1 Answers1

3

Change

- name: Print result of install chronyd
  debug:
    var: command_output.stdout_lines

to

- name: Print result of install chronyd
  debug:
    var: command_output

stdout_lines property is only present on shell/command module

Zulakis
  • 4,153
  • 14
  • 48
  • 76
  • Thanks, your change suggested worked! – sebelk Jun 24 '22 at 12:29
  • Right, because of [`shell` - Return Values](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html#return-values) and [Common Return Values](https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html). – U880D Jun 28 '22 at 15:21