summaryrefslogtreecommitdiffstats
path: root/roles/container_runtime/tasks
diff options
context:
space:
mode:
authorMichael Gugino <mgugino@redhat.com>2017-12-08 13:38:03 -0500
committerMichael Gugino <mgugino@redhat.com>2017-12-12 10:04:41 -0500
commite1df3b6ba7b78255c8022468e9ad1a32255e5e59 (patch)
treedc3a2f8018412314c1fa84bd526610c0c83660eb /roles/container_runtime/tasks
parent01ae634a0bf89fe840006f9139f8ffd20e09afc8 (diff)
downloadopenshift-e1df3b6ba7b78255c8022468e9ad1a32255e5e59.tar.gz
openshift-e1df3b6ba7b78255c8022468e9ad1a32255e5e59.tar.bz2
openshift-e1df3b6ba7b78255c8022468e9ad1a32255e5e59.tar.xz
openshift-e1df3b6ba7b78255c8022468e9ad1a32255e5e59.zip
Refactor upgrade codepaths step 1
This commit refactors some upgrade code paths. Touched areas are: 1) Reduces usage of 'oo_all_hosts' in various places, especially when running upgrade_control_plane. 2) Reuses common code across the various upgrade* playbooks. 3) Moves docker upgrade checks into container_runtime_role. 4) Combines smaller playbooks and plays to reduce file sprawl.
Diffstat (limited to 'roles/container_runtime/tasks')
-rw-r--r--roles/container_runtime/tasks/docker_upgrade_check.yml67
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','<')