ansible/roles/traefik_docker/tasks/main.yml

56 lines
1.2 KiB
YAML

---
- name: "Install dependencies"
ansible.builtin.apt:
pkg:
- docker-ce
- apparmor
- name: "Create directory for Traefik"
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: '0755'
with_items:
- "{{ docker_volumes_dir }}/traefik"
- name: "Template Config for Traefik"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "{{ docker_volumes_dir }}/traefik/{{ item }}"
force: true
owner: 0
group: 0
mode: '0640'
with_items:
- traefik.yml
- traefik_dynamic.yml
notify: restart-traefik-docker
- name: "Template systemd unit files for Traefik"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
force: true
owner: root
group: root
mode: '0644'
with_items:
- traefik.service
register: unit
notify: restart-traefik-docker
- name: "Reload systemd units"
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
- name: "Enable systemd units for Traefik"
ansible.builtin.systemd:
state: started
enabled: true
name: "{{ item }}"
with_items:
- traefik.service