ansible-nas/roles/homepage/tasks/main.yml
David Stephens 34127280fe Add Homepage
2024-02-26 15:09:27 +00:00

53 lines
1.8 KiB
YAML

---
- name: Start Homepage
block:
- name: Create Homepage Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ homepage_data_directory }}"
- name: Template config files
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ homepage_data_directory }}/{{ item }}"
with_items:
- bookmarks.yaml
- docker.yaml
- settings.yaml
- services.yaml
- widgets.yaml
register: homepage_config
- name: Create Homepage Docker Container
community.docker.docker_container:
name: "{{ homepage_container_name }}"
image: "{{ homepage_image_name }}:{{ homepage_image_tag }}"
pull: true
volumes:
- "{{ homepage_data_directory }}:/app/config"
- "/var/run/docker.sock:/var/run/docker.sock"
env:
TZ: "{{ ansible_nas_timezone }}"
ports:
- "{{ homepage_port }}:3000"
restart_policy: unless-stopped
restart: "{{ homepage_config is changed }}"
memory: "{{ homepage_memory }}"
labels:
traefik.enable: "{{ homepage_available_externally | string }}"
traefik.http.routers.homepage.rule: "Host(`{{ homepage_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.homepage.tls.certresolver: "letsencrypt"
traefik.http.routers.homepage.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.homepage.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.homepage.loadbalancer.server.port: "3000"
when: homepage_enabled is true
- name: Stop Homepage
block:
- name: Stop Homepage
community.docker.docker_container:
name: "{{ homepage_container_name }}"
state: absent
when: homepage_enabled is false