The docker prerequisites and the system_baseline packages install only from the distribution's sources, yet refreshed the APT cache on every run. They now pass cache_valid_time: 3600, as the system_baseline update task and user_management already do. The docker and tailscale installs from the role's own APT source keep refreshing on every run, so a run that wrote the source line but failed to fetch its lists heals on the next run. The update entry points are unchanged. The system_baseline README tells a consumer who adds a source just before the role to refresh the cache themselves. Assisted-by: Claude Code:claude-opus-5-5
61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
---
|
|
- name: Install prerequisite packages
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name:
|
|
- ca-certificates
|
|
- curl
|
|
state: present
|
|
update_cache: true
|
|
cache_valid_time: 3600
|
|
tags: [docker, install]
|
|
|
|
- name: Ensure APT keyrings directory exists
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: /etc/apt/keyrings
|
|
state: directory
|
|
mode: "0755"
|
|
tags: [docker, install]
|
|
|
|
- name: Install Docker APT GPG key
|
|
become: true
|
|
ansible.builtin.get_url:
|
|
url: "{{ docker_gpg_url }}"
|
|
dest: "{{ docker_keyring_path }}"
|
|
mode: "0644"
|
|
tags: [docker, install]
|
|
|
|
- name: Install Docker APT source list
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: "{{ docker_apt_list_path }}"
|
|
content: |
|
|
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
|
|
mode: "0644"
|
|
register: __docker_apt_source
|
|
tags: [docker, install]
|
|
|
|
- name: Install Docker Engine packages
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name: "{{ docker_packages }}"
|
|
state: present
|
|
# Always refreshed: a run that wrote the source line but failed to fetch its lists heals here.
|
|
update_cache: true
|
|
register: __docker_packages
|
|
notify: Restart docker
|
|
# Under --check a new source line is only simulated, so apt would find no Docker package.
|
|
when: not ansible_check_mode or __docker_apt_source is not changed
|
|
tags: [docker, install]
|
|
|
|
- name: Enable and start Docker service
|
|
become: true
|
|
ansible.builtin.systemd:
|
|
name: "{{ docker_service }}"
|
|
enabled: true
|
|
state: started
|
|
# Under --check on a host without the packages there is no unit to start yet.
|
|
when: not ansible_check_mode or (__docker_apt_source is not changed and __docker_packages is not changed)
|
|
tags: [docker, install]
|