Reputation: 13
I am running Playbook to install in-house software on Windows target machines. I am printing a log of "msg" during this process so that I can forward that to QA / compliance team. However, I do not know how to generate a log file with output from debug > "msg" and place it on Windows host machine. I know log_plays might be useful, but I could not find any example on how to actually use that module.
Any example code would be appreciated.
Upvotes: 1
Views: 7508
Reputation: 21
Probably a bit late, but you can add log_path=mylogfile
to your ansible.cfg
file in the defaults
section
See in the link provided in the answer above.
Upvotes: 1
Reputation: 33203
So, regrettably, /var/log/ansible/hosts
is hardcoded but otherwise it should behave as you would expect. You can enable the callback via ansible.cfg
or the $ANSIBLE_STDOUT_CALLBACK
environment variable:
env ANSIBLE_STDOUT_CALLBACK=log_plays ansible-playbook -i host1,host2 the_file.yml
Be aware that ad-hoc mode does not load callback plugins, so you need to request that explicitly:
env ANSIBLE_LOAD_CALLBACK_PLUGINS=yes ANSIBLE_STDOUT_CALLBACK=log_plays \
ansible -i host1,host2 -m ping '*'
If the /var/log/ansible/hosts
part bugs you, there is also $ANSIBLE_LOG_PATH
which will cause ansible to carbon-copy the log output to a file, and it works fine in ad-hoc mode:
env ANSIBLE_LOG_PATH=$PWD/my-log ansible -i host1,host2 -m ping '*'
Upvotes: 4