diff --git a/IM/ansible_utils/ansible_launcher.py b/IM/ansible_utils/ansible_launcher.py index 8ed588141..6981a4a90 100755 --- a/IM/ansible_utils/ansible_launcher.py +++ b/IM/ansible_utils/ansible_launcher.py @@ -157,6 +157,7 @@ def get_play_prereqs_2(self, options): variable_manager = VariableManager() variable_manager.extra_vars = self.extra_vars + variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)} # Add this to avoid the Ansible bug: no host vars as host is not in inventory # In version 2.0.1 it must be fixed @@ -186,9 +187,30 @@ def get_play_prereqs_2_4(self, options): # the code, ensuring a consistent view of global variables variable_manager = VariableManager(loader=loader, inventory=inventory) variable_manager.extra_vars = self.extra_vars + variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)} return loader, inventory, variable_manager + def version_info(self, ansible_version_string): + ''' return full ansible version info ''' + ansible_ver = ansible_version_string.split()[0] + ansible_versions = ansible_ver.split('.') + for counter in range(len(ansible_versions)): + if ansible_versions[counter] == "": + ansible_versions[counter] = 0 + try: + ansible_versions[counter] = int(ansible_versions[counter]) + except: + pass + if len(ansible_versions) < 3: + for counter in range(len(ansible_versions), 3): + ansible_versions.append(0) + return {'string': ansible_version_string.strip(), + 'full': ansible_ver, + 'major': ansible_versions[0], + 'minor': ansible_versions[1], + 'revision': ansible_versions[2]} + def launch_playbook_v2(self): ''' run ansible-playbook operations v2.X''' # create parser for CLI options diff --git a/test/files/test.radl b/test/files/test.radl index fcdc88d5f..c192076fb 100644 --- a/test/files/test.radl +++ b/test/files/test.radl @@ -69,6 +69,7 @@ configure test ( - easy_install: name=jmespath tasks: - debug: msg="NODENAME = {{NODENAME}}" + - debug: msg="VERSION = {{ansible_version.major}}" - shell: test -d "/mnt/disk/lost+found" @end