diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-07-14 18:49:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-14 18:49:24 -0400 |
commit | 65ffae3e6edc8902c591dfef792a505a16029698 (patch) | |
tree | a28948529ce2a4c8b700aaf5352173be1aea8f8a /roles/openshift_version/tasks | |
parent | 1a6b1bf010b661feb8495d4088f9a0f2640b5658 (diff) | |
parent | 03f31fdc581eea090388b5a60b3818167eb47c0c (diff) | |
download | openshift-65ffae3e6edc8902c591dfef792a505a16029698.tar.gz openshift-65ffae3e6edc8902c591dfef792a505a16029698.tar.bz2 openshift-65ffae3e6edc8902c591dfef792a505a16029698.tar.xz openshift-65ffae3e6edc8902c591dfef792a505a16029698.zip |
Merge pull request #1945 from dgoodwin/upgrade33
openshift_release / version / upgrade improvements
Diffstat (limited to 'roles/openshift_version/tasks')
-rw-r--r-- | roles/openshift_version/tasks/main.yml | 76 | ||||
-rw-r--r-- | roles/openshift_version/tasks/set_version_containerized.yml | 39 | ||||
-rw-r--r-- | roles/openshift_version/tasks/set_version_rpm.yml | 18 |
3 files changed, 133 insertions, 0 deletions
diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml new file mode 100644 index 000000000..2d96d2765 --- /dev/null +++ b/roles/openshift_version/tasks/main.yml @@ -0,0 +1,76 @@ +--- +# Determine the openshift_version to configure if none has been specified or set previously. + +- set_fact: + is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" + +# Block attempts to install origin without specifying some kind of version information. +# This is because the latest tags for origin are usually alpha builds, which should not +# be used by default. Users must indicate what they want. +- fail: + msg: "Must specify openshift_release or openshift_image_tag in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)" + when: is_containerized | bool and openshift.common.deployment_type == 'origin' and openshift_release is not defined and openshift_image_tag is not defined + +# Normalize some values that we need in a certain format that might be confusing: +- set_fact: + openshift_release: "{{ openshift_release[1:] }}" + when: openshift_release is defined and openshift_release[0] == 'v' + +- set_fact: + openshift_image_tag: "{{ 'v' + openshift_image_tag }}" + when: openshift_image_tag is defined and openshift_image_tag[0] != 'v' + +- set_fact: + openshift_pkg_version: "{{ '-' + openshift_pkg_version }}" + when: openshift_pkg_version is defined and openshift_pkg_version[0] != '-' + +# Make sure we copy this to a fact if given a var: +- set_fact: + openshift_version: "{{ openshift_version }}" + when: openshift_version is defined + +# Protect the installed version by default unless explicitly told not to, or given an +# openshift_version already. +- name: Use openshift.common.version fact as version to configure if already installed + set_fact: + openshift_version: "{{ openshift.common.version }}" + when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version | bool + +- name: Set openshift_version for rpm installation + include: set_version_rpm.yml + when: not is_containerized | bool + +- name: Set openshift_version for containerized installation + include: set_version_containerized.yml + when: is_containerized | bool + +# At this point we know openshift_version is set appropriately. Now we set +# openshift_image_tag and openshift_pkg_version, so all roles can always assume +# each of this variables *will* be set correctly and can use them per their +# intended purpose. + +- set_fact: + openshift_image_tag: v{{ openshift_version }} + when: openshift_image_tag is not defined + +- set_fact: + openshift_pkg_version: -{{ openshift_version }} + when: openshift_pkg_version is not defined + +- fail: + msg: openshift_version role was unable to set openshift_version + when: openshift_version is not defined + +- fail: + msg: openshift_version role was unable to set openshift_image_tag + when: openshift_image_tag is not defined + +- fail: + msg: openshift_version role was unable to set openshift_pkg_version + when: openshift_pkg_version is not defined + +# We can't map an openshift_release to full rpm version like we can with containers, make sure +# the rpm version we looked up matches the release requested and error out if not. +- fail: + msg: "Detected openshift version {{ openshift_version }} does not match requested openshift_release {{ openshift_release }}. You may need to adjust your yum repositories or specify an exact openshift_pkg_version." + when: not is_containerized | bool and openshift_release is defined and not openshift_version.startswith(openshift_release) | bool diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml new file mode 100644 index 000000000..8e2702391 --- /dev/null +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -0,0 +1,39 @@ +--- +- name: Set containerized version to configure if openshift_image_tag specified + set_fact: + # Expects a leading "v" in inventory, strip it off here: + openshift_version: "{{ openshift_image_tag[1:].split('-')[0] }}" + when: openshift_image_tag is defined and openshift_version is not defined + +- name: Set containerized version to configure if openshift_release specified + set_fact: + openshift_version: "{{ openshift_release }}" + when: openshift_release is defined and openshift_version is not defined + +- name: Lookup latest containerized version if no version specified + command: > + docker run --rm {{ openshift.common.cli_image }}:latest version + register: cli_image_version + when: openshift_version is not defined + +# Origin latest = pre-release version (i.e. v1.3.0-alpha.1-321-gb095e3a) +- set_fact: + openshift_version: "{{ (cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-'))[1:] }}" + when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length > 1 + +- set_fact: + openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" + when: openshift_version is not defined + +# If we got an openshift_version like "3.2", lookup the latest 3.2 container version +# and use that value instead. +- name: Set precise containerized version to configure if openshift_release specified + command: > + docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version + register: cli_image_version + when: openshift_version is defined and openshift_version.split('.') | length == 2 + +- set_fact: + openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" + when: openshift_version is defined and openshift_version.split('.') | length == 2 + diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml new file mode 100644 index 000000000..7fa74e24f --- /dev/null +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -0,0 +1,18 @@ +--- +- name: Set rpm version to configure if openshift_pkg_version specified + set_fact: + # Expects a leading "-" in inventory, strip it off here, and remove trailing release, + openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" + when: openshift_pkg_version is defined and openshift_version is not defined + +- name: Gather common package version + command: > + {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type}}" + register: common_version + failed_when: false + changed_when: false + when: openshift_version is not defined + +- set_fact: + openshift_version: "{{ common_version.stdout | default('0.0', True) }}" + when: openshift_version is not defined |