diff options
author | Tim Bielawa <timbielawa@gmail.com> | 2016-12-09 07:24:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-09 07:24:15 -0800 |
commit | ce39c9084bc20df242bbbef3a2a5b1c8060cbe9d (patch) | |
tree | 9f1a255e9b5e4d39ca18baf28a5e0b27007f0433 | |
parent | 760ea5d197a19a87d624db0a6b110896ab2021b0 (diff) | |
parent | 9947e539f36a0be38b4902b7b55f2fc4023a064f (diff) | |
download | openshift-ce39c9084bc20df242bbbef3a2a5b1c8060cbe9d.tar.gz openshift-ce39c9084bc20df242bbbef3a2a5b1c8060cbe9d.tar.bz2 openshift-ce39c9084bc20df242bbbef3a2a5b1c8060cbe9d.tar.xz openshift-ce39c9084bc20df242bbbef3a2a5b1c8060cbe9d.zip |
Merge pull request #2959 from mtnbikenc/plugin_lint
Resolved lint issues for version_requirement plugin
-rw-r--r-- | callback_plugins/aa_version_requirement.py (renamed from callback_plugins/0_version_requirement.py) | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/callback_plugins/0_version_requirement.py b/callback_plugins/aa_version_requirement.py index 0c9c2cda9..1cca19a45 100644 --- a/callback_plugins/0_version_requirement.py +++ b/callback_plugins/aa_version_requirement.py @@ -1,42 +1,56 @@ #!/usr/bin/python +""" +This callback plugin verifies the required minimum version of Ansible +is installed for proper operation of the OpenShift Ansible Installer. +The plugin is named with leading `aa_` to ensure this plugin is loaded +first (alphanumerically) by Ansible. +""" import sys from ansible import __version__ if __version__ < '2.0': + # pylint: disable=import-error,no-name-in-module + # Disabled because pylint warns when Ansible v2 is installed from ansible.callbacks import display as pre2_display CallbackBase = object def display(*args, **kwargs): + """Set up display function for pre Ansible v2""" pre2_display(*args, **kwargs) else: from ansible.plugins.callback import CallbackBase from ansible.utils.display import Display def display(*args, **kwargs): + """Set up display function for Ansible v2""" 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 +REQUIRED_VERSION = '2.2.0.0' +DESCRIPTION = "Supported versions: %s or newer" % REQUIRED_VERSION def version_requirement(version): - return version >= required_version + """Test for minimum required 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 + Ansible callback plugin """ CALLBACK_VERSION = 1.0 CALLBACK_NAME = 'version_requirement' def __init__(self): + """ + Version verification is performed in __init__ to catch the + requirement early in the execution of Ansible and fail gracefully + """ super(CallbackModule, self).__init__() if not version_requirement(__version__): |