chef-recipes/containers/heimdall/tasks.yml

111 lines
3.3 KiB
YAML

# code: language=ansible
---
- hosts: all
name: Heimdall landing page
tasks:
- name: Stop running containers
become_user: containers
become: true
ansible.builtin.systemd:
scope: user
name: container-{{ item }}.service
state: stopped
loop:
- heimdall
failed_when: false
- name: Create podman volumes
containers.podman.podman_volume:
state: present
name: "{{ item }}"
become_user: containers
become: true
loop:
- heimdall-config
- name: Create podman networks
containers.podman.podman_network:
name: "{{ item }}"
recreate: false
state: "present"
become_user: containers
become: true
loop:
- traefik-heimdall
- name: Pull an image
become_user: containers
become: true
containers.podman.podman_image:
name: lscr.io/linuxserver/heimdall:latest
- name: Add a heimdall container
become_user: containers
become: true
containers.podman.podman_container:
name: heimdall
image: lscr.io/linuxserver/heimdall:latest
state: present
network:
- traefik-heimdall
volume:
- heimdall-config:/config:Z
label:
io.containers.autoupdate: "registry"
traefik.enable: "true"
traefik.http.routers.heimdall.entrypoints: "https"
traefik.http.routers.heimdall.rule: "Host(`{{ vault_domain }}`)"
traefik.http.routers.heimdall.tls: "true"
traefik.http.routers.heimdall.tls.certresolver: "wildcard"
traefik.http.routers.heimdall.service: "heimdall"
traefik.http.services.heimdall.loadbalancer.server.port: "80"
traefik.http.routers.heimdall-settings.entrypoints: "https"
traefik.http.routers.heimdall-settings.rule: "Host(`{{ vault_domain }}`) && Path(`/settings`)"
traefik.http.routers.heimdall-settings.tls: "true"
traefik.http.routers.heimdall-settings.tls.certresolver: "wildcard"
traefik.http.routers.heimdall-settings.service: "heimdall"
traefik.http.routers.heimdall-settings.middlewares: "heimdall-auth@docker"
traefik.http.services.heimdall-settings.loadbalancer.server.port: "80"
traefik.http.middlewares.heimdall-auth.basicauth.users: "{{ vault_heimdall_basic_auth }}"
traefik.docker.network: "traefik-heimdall"
env:
TZ: "Europe/Rome"
generate_systemd:
path: /home/containers/.config/systemd/user/
restart_policy: on-failure
requires: [container-traefik.service]
names: true
new: true
- name: Change start and stop timeout limits
become_user: containers
become: true
community.general.ini_file:
path: /home/containers/.config/systemd/user/container-heimdall.service
section: Service
option: "{{ item }}"
value: 3600
mode: "0664"
state: "present"
no_extra_spaces: true
loop:
- TimeoutStartSec
- TimeoutStopSec
- name: Start containers at boot
become_user: containers
become: true
ansible.builtin.systemd:
scope: user
name: container-{{ item }}.service
enabled: true
state: started
daemon_reload: true
loop:
- heimdall