I did modify my plugin this way:
def _*init*_(self):
super(CallbackModule, self)._*init*_()
*self.playbook_name = None*
if not os.path.exists("./logs"):
os.makedirs("./logs")
- def v2_playbook_on_start(self, playbook):
self.playbook = playbook
self.playbook_name = os.path.basename(self.playbook._file_name*)
def log(self, host, data):
*filename = '%s_%s_%s' % (self.playbook_name,host,os.getpid())*
path = os.path.join("./logs", filename)
Le mardi 7 février 2017 11:08:47 UTC+1, fanvalt a écrit :
>
> Hello,
>
> In a callback plugin, I did parameter the filename to dipatch log files by
> host and ansible pid this way:
> filename = '%s_%s' % (host,os.getpid())
>
> I would like to add the name of the playbook that is run, in example if I
> run the command: ansible-playbook test.yml, I would like to create this
> logfile: test_*host_pid*
> in what structure and variable can I get the playbook name ?
>
> Regards
>
--
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/acd55b20-6026-4d28-9ea2-104594523195%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.