Ansible Playbook – Print command output

 

By using the following play I am printing command output in Ansible playbook:

---
- hosts: all
  user: ubuntu
  tasks:
    - name: uptime
      command: 'uptime'
      register: output

    - debug: var=output.stdout_lines

Here I am registered output as output variable, in debug task printing the same with output.stdout_lines.

Other ways to print output:

#- debug: msg="{{ output.stdout }}"
#- debug: msg="{{ output.stderr }}"

Leave a comment