Files
Watari-Ansible/playbooks/setup-docker.yaml
Ryan Toler eb89ecce10 new file
2026-03-02 07:47:59 +00:00

81 lines
2.0 KiB
YAML

- name: Install package on Debian 13.x
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
state: present
update_cache: yes
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '>=')
- name: Setup Docker reposoitory
ansible.builtin.deb822_repository:
name: docker
types: [deb]
uris: "https://download.docker.com/linux/debian"
components: [stable]
suites: ["trixie"]
signed_by: https://download.docker.com/linux/debian/gpg
state: present
enabled: true
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '>=')
- name: Install Docker Engine Debian 12.x
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io=1.7.28-1*
- docker-compose-plugin
state: present
update_cache: yes
allow_downgrade: true
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '<')
- name: Install Docker Engine Debian 13.x
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io=1.7.28-1*
- docker-compose-plugin
state: present
update_cache: yes
allow_downgrade: true
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '>=')
- name: Hold containerd.io package
ansible.builtin.dpkg_selections:
name: containerd.io
selection: hold
- name: Create docker user
user:
name: docker
uid: 2000
group: docker
state: present
create_home: yes
home: /home/docker
shell: /bin/bash
- name: Add key for docker user
ansible.posix.authorized_key:
user: docker
state: present
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIjMDDhinpnCPFUMERa/tLYymzRI8oJoAvXZnBH9wpA4 fake@gmail.com"
- name: Start Docker service
systemd:
name: docker
state: started
enabled: yes