Files
Terraform/roles/lib/install-docker.yml
2025-11-25 01:51:54 -06:00

88 lines
2.2 KiB
YAML

- name: Install package on Debian 12.x
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
state: present
update_cache: yes
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '<')
- 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
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
when:
- ansible_distribution == "Debian"
- ansible_distribution_version is version('13', '>=')
- 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