Hello,
I would like to log in a file the output of the display when running a playbook, this is set with the log_path variable in logs/ansible.log
But I would like the output to be dispatch in a logfile whose name would be the playbook_name.hostname.nupro
I have a plugin that log into such a file but I cannot log the display log,
Example: the display of the ansible-playbook command, looged in the logfile set by the log_path variable, when running the test_failed.yml playbook:
2017-03-14 11:30:53,570 p=3101 u=fvaltat | Using /home/fvaltat/PLUGINS/ansible.cfg as config file
2017-03-14 11:30:53,615 p=3101 u=fvaltat | Loaded callback default of type stdout, v2.0
2017-03-14 11:30:53,651 p=3101 u=fvaltat | Loaded callback perserver_log of type old, v2.0
2017-03-14 11:30:53,654 p=3101 u=fvaltat | PLAYBOOK: test_failed.yml ******************************************************
2017-03-14 11:30:53,654 p=3101 u=fvaltat | 2 plays in test_failed.yml
2017-03-14 11:30:53,663 p=3101 u=fvaltat | PLAY [RD:!host2] ***************************************************************
2017-03-14 11:30:53,706 p=3101 u=fvaltat | TASK [setup] *******************************************************************
2017-03-14 11:30:54,342 p=3101 u=fvaltat | ok: [localhost]
2017-03-14 11:30:54,352 p=3101 u=fvaltat | TASK [set_fact] ****************************************************************
2017-03-14 11:30:54,352 p=3101 u=fvaltat | task path: /home/fvaltat/PLUGINS/test_failed.yml:3
2017-03-14 11:30:54,383 p=3101 u=fvaltat | ok: [localhost] => {“ansible_facts”: {“var”: false}, “changed”: false, “invocation”: {“module_args”: {“var”: false}, “module_name”: “set_fact”}}
2017-03-14 11:30:54,391 p=3101 u=fvaltat | TASK [fail] ********************************************************************
2017-03-14 11:30:54,392 p=3101 u=fvaltat | task path: /home/fvaltat/PLUGINS/test_failed.yml:5
2017-03-14 11:30:54,463 p=3101 u=fvaltat | fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_args”: {“msg”: “failed”}, “module_name”: “fail”}, “msg”: “failed”}
2017-03-14 11:30:54,469 p=3101 u=fvaltat | NO MORE HOSTS LEFT *************************************************************
2017-03-14 11:30:54,470 p=3101 u=fvaltat | to retry, use: --limit @/home/fvaltat/PLUGINS/test_failed.retry
The contents of the logfile test_failed.yml_localhost_3101 created by the callback plugin:
2017-03-14.11:30:54: msg : failed
Is there an easy way to proceed to rename the ansible.log file during the run of the ansible-playbook command and not in a script ?
I tried to use the log_plays plugin without any success
Regards