Score:0

How to use log_plays in playbook and config?

id flag

I am trying to understand and use log_plays so that I can separate out logs per host (I have quite many hosts in hosts.cfg and I want each log in separate file).

I tried following: https://docs.ansible.com/ansible/latest/collections/community/general/log_plays_callback.html

Created the directory /var/log/ansible/hosts, added community.general.log_plays in the playbook, tried ANSIBLE_LOG_FOLDER - didn't seem to pick. Tried adding [callback_log_plays] section in hosts.cfg - threw some error and I had to remove it. But I am OK with the default /var/log/ansible/hosts directory.

I have commented out log_path= in ansible.cfg.

What else did I miss ?

My ansible version:

$ ansible-playbook --version 
ansible-playbook 2.9.21
  config file = /home/vyom/tstansible/ansible.cfg
  configured module search path = [u'/home/vyom/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0]
Score:0
id flag

My bad! I had more than 1 callback_whitelist line!! and in my case I had to also remove the ansible.posix. prefix and just say log_plays

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.