ansible-role-docker/tasks/deb_pkgs.yml

76 lines
2.2 KiB
YAML

---
- name: Docker.com repository
when: docker_install | bool
tags: [docker, docker_pkg]
block:
- name: Add the Docker repository key
ansible.builtin.apt_key:
url: "{{ docker_deb_repo_key_url }}"
state: present
- name: Remove the old docker packages, from the old distribution method
ansible.builtin.apt:
pkg: "{{ docker_deb_old_packages }}"
state: absent
- name: Remove the obsolete docker repository
ansible.builtin.apt_repository:
repo: "{{ docker_deb_repo_old }}"
state: absent
update_cache: true
- name: Add the Docker repository
ansible.builtin.apt_repository:
repo: "{{ docker_deb_repo }}"
update_cache: true
- name: Install the latest Docker package available
ansible.builtin.apt:
pkg: "{{ docker_deb_packages }}"
state: "{{ docker_pkg_status }}"
cache_valid_time: 3600
when: not docker_specific_package_ver
- name: Install a specific Docker package version
ansible.builtin.apt:
pkg: "{{ docker_versioned_deb_packages }}"
state: "{{ docker_pkg_status }}"
cache_valid_time: 3600
force: true
when: docker_specific_package_ver
- name: Install some pyton 3 packages required by ansible
ansible.builtin.apt:
pkg: "{{ docker_python_deb_pkgs }}"
state: present
cache_valid_time: 3600
force: true
when: not py3_env_install
- name: Remove the docker packages and repository
when: not docker_install | bool
tags: [docker, docker_pkg]
block:
- name: Ensure that the service is stopped and disabled
ansible.builtin.service:
name: docker
state: stopped
enabled: false
ignore_errors: true
- name: Remove the Docker package
ansible.builtin.apt:
pkg: "{{ docker_deb_packages }}"
state: absent
- name: Remove the Docker repository key
ansible.builtin.apt_key:
id: "{{ docker_deb_repo_key }}"
state: absent
- name: Remove the Docker repository
ansible.builtin.apt_repository:
repo: "{{ docker_deb_repo }}"
state: absent
update_cache: true