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

38 lines
1.4 KiB
YAML
Raw Normal View History

2022-09-09 21:24:34 +00:00
---
- name: Start Hello World
block:
- name: Create Hello World Directories
2023-04-15 13:11:49 +00:00
ansible.builtin.file:
2022-09-09 21:24:34 +00:00
path: "{{ item }}"
state: directory
with_items:
- "{{ hello_world_data_directory }}"
- name: Hello World Docker Container
2023-04-15 13:11:49 +00:00
community.docker.docker_container:
2022-09-09 21:24:34 +00:00
name: "{{ hello_world_container_name }}"
image: crccheck/hello-world
pull: true
volumes:
- "{{ hello_world_data_directory }}:/hello_world:rw"
ports:
- "{{ hello_world_port }}:8000"
restart_policy: unless-stopped
memory: "{{ hello_world_memory }}"
labels:
traefik.enable: "{{ hello_world_available_externally | string }}"
traefik.http.routers.hello_world.rule: "Host(`{{ hello_world_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.hello_world.tls.certresolver: "letsencrypt"
traefik.http.routers.hello_world.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.hello_world.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.hello_world.loadbalancer.server.port: "4040"
when: hello_world_enabled is true
- name: Stop Hello World
block:
- name: Stop Hello World
2023-04-15 13:11:49 +00:00
community.docker.docker_container:
2022-09-09 21:24:34 +00:00
name: "{{ hello_world_container_name }}"
state: absent
when: hello_world_enabled is false