Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #215 from indigo-dc/devel
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
micafer authored Nov 17, 2017
2 parents 8c50a28 + 630ef89 commit ba35a61
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions IM/ansible_utils/ansible_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/files/test.radl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba35a61

Please sign in to comment.