diff options
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 1 | ||||
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 14 | ||||
-rw-r--r-- | roles/openshift_version/tasks/main.yml | 5 |
3 files changed, 17 insertions, 3 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 770ccaa78..1a3b557e7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -109,7 +109,6 @@ - openshift_facts - openshift_docker_facts tasks: - - debug: var=openshift.docker.openshift_version - name: Ensure Node is running service: name: "{{ openshift.common.service_type }}-node" diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 856dcbdb8..9d7705af7 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1139,11 +1139,21 @@ def get_openshift_version(facts): _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) version = parse_openshift_version(output) elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: - _, output, _ = module.run_command(['docker', 'run', '--rm', facts['common']['cli_image'], 'version']) - version = parse_openshift_version(output) + version = get_containerized_node_openshift_version(facts) return version +def get_containerized_node_openshift_version(facts): + node_svc = "%s-node" % facts['common']['service_type'] + rc, _, _ = module.run_command(['systemctl', 'is-active', node_svc]) + if rc > 0: + # Node service not running or doesn't exist: + return None + # Node service running, exec in and get the version: + _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) + return parse_openshift_version(output) + + def parse_openshift_version(output): """ Apply provider facts to supplied facts dict diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 39accf579..29724a9e5 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -4,6 +4,11 @@ - set_fact: is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" +# Make sure we copy this to a fact if given a var: +- set_fact: + openshift_version: "{{ openshift_version }}" + when: openshift_version is defined + - debug: var=openshift_version - debug: var=openshift_release - debug: var=openshift_pkg_version |