ansible-nas/roles/traefik/tasks/main.yml

42 lines
1.4 KiB
YAML
Raw Normal View History

2018-11-25 11:10:14 +00:00
---
2023-03-10 21:00:37 +00:00
- name: Start Traefik
block:
- name: Create Traefik Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ traefik_data_directory }}"
- "{{ traefik_data_directory }}/letsencrypt"
2018-11-25 11:10:14 +00:00
2023-03-10 21:00:37 +00:00
- name: Template Traefik config.toml
ansible.builtin.template:
src: traefik.toml
dest: "{{ traefik_data_directory }}/traefik.toml"
register: template_config
2018-11-25 11:10:14 +00:00
2023-03-10 21:00:37 +00:00
- name: Traefik Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ traefik_container_name }}"
image: "{{ traefik_image_name }}:{{ traefik_image_version }}"
pull: true
network_mode: host
volumes:
- "{{ traefik_data_directory }}/traefik.toml:/etc/traefik/traefik.toml:ro"
- "{{ traefik_data_directory }}/letsencrypt:/letsencrypt:rw"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
env: "{{ traefik_environment_variables }}"
restart_policy: unless-stopped
memory: "{{ traefik_memory }}"
recreate: "{{ template_config is changed }}"
when: traefik_enabled is true
- name: Stop Traefik
block:
- name: Stop Traefik
community.docker.docker_container:
name: "{{ traefik_container_name }}"
state: absent
when: traefik_enabled is false