1

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

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. – user2187367 Aug 3 '18 at 7:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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