Custom Ansible Callback not receiving group_vars/host_vars

前端 未结 2 1535
北海茫月
北海茫月 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:40

    You are accessing variables under ansible.inventory class hence you get only those defined in the inventory.

    If you want to access other variables, you need to go through the play's variable manager:

    def v2_playbook_on_play_start(self, play):
        variable_manager = play.get_variable_manager()
        hostvars = variable_manager.get_vars()['hostvars']
    

提交回复
热议问题