diff options
author | Tim Bielawa <timbielawa@gmail.com> | 2016-12-08 11:05:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-08 11:05:31 -0800 |
commit | 760ea5d197a19a87d624db0a6b110896ab2021b0 (patch) | |
tree | f01219965f3a940eb14efb86774f49219a1225ba | |
parent | 16749761a312894d8ba1101917b7ebf430616812 (diff) | |
parent | a6aea71d78bb09a2647808405f1f7ade4ca67865 (diff) | |
download | openshift-760ea5d197a19a87d624db0a6b110896ab2021b0.tar.gz openshift-760ea5d197a19a87d624db0a6b110896ab2021b0.tar.bz2 openshift-760ea5d197a19a87d624db0a6b110896ab2021b0.tar.xz openshift-760ea5d197a19a87d624db0a6b110896ab2021b0.zip |
Merge pull request #2942 from mtnbikenc/ansible-version
Minimum Ansible version check
-rw-r--r-- | callback_plugins/0_version_requirement.py | 46 | ||||
-rw-r--r-- | playbooks/aws/openshift-cluster/config.yml | 2 | ||||
-rw-r--r-- | playbooks/byo/openshift-cluster/config.yml | 4 | ||||
-rw-r--r-- | playbooks/byo/openshift-cluster/enable_dnsmasq.yml | 4 | ||||
-rw-r--r-- | playbooks/byo/openshift-cluster/redeploy-certificates.yml | 4 | ||||
-rw-r--r-- | playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml | 2 | ||||
-rw-r--r-- | playbooks/byo/openshift_facts.yml | 2 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/init.yml | 2 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/verify_ansible_version.yml | 11 | ||||
-rw-r--r-- | playbooks/libvirt/openshift-cluster/config.yml | 2 | ||||
-rw-r--r-- | playbooks/openstack/openshift-cluster/config.yml | 2 |
11 files changed, 48 insertions, 33 deletions
diff --git a/callback_plugins/0_version_requirement.py b/callback_plugins/0_version_requirement.py new file mode 100644 index 000000000..0c9c2cda9 --- /dev/null +++ b/callback_plugins/0_version_requirement.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import sys +from ansible import __version__ + +if __version__ < '2.0': + from ansible.callbacks import display as pre2_display + CallbackBase = object + + def display(*args, **kwargs): + pre2_display(*args, **kwargs) +else: + from ansible.plugins.callback import CallbackBase + from ansible.utils.display import Display + + def display(*args, **kwargs): + display_instance = Display() + display_instance.display(*args, **kwargs) + + +# Set to minimum required Ansible version +required_version = '2.2.0.0' +DESCRIPTION = "Supported versions: %s or newer" % required_version + + +def version_requirement(version): + return version >= required_version + + +class CallbackModule(CallbackBase): + """ + This callback module stops playbook execution if the Ansible + version is less than required, defined by required_version + """ + + CALLBACK_VERSION = 1.0 + CALLBACK_NAME = 'version_requirement' + + def __init__(self): + super(CallbackModule, self).__init__() + + if not version_requirement(__version__): + display( + 'FATAL: Current Ansible version (%s) is not supported. %s' + % (__version__, DESCRIPTION), color='red') + sys.exit(1) diff --git a/playbooks/aws/openshift-cluster/config.yml b/playbooks/aws/openshift-cluster/config.yml index 05cfe7d6e..49e028396 100644 --- a/playbooks/aws/openshift-cluster/config.yml +++ b/playbooks/aws/openshift-cluster/config.yml @@ -1,6 +1,4 @@ --- -- include: ../../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost gather_facts: no tasks: diff --git a/playbooks/byo/openshift-cluster/config.yml b/playbooks/byo/openshift-cluster/config.yml index df00106d3..5d90da28a 100644 --- a/playbooks/byo/openshift-cluster/config.yml +++ b/playbooks/byo/openshift-cluster/config.yml @@ -1,8 +1,4 @@ --- -- include: ../../common/openshift-cluster/verify_ansible_version.yml - tags: - - always - - name: Create initial host groups for localhost hosts: localhost connection: local diff --git a/playbooks/byo/openshift-cluster/enable_dnsmasq.yml b/playbooks/byo/openshift-cluster/enable_dnsmasq.yml index 0ba11a21b..fab3e111f 100644 --- a/playbooks/byo/openshift-cluster/enable_dnsmasq.yml +++ b/playbooks/byo/openshift-cluster/enable_dnsmasq.yml @@ -1,6 +1,4 @@ --- -- include: ../../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost connection: local become: no @@ -16,5 +14,5 @@ gather_facts: no tasks: - include_vars: ../../byo/openshift-cluster/cluster_hosts.yml - + - include: ../../common/openshift-cluster/enable_dnsmasq.yml diff --git a/playbooks/byo/openshift-cluster/redeploy-certificates.yml b/playbooks/byo/openshift-cluster/redeploy-certificates.yml index 6d1247e0f..73d9baadb 100644 --- a/playbooks/byo/openshift-cluster/redeploy-certificates.yml +++ b/playbooks/byo/openshift-cluster/redeploy-certificates.yml @@ -1,6 +1,4 @@ --- -- include: ../../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost connection: local become: no @@ -16,7 +14,7 @@ gather_facts: no tasks: - include_vars: ../../byo/openshift-cluster/cluster_hosts.yml - + - include: ../../common/openshift-cluster/redeploy-certificates.yml vars: openshift_deployment_type: "{{ deployment_type }}" diff --git a/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml b/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml index c25f96212..a365ae994 100644 --- a/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml +++ b/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml @@ -1,6 +1,4 @@ --- -- include: ../../../common/openshift-cluster/verify_ansible_version.yml - - name: Create initial host groups for localhost hosts: localhost connection: local diff --git a/playbooks/byo/openshift_facts.yml b/playbooks/byo/openshift_facts.yml index 8c0708df0..d1acf6175 100644 --- a/playbooks/byo/openshift_facts.yml +++ b/playbooks/byo/openshift_facts.yml @@ -1,6 +1,4 @@ --- -- include: ../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost connection: local become: no diff --git a/playbooks/common/openshift-cluster/upgrades/init.yml b/playbooks/common/openshift-cluster/upgrades/init.yml index fbdb7900a..8cac2fb3b 100644 --- a/playbooks/common/openshift-cluster/upgrades/init.yml +++ b/playbooks/common/openshift-cluster/upgrades/init.yml @@ -1,6 +1,4 @@ --- -- include: ../verify_ansible_version.yml - - hosts: localhost connection: local become: no diff --git a/playbooks/common/openshift-cluster/verify_ansible_version.yml b/playbooks/common/openshift-cluster/verify_ansible_version.yml deleted file mode 100644 index 8be8fbf04..000000000 --- a/playbooks/common/openshift-cluster/verify_ansible_version.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Verify Ansible version is greater than or equal to 2.2.0 - hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - name: Verify Ansible version is greater than or equal to 2.2.0 - fail: - msg: "Unsupported ansible version: {{ ansible_version.full }} found" - when: not ansible_version.full | version_compare('2.2.0', 'ge') diff --git a/playbooks/libvirt/openshift-cluster/config.yml b/playbooks/libvirt/openshift-cluster/config.yml index 299325fc4..44b0f5a3c 100644 --- a/playbooks/libvirt/openshift-cluster/config.yml +++ b/playbooks/libvirt/openshift-cluster/config.yml @@ -3,8 +3,6 @@ # is localhost, so no hostname value (or public_hostname) value is getting # assigned -- include: ../../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost gather_facts: no tasks: diff --git a/playbooks/openstack/openshift-cluster/config.yml b/playbooks/openstack/openshift-cluster/config.yml index f6550b2c4..1366c83ca 100644 --- a/playbooks/openstack/openshift-cluster/config.yml +++ b/playbooks/openstack/openshift-cluster/config.yml @@ -1,6 +1,4 @@ --- -- include: ../../common/openshift-cluster/verify_ansible_version.yml - - hosts: localhost gather_facts: no tasks: |