docker playbook
This commit is contained in:
parent
3343de2dc0
commit
97ff4b40e3
1 changed files with 45 additions and 25 deletions
|
|
@ -1,34 +1,60 @@
|
||||||
- name: Install Docker and Docker Compose on Debian 12
|
- name: Install Docker and Docker Compose on Debian 12
|
||||||
hosts: all
|
hosts: all
|
||||||
become: yes
|
|
||||||
|
|
||||||
|
become: yes
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ensure required packages are installed
|
- name: Remove old Docker-related packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- docker.io
|
||||||
|
- docker-doc
|
||||||
|
- docker-compose
|
||||||
|
- podman-docker
|
||||||
|
- containerd
|
||||||
|
- runc
|
||||||
|
state: absent
|
||||||
|
purge: yes
|
||||||
|
autoremove: yes
|
||||||
|
|
||||||
|
- name: Update apt cache
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Install prerequisites
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
- curl
|
- curl
|
||||||
- gnupg
|
state: present
|
||||||
- lsb-release
|
|
||||||
|
- name: Create directory for Docker GPG key
|
||||||
|
file:
|
||||||
|
path: /etc/apt/keyrings
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Download Docker GPG key
|
||||||
|
get_url:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
dest: /etc/apt/keyrings/docker.asc
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Get Debian architecture
|
||||||
|
command: dpkg --print-architecture
|
||||||
|
register: deb_arch
|
||||||
|
|
||||||
|
- name: Add Docker repository
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb [arch={{ deb_arch.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian {{ ansible_lsb.codename }} stable"
|
||||||
|
filename: docker
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Add Docker GPG key
|
- name: Update apt cache
|
||||||
ansible.builtin.apt_key:
|
|
||||||
url: https://download.docker.com/linux/debian/gpg
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Add Docker repository
|
|
||||||
ansible.builtin.apt_repository:
|
|
||||||
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
|
||||||
state: present
|
|
||||||
filename: docker
|
|
||||||
|
|
||||||
- name: Update apt cache after adding Docker repo
|
|
||||||
apt:
|
apt:
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Install Docker Engine and CLI
|
- name: Install Docker packages
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- docker-ce
|
- docker-ce
|
||||||
|
|
@ -36,7 +62,8 @@
|
||||||
- containerd.io
|
- containerd.io
|
||||||
- docker-buildx-plugin
|
- docker-buildx-plugin
|
||||||
- docker-compose-plugin
|
- docker-compose-plugin
|
||||||
state: latest
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
- name: Ensure Docker is started and enabled
|
- name: Ensure Docker is started and enabled
|
||||||
systemd:
|
systemd:
|
||||||
|
|
@ -50,10 +77,3 @@
|
||||||
groups: docker
|
groups: docker
|
||||||
append: yes
|
append: yes
|
||||||
|
|
||||||
- name: Create symlink for docker-compose (optional CLI alias)
|
|
||||||
file:
|
|
||||||
src: /usr/libexec/docker/cli-plugins/docker-compose
|
|
||||||
dest: /usr/local/bin/docker-compose
|
|
||||||
state: link
|
|
||||||
when: ansible_facts['os_family'] == "Debian"
|
|
||||||
ignore_errors: true # In case the plugin path differs slightly
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue