From ff3fb0b84b3177b813df91cbed3d96d084bcd72c Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Thu, 1 Oct 2015 09:08:07 -0400 Subject: openshift_facts.py: Ansible fact for openshift version This added some logic to add a new the version of openshift rpm-based installations. This fact is intentionally not cached to account for users potenially updating versions outside of ansible playbooks. --- roles/openshift_facts/library/openshift_facts.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 3ab3663de..aeab7152c 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -474,6 +474,7 @@ def set_deployment_facts_if_unset(facts): if deployment_type in ['enterprise', 'online']: data_dir = '/var/lib/openshift' facts['common']['data_dir'] = data_dir + facts['common']['version'] = get_openshift_version() for role in ('master', 'node'): if role in facts: @@ -598,6 +599,19 @@ def get_current_config(facts): return current_config +def get_openshift_version(): + """ Get current version of openshift on the host + + Returns: + version: the current openshift version + """ + if os.path.isfile('/usr/bin/openshift'): + _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) + versions = dict(e.split(' v') for e in output.splitlines()) + version = versions.get('openshift', '') + + #TODO: acknowledge the possility of a containerized install + return version def apply_provider_facts(facts, provider_facts): """ Apply provider facts to supplied facts dict -- cgit v1.2.3