Fix Docker install for Ubuntu 22.04+ and ARM64 OCI instances
- Replace deprecated apt_key/apt_repository with modern keyrings approach (signed-by) - Use ansible_distribution_release instead of hardcoded focal - Auto-detect arch: arm64 for aarch64 (Ampere), amd64 for x86 - Replace docker-compose (v1, EOL) with docker-compose-plugin (v2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,25 +16,35 @@
|
||||
update_cache: true
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Add Docker GPG apt Key
|
||||
apt_key:
|
||||
- name: Create apt keyrings directory
|
||||
ansible.builtin.file:
|
||||
path: /etc/apt/keyrings
|
||||
state: directory
|
||||
mode: '0755'
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Download Docker GPG key
|
||||
ansible.builtin.get_url:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
dest: /etc/apt/keyrings/docker.asc
|
||||
mode: '0644'
|
||||
force: false
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Add Docker Repository
|
||||
apt_repository:
|
||||
repo: deb https://download.docker.com/linux/ubuntu focal stable
|
||||
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"
|
||||
state: present
|
||||
filename: docker
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Update apt and install Docker packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose
|
||||
- docker-compose-plugin
|
||||
state: latest
|
||||
update_cache: true
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
Reference in New Issue
Block a user