I have a playbook which contains multiple Tasks. I need Ansible to print only the Tasks which contains STDOUT /debug task
- hosts: "{{ v_host }}"
gather_facts: no
tasks:
- name: "Create /tmp in target in all VM's "
file:
path: /tmp
state: directory
owner: oracle
group: oinstall
mode: 0775
- copy:
src: /xxx
dest: /yyy
owner: oracle
group: oinstall
force: yes
mode: 0755
- name: "Performing {{ patch_action }} of CPU patch on {{ v_host }} "
shell: |
cd /tmp
sudo -u oracle ./patch.sh
register: out
- debug: var=out.stdout_lines
I execute the playbook without -v option to have a cleaner output. The output looks like below.
ansible-playbook test.yml --extra-vars v_host=xyz.com.
TASK [Create /tmp in target in all VM's] ********************************************************************
ok: [ixyz.com]
TASK [copy] ********************************************************************
ok: [xyz.com]
TASK [Performing of CPU patch on xyz.com] ***
changed: [xyz.com]
TASK [debug] *******************************************************************
ok: [xyz.com] => {
"out.stdout_lines": [
"Patch 123456 : applied on Tue Sep 29 10:11:58 GMT 2020",
"Patch description: \"one-off\"",
"Patch 987654 : applied on Tue Sep 29 10:08:39 GMT 2020",
"Patch description: \"One-off\"",
]
}
Is there an option when i execute the playbook, it gives me the output only for the stdout/debug . The only output that i need is
TASK [debug] *******************************************************************
ok: [xyz.com] => {
"out.stdout_lines": [
"Patch 123456 : applied on Tue Sep 29 10:11:58 GMT 2020",
"Patch description: \"one-off\"",
"Patch 987654 : applied on Tue Sep 29 10:08:39 GMT 2020",
"Patch description: \"One-off\"",
]
}