FreeKB - ansible-playbook command - printing output to the console (debug)
ansible-playbook command - printing output to the console (debug)

Home > Search


This assumes you have installed Ansible Tower and are familiar with the ansible-playbook command.

The "- debug" option can be used to print output to the console. In this example, "Hello World" will be printed.

- debug: msg="Hello World"

 

When the play is run, the following should be produced.

TASK [debug]
ok: [server1.example.com] => {
    "msg": "Hello World"
}

 

Here is now to print stdout, stderr, and return code.

---
- hosts: all
  remote_user: root
  tasks:
    - name: ps command
      shell: ps
      register: out

    - debug: msg={{ out.stdout }}
    - debug: msg={{ out.stderr }}
    - debug: msg={{ out.rc }}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 95291 in the box below so that we can be sure you are a human.




Comments