How to store ansible running log to separate log file without touch ANSIBLE_LOG_PATH or ansible.cfg

26 views
Skip to first unread message

Qin Peter

unread,
Feb 27, 2019, 2:23:22 AM2/27/19
to Ansible Development
Hi All,
This is Peter and I am newer to Ansible.

I am trying to store the ansible running log to a file. And every playbook will have separate ansible running log file.
I know I can use   'export  ANSIBLE_LOG_PATH=~/share/logging/peter.log' this variable to do this. But is there any other way?

I prefer a command line parameter or a module. I would like to do some development work but I need some directive guidance.

I cannot use plugin because I cannot affect other ansible users, also I have no right to change the ansible.cfg file. Too much limitataion from the boss, right?

Thanks for any help.

Best Regards,
Peter Qin

Tony Chia

unread,
Mar 1, 2019, 1:37:00 AM3/1/19
to Ansible Development

How about running the ansible playbook Andy pipe to tee command such as this

Ansible-playbook -I inventory dummy.yml | tee playbook.log

Qin Peter

unread,
Mar 1, 2019, 1:47:07 AM3/1/19
to Ansible Development
Thanks for the help.
The customer will execute the command so I should work in the playbook.
And what I need to store is running log like below, not the stand output. Do you have any other suggestions? Thanks.


 1 2019-02-28 21:27:57,795 p=6115 u=peterqi |  PLAY [test1 output] ***********************************************************************************************************>
  2 2019-02-28 21:27:57,806 p=6115 u=peterqi |  TASK [Gathering Facts] ********************************************************************************************************>
  3 2019-02-28 21:27:58,259 paramiko.transport starting thread (client mode): 0xfa683450L
  4 2019-02-28 21:27:58,259 paramiko.transport Local version/idstring: SSH-2.0-paramiko_2.4.1
  5 2019-02-28 21:27:58,267 paramiko.transport Remote version/idstring: SSH-2.0-OpenSSH_6.6.1
  6 2019-02-28 21:27:58,267 paramiko.transport Connected (version 2.0, client OpenSSH_6.6.1)
  7 2019-02-28 21:27:58,270 paramiko.transport kex algos:[u'curve255...@libssh.org', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellma>
  8 2019-02-28 21:27:58,270 paramiko.transport Kex agreed: ecdh-sha2-nistp256
  9 2019-02-28 21:27:58,270 paramiko.transport HostKey agreed: ssh-ed25519
 10 2019-02-28 21:27:58,270 paramiko.transport Cipher agreed: aes128-ctr
 11 2019-02-28 21:27:58,270 paramiko.transport MAC agreed: hmac-sha2-256
 12 2019-02-28 21:27:58,270 paramiko.transport Compression agreed: none







在 2019年3月1日星期五 UTC+8下午2:37:00,Tony Chia写道:

Tchia04

unread,
Mar 1, 2019, 9:46:22 AM3/1/19
to Qin Peter, Ansible Development
If you are trying to get debug or connection info , try adding -vvvvv to tha ansible-playbook command. 
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-devel/S-sO4ToJaiU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Klebolt

unread,
Mar 5, 2019, 4:47:08 PM3/5/19
to Ansible Development
Try creating an alias.

alias ansible-playbook='ANSIBLE_LOG_PATH="${HOME}/logs/ansible-$(date +%H%M%S).log" ansible-playbook'


Reply all
Reply to author
Forward
0 new messages