I am using Ansible and created a Playbook for deployment. I defined log_path in ansible.cfg and now tasks output are going to this log file. I want to send only few task's log into this log file. How can I achieve this ?

One option is to use no_log: True attribute but this is not displaying the logs on console.

So my requirement is to display all task's logs in console but I want to send only few task's log to my log file.

1 Answer 1


It's in the wish list, I think. Quoting from the doc log_plays - write playbook output to log file

* This callback writes playbook output to a file per host in the /var/log/ansible/hosts directory
* TODO: make this configurable

IMHO required functionality is not available at the moment. Take a look at the available plugins. "You can only have one plugin".

ansible-doc -t callback -l

There is an option to customize a callback. context_demo looks promising.

  • I got this info but there is not much documentation in link. Right now logs are going in the file but I want to stop that log for certain tasks (not hosts) and problem that I can't use no_log: True because I want to print them on console. Commented Aug 3, 2018 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.