Hello,

I am working on a custom callback plugin.
https://docs.ansible.com/ansible/latest/plugins/callback.html

This is a part of code in the plugin I am working.

from ansible.plugins.callback import CallbackBase


co_create = None


class CallbackModule(CallbackBase):
  CALLBACK_VERSION = 2.0


  def __init__(self):
        super(CallbackModule, self).__init__()


  def v2_playbook_on_play_start(self, play):
        
        self.play = play
        vm = play.get_variable_manager()
        co_create = vm.extra_vars["co_create"]


if __name__ == '__main__':
    play = ...
    obj = CallbackModule()
    obj.v2_playbook_on_play_start(play)
    print(co_create)

    
And Ansible run:
ansible-playbook test.yml --extra-vars "co_create=True"


My goal is to be able to use 'co_create' outside of the CallbackModule in 
the callback plugin (python script) (like a global variable).
I haven't figured out how to achieve it.
One way of test I am performing is the above but I don't know what to put 
in "play = ..." because the play is available by the callback module when 
it is called directly from ansible..

Looking for any help.

Thanks,
Jerry

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/7f32f7ea-5b3d-430f-973c-f054488f8a4ao%40googlegroups.com.

Reply via email to