Custom Ansible Callback not receiving group_vars/host_vars

前端 未结 2 1512
北海茫月
北海茫月 2021-01-15 12:13

I have a custom ansible callback that I am writing:

class CallbackModule(CallbackBase):
  CALLBACK_VERSION = 2.0
  CALLBACK_TYPE = \'aggregate\'
  CALLBACK_N         


        
2条回答
  •  隐瞒了意图╮
    2021-01-15 12:26

    Excellent @techraf helped me figure this out. I needed to capture the Play's Variable Manager:

    class CallbackModule(CallbackBase):
        CALLBACK_VERSION = 2.0
        CALLBACK_TYPE = 'aggregate'
        CALLBACK_NAME = 'is'
    
        def v2_playbook_on_play_start(self, play):
          self.vm = play.get_variable_manager()
    
        def v2_runner_on_ok(self, result):
          host_vars = self.vm.get_vars()['hostvars'][result._host.name]
          var_that_i_want = host_vars['var_that_i_want']
    

提交回复
热议问题