Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switched removing obsolete packages to variable #472 #485

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ You can control whether the package is installed, uninstalled, or at the latest

```yaml
docker_obsolete_packages:
```

A list of packages to be uninstalled on all platforms prior to running this role. By default this will `docker_obsolete_packages_debian` on debian based systems and `docker_obsolete_packages_redhat` on redhat systems.

```yaml
docker_obsolete_packages_debian:
- docker
- docker.io
- docker-engine
Expand All @@ -39,8 +45,23 @@ docker_obsolete_packages:
- containerd
- runc
```
A list of packages to be uninstalled on Debian based systems prior to running this role. See [Docker's installation instructions](https://docs.docker.com/engine/install/debian/#uninstall-old-versions) for an up-to-date list of old packages that should be removed.

```yaml
docker_obsolete_packages_redhat:
- docker
- docker-client
- docker-client-latest
- docker-common
- docker-latest
- docker-latest-logrotate
- docker-logrotate
- docker-engine
- podman
- runc
```

A list of packages to be uninstalled prior to running this role. See [Docker's installation instructions](https://docs.docker.com/engine/install/debian/#uninstall-old-versions) for an up-to-date list of old packages that should be removed.
A list of packaged to be uninstalled on RedHat based systems prior to running this role. See [Docker's installation instructions](https://docs.docker.com/engine/install/rhel/#uninstall-old-versions) for an up-to-date list of old packages that should be removed.

```yaml
docker_service_manage: true
Expand Down
15 changes: 14 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@
- "containerd.io"
- docker-buildx-plugin
docker_packages_state: present
docker_obsolete_packages:

# obsolete packages are different on Redhat and Debian and are set to docker_obsolete_packages in their respective tasks files
docker_obsolete_packages_debian:
- docker
- docker.io
- docker-engine
- docker-doc
- podman-docker
- containerd
- runc
docker_obsolete_packages_redhat:
- docker
- docker-client
- docker-client-latest
- docker-common
- docker-latest
- docker-latest-logrotate
- docker-logrotate
- docker-engine
- podman
- runc

# Service options.
docker_service_manage: true
Expand Down Expand Up @@ -47,7 +60,7 @@
# and is only necessary until Docker officially supports them.
docker_apt_ansible_distribution: "{{ 'ubuntu' if ansible_distribution in ['Pop!_OS', 'Linux Mint'] else ansible_distribution }}"
docker_apt_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'armhf' if ansible_architecture == 'armv7l' else 'amd64' }}"
docker_apt_repository: "deb [arch={{ docker_apt_arch }} signed-by=/etc/apt/keyrings/docker.asc] {{ docker_repo_url }}/{{ docker_apt_ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"

Check warning on line 63 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / Lint

63:201 [line-length] line too long (232 > 200 characters)
docker_apt_ignore_key_error: true
docker_apt_gpg_key: "{{ docker_repo_url }}/{{ docker_apt_ansible_distribution | lower }}/gpg"
docker_apt_gpg_key_checksum: "sha256:1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570"
Expand Down
5 changes: 5 additions & 0 deletions tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@

- name: Ensure the repo referencing the previous trusted.gpg.d key is not present
apt_repository:
repo: "deb [arch={{ docker_apt_arch }} signed-by=/etc/apt/trusted.gpg.d/docker.asc] {{ docker_repo_url }}/{{ docker_apt_ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"

Check warning on line 14 in tasks/setup-Debian.yml

View workflow job for this annotation

GitHub Actions / Lint

14:201 [line-length] line too long (224 > 200 characters)
state: absent
filename: "{{ docker_apt_filename }}"
update_cache: true
when: docker_add_repo | bool

- name: Set obselete packages if not already defined
set_fact:
docker_obsolete_packages: "{{ docker_obsolete_packages_debian }}"
when: docker_obsolete_packages is not defined

- # See https://docs.docker.com/engine/install/debian/#uninstall-old-versions

Check warning on line 25 in tasks/setup-Debian.yml

View workflow job for this annotation

GitHub Actions / Lint

25:3 [comments] too few spaces before comment
name: Ensure old versions of Docker are not installed.
package:
name: "{{ docker_obsolete_packages }}"
Expand Down
14 changes: 10 additions & 4 deletions tasks/setup-RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
---
- name: Set obselete packages if not already defined
set_fact:
docker_obsolete_packages: "{{ docker_obsolete_packages_redhat }}"
when: docker_obsolete_packages is not defined

- name: Ensure old versions of Docker are not installed.
package:
name:
- docker
- docker-common
- docker-engine
name: "{{ docker_obsolete_packages }}"
state: absent
register: obsolete_package_results
failed_when:
- '"Depsolve Error occurred" not in obsolete_package_results.msg'
- obsolete_package_results.rc == 0

- name: Add Docker GPG key.
rpm_key:
Expand Down
Loading