--- - 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 {{ ansible_distribution_release }} stable filename: docker state: present - 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-ce - docker-ce-cli - containerd.io - docker-buildx-plugin - docker-compose-plugin state: present update_cache: true - name: Ensure Docker is enabled and running ansible.builtin.systemd: name: docker enabled: true state: started