Logging Playbook Output - Are There Better Ways?
Hello,
so far I have tried different ways to log the output of a single Ansible Playbook execution to a file.
In business environments you usually want to upload the logfile to some platform (e.g. jira
) or send it to someone.
And of course you want to automate this process, too.
my current approach
Right now the most feasible method for me is to do it like this:
- create a wrapper bash script around the
ansible-playbook
commands - redirect the output of the
ansible-playbook
command to a log file - create a second playbook that uploads the logfile to
jira
- start that second playbook after the primary playbook in the wrapper script
other approaches
I have seen people register
every task
and write that to a log with copy
or lineinfile
, but that seems very cumbersome to me and makes roles
harder to maintain.
I know the log_path
setting, but that appends all playbook outputs and is only helpful for looking at past playbook executions.
And I think I have used the log_plays
plugin which did not really do what I had in mind, it also creates a dir for every host.
So - are there better ways to do it?
How do you log your Ansible
runs?
Regards