diff options
author | Scott Dodson <sdodson@redhat.com> | 2017-12-12 14:40:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 14:40:29 -0500 |
commit | e2a6cde4f4e7d4a003950afc388f2cb60414c775 (patch) | |
tree | 7d2987a0d340b8f7f1feb17f15278fc5de8cb9be /roles/container_runtime | |
parent | 549bd2c81da98333e229f8afb467aa909917a8a4 (diff) | |
parent | e1df3b6ba7b78255c8022468e9ad1a32255e5e59 (diff) | |
download | openshift-e2a6cde4f4e7d4a003950afc388f2cb60414c775.tar.gz openshift-e2a6cde4f4e7d4a003950afc388f2cb60414c775.tar.bz2 openshift-e2a6cde4f4e7d4a003950afc388f2cb60414c775.tar.xz openshift-e2a6cde4f4e7d4a003950afc388f2cb60414c775.zip |
Merge pull request #6407 from mgugino-upstream-stage/crt-upgrades
Refactor upgrade codepaths step 1
Diffstat (limited to 'roles/container_runtime')
-rw-r--r-- | roles/container_runtime/tasks/docker_upgrade_check.yml | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/roles/container_runtime/tasks/docker_upgrade_check.yml b/roles/container_runtime/tasks/docker_upgrade_check.yml new file mode 100644 index 000000000..f29619f42 --- /dev/null +++ b/roles/container_runtime/tasks/docker_upgrade_check.yml @@ -0,0 +1,67 @@ +--- + +# This snippet determines if a Docker upgrade is required by checking the inventory +# variables, the available packages, and sets l_docker_upgrade to True if so. + +- set_fact: + docker_upgrade: True + when: docker_upgrade is not defined + +- name: Check if Docker is installed + command: rpm -q docker + args: + warn: no + register: pkg_check + failed_when: pkg_check.rc > 1 + changed_when: no + +- name: Get current version of Docker + command: "{{ repoquery_installed }} --qf '%{version}' docker" + register: curr_docker_version + retries: 4 + until: curr_docker_version | succeeded + changed_when: false + +- name: Get latest available version of Docker + command: > + {{ repoquery_cmd }} --qf '%{version}' "docker" + register: avail_docker_version + retries: 4 + until: avail_docker_version | succeeded + # Don't expect docker rpm to be available on hosts that don't already have it installed: + when: pkg_check.rc == 0 + failed_when: false + changed_when: false + +- fail: + msg: This playbook requires access to Docker 1.12 or later + # Disable the 1.12 requirement if the user set a specific Docker version + when: docker_version is not defined and (docker_upgrade is not defined or docker_upgrade | bool == True) and (pkg_check.rc == 0 and (avail_docker_version.stdout == "" or avail_docker_version.stdout | version_compare('1.12','<'))) + +# Default l_docker_upgrade to False, we'll set to True if an upgrade is required: +- set_fact: + l_docker_upgrade: False + +# Make sure a docker_version is set if none was requested: +- set_fact: + docker_version: "{{ avail_docker_version.stdout }}" + when: pkg_check.rc == 0 and docker_version is not defined + +- name: Flag for Docker upgrade if necessary + set_fact: + l_docker_upgrade: True + when: pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') + +# Additional checks for Atomic hosts: +- name: Determine available Docker + shell: "rpm -q --queryformat '---\ncurr_version: %{VERSION}\navail_version: \n' docker" + register: g_atomic_docker_version_result + when: openshift.common.is_atomic | bool + +- set_fact: + l_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}" + when: openshift.common.is_atomic | bool + +- fail: + msg: This playbook requires access to Docker 1.12 or later + when: openshift.common.is_atomic | bool and l_docker_version.avail_version | default(l_docker_version.curr_version, true) | version_compare('1.12','<') |