mirror of
https://github.com/davestephens/ansible-nas
synced 2025-01-13 03:58:47 +00:00
41 lines
1.4 KiB
YAML
41 lines
1.4 KiB
YAML
---
|
|
- name: Start Traefik
|
|
block:
|
|
- name: Create Traefik Directories
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "{{ traefik_data_directory }}"
|
|
- "{{ traefik_data_directory }}/letsencrypt"
|
|
|
|
- name: Template Traefik config.toml
|
|
ansible.builtin.template:
|
|
src: traefik.toml
|
|
dest: "{{ traefik_data_directory }}/traefik.toml"
|
|
register: template_config
|
|
|
|
- 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
|