From 5d5c9cab198def27b4f4bb3f9a57e9f637253856 Mon Sep 17 00:00:00 2001 From: Chad Swenson Date: Mon, 1 Apr 2019 17:08:35 -0500 Subject: [PATCH] Speed up old docker package removal (#4408) Both the `yum` and `apt` modules support a list as input, this allows us avoid the slower `with_items` approach, which can take a long time with a large count of cluster nodes. --- .../container-engine/docker/defaults/main.yml | 18 +++++++++++++++ .../docker/tasks/pre-upgrade.yml | 23 ++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/roles/container-engine/docker/defaults/main.yml b/roles/container-engine/docker/defaults/main.yml index b66c9124a..d771806c7 100644 --- a/roles/container-engine/docker/defaults/main.yml +++ b/roles/container-engine/docker/defaults/main.yml @@ -50,3 +50,21 @@ extras_rh_repo_gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7" # flag to enable/disable docker cleanup docker_orphan_clean_up: false + +# old docker package names to be removed +docker_remove_packages_yum: + - docker + - docker-common + - docker-engine + - docker-selinux.noarch + - docker-client + - docker-client-latest + - docker-latest + - docker-latest-logrotate + - docker-logrotate + - docker-engine-selinux.noarch + +docker_remove_packages_apt: + - docker + - docker-engine + - docker.io \ No newline at end of file diff --git a/roles/container-engine/docker/tasks/pre-upgrade.yml b/roles/container-engine/docker/tasks/pre-upgrade.yml index cf949c4d1..289211ed0 100644 --- a/roles/container-engine/docker/tasks/pre-upgrade.yml +++ b/roles/container-engine/docker/tasks/pre-upgrade.yml @@ -1,31 +1,16 @@ --- - name: Ensure old versions of Docker are not installed. | Debian - package: - name: '{{ item }}' + apt: + name: '{{ docker_remove_packages_apt }}' state: absent - with_items: - - docker - - docker-engine - - docker.io when: - ansible_os_family == 'Debian' - (docker_versioned_pkg[docker_version | string] is search('docker-ce')) - name: Ensure old versions of Docker are not installed. | RedHat - package: - name: '{{ item }}' + yum: + name: '{{ docker_remove_packages_yum }}' state: absent - with_items: - - docker - - docker-common - - docker-engine - - docker-selinux.noarch - - docker-client - - docker-client-latest - - docker-latest - - docker-latest-logrotate - - docker-logrotate - - docker-engine-selinux.noarch when: - ansible_os_family == 'RedHat' - (docker_versioned_pkg[docker_version | string] is search('docker-ce'))