platform/platform-infra/ansible/roles/docker/tasks/main.yml
Bart Van Geyt 7a65e7f7c6 fix(ansible/backup): create /etc/sanoid and install its defaults
Some sanoid packages (e.g. on Ubuntu 26.04) don't ship /etc/sanoid, so the
config template failed with 'Destination directory does not exist'. Create
the directory explicitly, and copy the packaged sanoid.defaults.conf into
it (sanoid requires it beside sanoid.conf) so the first timer run succeeds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 05:28:08 +02:00

65 lines
1.9 KiB
YAML

---
- name: Create Docker apt keyring dir
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
- name: Add Docker's official GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.asc
mode: "0644"
- name: Add Docker apt repository
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}
signed-by=/etc/apt/keyrings/docker.asc]
https://download.docker.com/linux/ubuntu {{ docker_apt_codename }} stable
filename: docker
state: present
register: docker_repo
- name: Refresh apt cache after adding the Docker repo
ansible.builtin.apt:
update_cache: true
when: docker_repo is changed
- name: Ensure the ZFS docker dataset is mounted at the data-root
ansible.builtin.command: "zfs get -H -o value mounted {{ zfs_pool_name }}/platform/docker"
register: docker_ds_mounted
changed_when: false
failed_when: docker_ds_mounted.stdout != "yes"
# The zfs role creates tank/platform/docker with mountpoint=/var/lib/docker.
# This guards against installing Docker onto the wrong (non-ZFS) filesystem.
- name: Ensure /etc/docker exists
ansible.builtin.file:
path: /etc/docker
state: directory
mode: "0755"
- name: Write Docker daemon configuration (before first start, so the zfs
storage driver initializes on the empty ZFS data-root)
ansible.builtin.template:
src: daemon.json.j2
dest: /etc/docker/daemon.json
owner: root
group: root
mode: "0644"
notify: Restart docker
- name: Install Docker Engine + Compose plugin
ansible.builtin.apt:
name:
- docker.io
- docker-compose-v2
state: present
update_cache: true
- name: Ensure Docker is enabled and running
ansible.builtin.systemd:
name: docker
enabled: true
state: started