python - Ansible callbacks: get the name of the playbook being executed -


i playing ansible callbacks , use name (for example "ansible-test") of playbook being executed within v2_playbook_on_start(self, playbook) method.

so far, here how code custom callback

class callbackmodule(callbackbase):      callback_version = 2.0     callback_type = 'notification'     callback_name = 'xxxx'     callback_needs_whitelist = true      def __init__(self, display=none):         super(callbackmodule, self).__init__(display=display)      def v2_playbook_on_start(self, playbook):         # how playbook name?      def v2_playbook_on_stats(self, stats):         # ... 

i tried several things, nothing works far: playbook._load_playbook_data, playbook.__module__

and can't find in docs.

how can name?

note: in case, can't use playbook._basedir

edit

some more details clarify point.

so far, structure following:

- ansible-deploy-apache     - defaults         - main.yml     - tasks         - main.yml     - vars      - ... 

here, tasks playbook execute defined in tasks/main.yml.

what playbook._file_name gives me main.yml (not content, name) tasks. have callback method ansible-deploy-apache instead ansible-deploy-apache.

you may want try _file_name:

def v2_playbook_on_start(self, playbook):     display.warning('current playbook: {}'.format(playbook._file_name)) 

writing plugins require reverse engineering :)
context v2_playbook_on_start.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -