summaryrefslogtreecommitdiffstats
path: root/roles/lib_utils
diff options
context:
space:
mode:
authorMichael Gugino <mgugino@redhat.com>2017-12-19 15:36:57 -0500
committerMichael Gugino <mgugino@redhat.com>2017-12-20 15:34:05 -0500
commitedde00af6a5b811468fe2a0e9bff45346103be92 (patch)
treecd5622c911972d06732a2986856c6ffe47b34ceb /roles/lib_utils
parent5faaf9cd1e48864b3ff93276f4b1015b297d0b06 (diff)
downloadopenshift-edde00af6a5b811468fe2a0e9bff45346103be92.tar.gz
openshift-edde00af6a5b811468fe2a0e9bff45346103be92.tar.bz2
openshift-edde00af6a5b811468fe2a0e9bff45346103be92.tar.xz
openshift-edde00af6a5b811468fe2a0e9bff45346103be92.zip
Move validate_hosts to prerequisites.yml
Move more checks outside of init/main.yml for speeding up upgrades and other operational plays that need to run.
Diffstat (limited to 'roles/lib_utils')
-rw-r--r--roles/lib_utils/action_plugins/sanity_checks.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/roles/lib_utils/action_plugins/sanity_checks.py b/roles/lib_utils/action_plugins/sanity_checks.py
index 81ffd6e3e..2ddcf77e4 100644
--- a/roles/lib_utils/action_plugins/sanity_checks.py
+++ b/roles/lib_utils/action_plugins/sanity_checks.py
@@ -30,6 +30,19 @@ class ActionModule(ActionBase):
return None
return self._templar.template(res)
+ def check_python_version(self, hostvars, host, distro):
+ """Ensure python version is 3 for Fedora and python 2 for others"""
+ ansible_python = self.template_var(hostvars, host, 'ansible_python')
+ if distro == "Fedora":
+ if ansible_python['version']['major'] != 3:
+ msg = "openshift-ansible requires Python 3 for {};".format(distro)
+ msg += " For information on enabling Python 3 with Ansible,"
+ msg += " see https://docs.ansible.com/ansible/python_3_support.html"
+ raise errors.AnsibleModuleError(msg)
+ else:
+ if ansible_python['version']['major'] != 2:
+ msg = "openshift-ansible requires Python 2 for {};".format(distro)
+
def network_plugin_check(self, hostvars, host):
"""Ensure only one type of network plugin is enabled"""
res = []
@@ -59,7 +72,8 @@ class ActionModule(ActionBase):
def run_checks(self, hostvars, host):
"""Execute the hostvars validations against host"""
- # msg = hostvars[host]['ansible_default_ipv4']
+ distro = self.template_var(hostvars, host, 'ansible_distribution')
+ self.check_python_version(hostvars, host, distro)
self.network_plugin_check(hostvars, host)
self.check_hostname_vars(hostvars, host)