update docker role & add separate play

This commit is contained in:
2026-08-05 20:48:24 +02:00
parent 7013159c29
commit 1fc2506cf4
11 changed files with 225 additions and 103 deletions
+19 -41
View File
@@ -1,45 +1,23 @@
---
- name: Clean install by removing any docker package
package: name={{ item }} state=absent
with_items: "{{ clean_install_remove_packages }}"
- name: Assert supported distribution
ansible.builtin.include_tasks: check_distro.yml
tags:
- docker_check_distro
- name: Ensure curl & ca-certs are installed
package:
name:
- ca-certificates
- curl
- gnupg
state: latest
- name: Install Docker
ansible.builtin.include_tasks: install.yml
when: docker_distro_supported
tags:
- docker_install
- name: Ensure docker keyring file exists
file:
path: /etc/apt/keyrings/docker.gpg
state: touch
- name: Download docker gpg key and add to keyrings
shell: |
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
- name: Configure Docker group membership
ansible.builtin.include_tasks: users.yml
when: docker_distro_supported and docker_users | length > 0
tags:
- docker_users
- name: Sign and add docker deb source
shell: |
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
- name: Update apt sources
become: true
apt:
update_cache: yes
cache_valid_time: 1
- name: Install docker packages
package: name={{ item }} state=latest
with_items: "{{ install_packages }}"
- name: Ensure group docker exists
user:
name: docker
state: present
- name: Manage Docker service
ansible.builtin.include_tasks: service.yml
when: docker_distro_supported
tags:
- docker_service