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
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f6d5e00d-a40f-49ed-b03b-b046775af86f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.