pez-infra/ansible/roles/docker/tasks/main.yml
Rasmus "Pez" Wejlgaard 0247f6aa6b
Fix docker-compose package conflict and alpine firewall handler (#22)
- Docker role: replace docker-compose with docker-compose-plugin (v2).
  The old docker-compose package conflicts with docker-compose-plugin
  already installed on helsinki-a. Also removes the conflicting package
  if present.

- firewall_alpine handler: use ansible.builtin.shell instead of
  ansible.builtin.command for iptables-restore, since the redirect
  operator (<) requires a shell.
2026-03-29 19:11:52 +01:00

37 lines
896 B
YAML

---
# Install Docker and docker-compose, start the daemon.
- name: Install Docker (Debian)
ansible.builtin.apt:
name:
- docker.io
- docker-compose-plugin
state: present
when: ansible_facts["os_family"] == "Debian"
- name: Remove conflicting docker-compose package (Debian)
ansible.builtin.apt:
name: docker-compose
state: absent
when: ansible_facts["os_family"] == "Debian"
- name: Install Docker (Alpine)
community.general.apk:
name:
- docker
- docker-cli-compose
state: present
when: ansible_facts["os_family"] == "Alpine"
- name: Enable and start Docker
ansible.builtin.service:
name: docker
state: started
enabled: true
- name: Create docker compose project directories
ansible.builtin.file:
path: "/opt/docker/{{ item }}"
state: directory
mode: '0755'
loop: "{{ docker_services | default([]) }}"