How to display verbose only for a particular task in playbook?

I have several tasks in a playbook. I want to see -vvvv (highest verbose level) only for a single task in the playbook. So i don’t want to give -vvvv after ‘ansible-playbook sample.yaml’.

Is there any way to display -vvvv info only for a single task while running the playbook?

Thanks,

Vikram

I don’t think there is a straightforward way.

As a workaround you could run the whole play with no_log: true and add no_log: false explicitly to your task calling ec2 action. Then run the playbook with -v.

There are log plugins specifically for these. You can refer logcallback plugin in ansible.

Create a copy of it and customize it as per your need.

8

Might be worth trying https://awsbloglink.wordpress.com/2018/11/11/how-to-control-the-output-of-ansible-debug-with-verbose/

Also, there is an existing issue with this https://github.com/ansible/ansible/issues/24215

Hi pushparaj,

The problem with this approach is that it is hiding even the normal output (success/fail, etc) of each task when i don’t use -vvvv. So it is hiding output of each task that i would otherwise need to see. Thanks for replying though.

Regards,
Vikram

Hi,

I tried this but it doesn’t exactly meet my requirements. I need to run only a single task with highest level verbosity. If i were to specify verbosity level as 4 as given in the article and if i were to run -vvvv, then all other tasks which have lower verbosity will also show debug info, not just the single task that i want shown.

Regards,
Vikram

or we add this https://github.com/ansible/ansible/pull/74888