diff --git a/playbooks/install-standard-docker.yml b/playbooks/install-standard-docker.yml index ce74809..fc9c1b4 100644 --- a/playbooks/install-standard-docker.yml +++ b/playbooks/install-standard-docker.yml @@ -1,18 +1,21 @@ --- - name: Install Docker using official Docker documentation steps - hosts: docker + hosts: all become: true vars: + # Path to store Docker's GPG keyring docker_keyring_path: /etc/apt/keyrings/docker.asc + + # Path to store the Docker APT source list docker_repo_list_path: /etc/apt/sources.list.d/docker.list tasks: - - name: Ensure required packages are installed + - name: Ensure required packages for Docker APT setup are installed apt: name: - - ca-certificates - - curl + - ca-certificates # Needed for HTTPS APT repos + - curl # Used to download the GPG key state: present update_cache: yes @@ -22,34 +25,50 @@ state: directory mode: "0755" - - name: Download Docker's official GPG key + - name: Download Docker's official GPG key to keyring path get_url: url: https://download.docker.com/linux/ubuntu/gpg dest: "{{ docker_keyring_path }}" mode: "0644" - - name: Add Docker repository to Apt sources + # Workaround block: + - name: Determine compatible Docker codename (bandage for Ubuntu 24.04 "noble") + set_fact: + docker_codename: "{{ 'jammy' if ansible_lsb.codename == 'noble' else ansible_lsb.codename }}" + + - name: Add Docker APT repository using the compatible codename copy: dest: "{{ docker_repo_list_path }}" content: | - deb [arch={{ ansible_architecture }} signed-by={{ docker_keyring_path }}] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable + deb [arch={{ ansible_architecture }} signed-by={{ docker_keyring_path }}] https://download.docker.com/linux/ubuntu {{ docker_codename }} stable notify: Update apt cache - - name: Flush handlers to update apt cache before installing Docker + - name: Flush handlers to make sure apt cache is updated before install meta: flush_handlers - name: Install Docker packages apt: name: - - docker-ce - - docker-ce-cli - - containerd.io - - docker-buildx-plugin - - docker-compose-plugin + - docker-ce # Core Docker engine + - docker-ce-cli # CLI tool + - containerd.io # Container runtime + - docker-buildx-plugin # Buildx plugin + - docker-compose-plugin # Compose v2 plugin state: present - update_cache: no # Already handled + update_cache: no # Cache is already updated by handler handlers: - name: Update apt cache apt: update_cache: yes +# ------------------------------------------------------------ +# 📝 Optional: Revert this when Docker supports Ubuntu 24.04 natively +# Just replace the repo setup block with the following: + +# - name: Add Docker APT repository using native codename +# copy: +# dest: "{{ docker_repo_list_path }}" +# content: | +# deb [arch={{ ansible_architecture }} signed-by={{ docker_keyring_path }}] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable +# notify: Update apt cache +# ------------------------------------------------------------