Fix callback plugin for Ansible 2.5 compatability

Ansible 2.5 changed an internal callback method around that is
expected in plugins for options. In order for this to work, we needed
to make some minor changes.

Change-Id: I3801f339511155a4b8ecab91bb06b286b11c0a06
Related-Bug: #1758462
This commit is contained in:
Julia Kreger 2018-03-23 18:59:54 -07:00 committed by Dmitry Tantsur
parent 34277f6237
commit 83c4ec9393
2 changed files with 8 additions and 4 deletions

View File

@ -22,4 +22,4 @@ ImcSdk>=0.7.2
sushy sushy
# Ansible-deploy interface # Ansible-deploy interface
ansible>=2.4,<2.5.0 ansible>=2.4

View File

@ -85,13 +85,17 @@ class CallbackModule(object):
setup_log() setup_log()
self.log = logging.getLogger(__name__) self.log = logging.getLogger(__name__)
self.node = None self.node = None
self.opts = {} self._plugin_options = {}
# NOTE(pas-ha) this method is required for Ansible>=2.4 # NOTE(pas-ha) this method is required for Ansible>=2.4
# TODO(pas-ha) rewrite to support defining callback plugin options # TODO(pas-ha) rewrite to support defining callback plugin options
# in ansible.cfg after we require Ansible >=2.4 # in ansible.cfg after we require Ansible >=2.4
def set_options(self, options): def set_options(self, option=None, option_value=None):
self.opts = options if option:
if option_value:
self._plugin_options[option] = option_value
else:
self._plugin_options = option
def runner_msg_dict(self, result): def runner_msg_dict(self, result):
self.node = result._host.get_name() self.node = result._host.get_name()