aboutsummaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorYifei Xue <xueyifei@huawei.com>2018-02-06 01:44:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-06 01:44:37 +0000
commita582c92b8cc3ee1b641a151373707e9a8604c8c8 (patch)
tree00eedf056434ebb8913819f4b7988fce8ed815b0 /deploy
parent794d5e92ebbba3818b23dd35f1399244a43cddfc (diff)
parent5e02737fa5f23451bbb443bbf9d67cbac603dc46 (diff)
Merge "Ansible callback support both V2.3 and V2.4"
Diffstat (limited to 'deploy')
-rw-r--r--deploy/ansible_plugins/callback/playbook_done.py (renamed from deploy/playbook_done.py)7
-rw-r--r--deploy/ansible_plugins/callback/status_callback.py (renamed from deploy/status_callback.py)7
-rwxr-xr-xdeploy/compass_conf/templates/ansible_installer/openstack_pike/ansible_cfg/HA-ansible-multinodes.tmpl2
3 files changed, 13 insertions, 3 deletions
diff --git a/deploy/playbook_done.py b/deploy/ansible_plugins/callback/playbook_done.py
index 6b1043d..4784ff6 100644
--- a/deploy/playbook_done.py
+++ b/deploy/ansible_plugins/callback/playbook_done.py
@@ -17,6 +17,8 @@
"""Ansible playbook callback after a playbook run has completed."""
import sys
+from distutils.version import LooseVersion
+from ansible import __version__ as __ansible_version__
from ansible.plugins.callback import CallbackBase
compass_bin = "/opt/compass/bin"
@@ -85,7 +87,10 @@ class CallbackModule(CallbackBase):
return
def v2_playbook_on_stats(self, stats):
- all_vars = self.play.get_variable_manager().get_vars(self.loader)
+ if LooseVersion(__ansible_version__) < LooseVersion("2.4"):
+ all_vars = self.play.get_variable_manager().get_vars(self.loader)
+ else:
+ all_vars = self.play.get_variable_manager().get_vars()
host_vars = all_vars["hostvars"]
hosts = sorted(stats.processed.keys())
cluster_name = host_vars[hosts[0]]['cluster_name']
diff --git a/deploy/status_callback.py b/deploy/ansible_plugins/callback/status_callback.py
index 6169b87..b87d209 100644
--- a/deploy/status_callback.py
+++ b/deploy/ansible_plugins/callback/status_callback.py
@@ -11,6 +11,8 @@ import httplib
import simplejson as json
import sys # noqa:F401
+from distutils.version import LooseVersion
+from ansible import __version__ as __ansible_version__
from ansible.plugins.callback import CallbackBase
COMPASS_HOST = "compass-deck"
@@ -101,7 +103,10 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_stats(self, stats):
self._display.display("playbook_on_stats enter")
- all_vars = self.play.get_variable_manager().get_vars(self.loader)
+ if LooseVersion(__ansible_version__) < LooseVersion("2.4"):
+ all_vars = self.play.get_variable_manager().get_vars(self.loader)
+ else:
+ all_vars = self.play.get_variable_manager().get_vars()
host_vars = all_vars["hostvars"]
hosts = sorted(stats.processed.keys())
cluster_name = host_vars[hosts[0]]['cluster_name']
diff --git a/deploy/compass_conf/templates/ansible_installer/openstack_pike/ansible_cfg/HA-ansible-multinodes.tmpl b/deploy/compass_conf/templates/ansible_installer/openstack_pike/ansible_cfg/HA-ansible-multinodes.tmpl
index cd8c8d3..1d0d647 100755
--- a/deploy/compass_conf/templates/ansible_installer/openstack_pike/ansible_cfg/HA-ansible-multinodes.tmpl
+++ b/deploy/compass_conf/templates/ansible_installer/openstack_pike/ansible_cfg/HA-ansible-multinodes.tmpl
@@ -3,7 +3,7 @@
log_path = /var/ansible/run/openstack_pike-$cluster_name/ansible.log
host_key_checking = False
callback_whitelist = playbook_done, status_callback
-callback_plugins = /opt/ansible_callbacks
+callback_plugins = /opt/ansible_plugins/callback
forks=100
[ssh_connection]