# How to store ansible running log separately without touching log\_path and ANSIBLE\_LOG\_PATH

**URL:** <https://forum.ansible.com/t/how-to-store-ansible-running-log-separately-without-touching-log-path-and-ansible-log-path/29803>\
**Category:** Ansible Project\
**Created:** [March 1, 2019, 7:17am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-separately-without-touching-log-path-and-ansible-log-path/29803 "2019-03-01T07:17:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qin\_Peter](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@Qin\_Peter](https://forum.ansible.com/u/Qin_Peter)\
**Post date:** [March 1, 2019, 7:17am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-separately-without-touching-log-path-and-ansible-log-path/29803/1 "2019-03-01T07:17:58Z")

</div>

Hi All,  
I am new to Ansible and I have requirement about ansible running log. Could anyone help? Thanks.  
I am talking about running log, not the playbook log.

eg:  
2019-02-28 01:39:59,819 p=23627 u=peterqi | PLAY [create log file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2019-02-28 01:39:59,830 p=23627 u=peterqi | TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2019-02-28 01:40:01,129 p=23627 u=peterqi | ok: [localhost]  
2019-02-28 01:40:01,213 p=23627 u=peterqi | TASK [rename log file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2019-02-28 01:40:01,570 p=23627 u=peterqi | changed: [localhost → localhost]  
2019-02-28 01:40:01,577 p=23627 u=peterqi | PLAY [cat test2 log] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2019-02-28 01:40:01,583 p=23627 u=peterqi | TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2019-02-28 01:40:01,682 paramiko.transport starting thread (client mode): 0x5517250L  
2019-02-28 01:40:01,683 paramiko.transport Local version/idstring: SSH-2.0-paramiko\_2.4.1  
2019-02-28 01:40:01,690 paramiko.transport Remote version/idstring: SSH-2.0-OpenSSH\_6.6.1

Customer has some playbooks to run and only they have the right to update the ansible.cfg  
I also will develop some playbooks but I must use the coutomer’s configuration, both ansible.cfg(log\_path) and variable ANSIBLE\_LOG\_PATH.

Now I want to keep the ansible running log in separate log file for all of my developed playbook.  
And another limitation is the playbooks could be executed at the same time.

I try a lot but I find it is almost impossiable.

My first try is adding a task at the beginning of every playbook:

- name: create log file  
hosts: localhost  
tasks:
- name: rename log file  
shell: /bin/bash -l -c “touch {{ lookup(‘env’,‘ANSIBLE\_LOG\_PATH’) }};mv {{ lookup(‘env’,‘ANSIBLE\_LOG\_PATH’) }} {{ lookup(‘env’,‘ANSIBLE\_LOG\_PATH’) }}-{{ lookup(‘pipe’,‘date +%Y%m%d%H%M%S’) }}”  
delegate\_to: localhost  
become: yes  
become\_user: “{{ lookup(‘env’, ‘USER’) }}”

It works well first but if more than one playbooks are running at the same time, only the first log file will have all the logs, otheres are empty.

I am thinking about create a module, but I do not know if a module will be my solution.

Any suggestion?  
I also cannot use plugin, because plugin will impact all the playbooks, including customer’s.

Thanks a lot for any suggestions.  
Best Regards,  
Peter Qin
