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.
This commit is contained in:
Chad Swenson 2019-04-01 17:08:35 -05:00 committed by Kubernetes Prow Robot
parent 5f12b7aedf
commit 5d5c9cab19
2 changed files with 22 additions and 19 deletions

View file

@ -50,3 +50,21 @@ extras_rh_repo_gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7"
# flag to enable/disable docker cleanup # flag to enable/disable docker cleanup
docker_orphan_clean_up: false 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

View file

@ -1,31 +1,16 @@
--- ---
- name: Ensure old versions of Docker are not installed. | Debian - name: Ensure old versions of Docker are not installed. | Debian
package: apt:
name: '{{ item }}' name: '{{ docker_remove_packages_apt }}'
state: absent state: absent
with_items:
- docker
- docker-engine
- docker.io
when: when:
- ansible_os_family == 'Debian' - ansible_os_family == 'Debian'
- (docker_versioned_pkg[docker_version | string] is search('docker-ce')) - (docker_versioned_pkg[docker_version | string] is search('docker-ce'))
- name: Ensure old versions of Docker are not installed. | RedHat - name: Ensure old versions of Docker are not installed. | RedHat
package: yum:
name: '{{ item }}' name: '{{ docker_remove_packages_yum }}'
state: absent 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: when:
- ansible_os_family == 'RedHat' - ansible_os_family == 'RedHat'
- (docker_versioned_pkg[docker_version | string] is search('docker-ce')) - (docker_versioned_pkg[docker_version | string] is search('docker-ce'))