Bug 1642361

Summary: openshift-ansible check prerequisite.yml fails prerequisite ansible version
Product: OpenShift Container Platform Reporter: jliberma <jliberma>
Component: InstallerAssignee: Antoni Segura Puimedon <asegurap>
Status: CLOSED ERRATA QA Contact: Weihua Meng <wmeng>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.11.0CC: aos-bugs, gpei, jokerman, ltomasbo, mmccomas, wmeng
Target Milestone: ---   
Target Release: 3.11.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: OpenShift-Ansible's version check was using alphanumeric order instead of semantic versioning order. Consequence: 2.5.10 would be considered not to meet a requirement for a version newer than 2.5.6. Fix: Do semantic versioning check. Result: 2.5.10 is rightly recognized as newer than 2.5.6
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-12 14:15:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description jliberma@redhat.com 2018-10-24 08:58:52 UTC
Description of problem:

openshift-ansible fails prerequisite check for Ansible version because it uses a string compare instead of strict_checking.

For example, if the requirement is version 5.7 or higher, and you have version 5.10, the check will fail because the string value of 5.10 is less than 5.7.

Version-Release number of the following components:
rpm -q openshift-ansible
openshift-ansible-3.11.22-1.git.1.c4bb7a6.el7.noarch
rpm -q ansible
ansible-2.5.10-1.el7ae.noarch
ansible --version
ansible 2.5.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

How reproducible:

Every time

Steps to Reproduce:
1. Install Ansible 5.10
2. Install OpenShift-Ansible 
3. ansible-playbook --user openshift -i /usr/share/ansible/openshift-ansible/playbooks/openstack/inventory.py -i inventory /usr/share/ansible/openshift-ansible/playbooks/openstack/openshift-cluster/prerequisites.yml

Actual results:

FATAL: Current Ansible version (2.5.10) is not supported. Supported versions: 2.5.7 or newer

Expected results:

(works)

Additional info:

To fix: (/usr/share/ansible/openshift-ansible/roles/lib_utils/callback_plugins/aa_version_requirement.py)

diff --git a/roles/lib_utils/callback_plugins/aa_version_requirement.py b/roles/lib_utils/callback_plugins/aa_version_requirement.py
index 175c99f91..fc594df60 100644
--- a/roles/lib_utils/callback_plugins/aa_version_requirement.py
+++ b/roles/lib_utils/callback_plugins/aa_version_requirement.py
@@ -7,6 +7,8 @@ The plugin is named with leading `aa_` to ensure this plugin is loaded
 first (alphanumerically) by Ansible.
 """
 import sys
+from distutils import version
+
 from ansible import __version__
 
 if __version__ < '2.0':
@@ -29,13 +31,13 @@ else:
  
 # Set to minimum required Ansible version
-REQUIRED_VERSION = '2.5.7'
+REQUIRED_VERSION = version.StrictVersion('2.5.7')
 DESCRIPTION = "Supported versions: %s or newer" % REQUIRED_VERSION
 
 def version_requirement(version):
     """Test for minimum required version"""
-    return version >= REQUIRED_VERSION
+    return version.StrictVersion(version) >= REQUIRED_VERSION

Comment 1 Luis Tomas Bolivar 2018-10-24 10:39:46 UTC
Solution for the problem is on this PR: https://github.com/openshift/openshift-ansible/pull/10484

Comment 5 Weihua Meng 2018-11-28 06:58:53 UTC
Fixed.

openshift-ansible-3.11.44-1.git.0.11d174e.el7.noarch

ansible-2.5.10-1.el7ae.noarch
ansible-2.5.11-1.el7ae.noarch

Comment 7 errata-xmlrpc 2018-12-12 14:15:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3743