Browse Source

Use standard library for version comparison.

Andrew Butcher 9 years ago
parent
commit
05458ecde0
1 changed files with 7 additions and 4 deletions
  1. 7 4
      roles/openshift_facts/library/openshift_facts.py

+ 7 - 4
roles/openshift_facts/library/openshift_facts.py

@@ -20,8 +20,8 @@ EXAMPLES = '''
 import ConfigParser
 import copy
 import os
-from ansible.runner.filter_plugins.core import version_compare
 from distutils.util import strtobool
+from distutils.version import LooseVersion
 
 
 def hostname_valid(hostname):
@@ -503,10 +503,13 @@ def set_deployment_facts_if_unset(facts):
                 data_dir = '/var/lib/openshift'
             facts['common']['data_dir'] = data_dir
         facts['common']['version'] = version = get_openshift_version()
-        if deployment_type == 'origin':
-            version_gt_3_1_or_1_1 = version_compare(version, '1.0.6', '>')
+        if version is not None:
+            if deployment_type == 'origin':
+                version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('1.0.6')
+            else:
+                version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('3.0.2')
         else:
-            version_gt_3_1_or_1_1 = version_compare(version, '3.0.2', '>')
+            version_gt_3_1_or_1_1 = True
         facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1
 
     for role in ('master', 'node'):