diff options
author | Samuel Munilla <smunilla@redhat.com> | 2015-10-01 09:08:07 -0400 |
---|---|---|
committer | Samuel Munilla <smunilla@redhat.com> | 2015-10-01 14:21:30 -0400 |
commit | ff3fb0b84b3177b813df91cbed3d96d084bcd72c (patch) | |
tree | 4ab08f8e24d00ccccc22010521ce5eff9a1aa8e7 | |
parent | 7be731dd7a0a5cfb5949d53a896ebd282aa7303f (diff) | |
download | openshift-ff3fb0b84b3177b813df91cbed3d96d084bcd72c.tar.gz openshift-ff3fb0b84b3177b813df91cbed3d96d084bcd72c.tar.bz2 openshift-ff3fb0b84b3177b813df91cbed3d96d084bcd72c.tar.xz openshift-ff3fb0b84b3177b813df91cbed3d96d084bcd72c.zip |
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.
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 14 |
1 files changed, 14 insertions, 0 deletions
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 |