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

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

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

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

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’curve25519-sha256@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写道:

If you are trying to get debug or connection info , try adding -vvvvv to tha ansible-playbook command.

Try creating an alias.

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