Moved docker tasks and made more dynamic

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
pull/1/head
TuDatTr 2023-04-27 10:52:49 +02:00
parent 25c2aff50c
commit c193374444
8 changed files with 152 additions and 130 deletions

View File

@ -66,13 +66,3 @@
dest: "{{ docker_compose_dir }}/compose.yaml"
register: compose
- name: Shut down docker
shell:
cmd: "docker compose down --remove-orphans"
chdir: "{{ docker_compose_dir }}"
when: compose.changed
- name: Run docker compose
shell:
cmd: "docker compose up -d"
chdir: "{{ docker_compose_dir }}"

View File

@ -1,15 +1,34 @@
---
- include_tasks: install.yml
- include_tasks: user_group_setup.yml
- include_tasks: pi_compose.yml
when: inventory_hostname == "pi"
tags:
- reload_compose
- include_tasks: aya01_compose.yml
when: inventory_hostname == "aya01"
tags:
- reload_compose
- include_tasks: mii_compose.yml
when: inventory_hostname == "mii"
# - include_tasks: pi_compose.yml
# when: inventory_hostname == "pi"
# tags:
# - reload_compose
# - include_tasks: aya01_compose.yml
# when: inventory_hostname == "aya01"
# tags:
# - reload_compose
#- include_tasks: mii_compose.yml
# when: inventory_hostname == "mii"
# tags:
# - reload_compose
- include_tasks: "{{ inventory_hostname }}_compose.yml"
tags:
- reload_compose
- name: Shut down docker
shell:
cmd: "docker compose down --remove-orphans"
chdir: "{{ docker_compose_dir }}"
- name: Update Docker Images
shell:
cmd: "docker compose pull"
chdir: "{{ docker_compose_dir }}"
- name: Restart Docker
shell:
cmd: "docker compose up -d"
chdir: "{{ docker_compose_dir }}"

View File

@ -10,9 +10,3 @@
tags:
- reload_compose
- name: Run docker compose
shell:
cmd: "docker compose up -d"
chdir: "{{ docker_compose_dir }}"
tags:
- reload_compose

View File

@ -16,22 +16,9 @@
tags:
- pihole
# Todo, check if docker compose is running
# - name: Shut down docker
# shell:
# cmd: "docker compose down --remove-orphans"
# chdir: "{{ docker_compose_dir }}"
- name: Copy the compose file
template:
src: templates/pi/compose.yaml
dest: "{{ docker_compose_dir }}/compose.yaml"
tags:
- reload_compose
- name: Run docker compose
shell:
cmd: "docker compose up -d"
chdir: "{{ docker_compose_dir }}"
tags:
- reload_compose

View File

@ -15,61 +15,12 @@ services:
- "{{ traefik_user_port}}:80"
- "{{ traefik_admin_port}}:8080"
db:
image: mariadb
container_name: zoneminder_db
restart: unless-stopped
networks:
- zoneminder
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ zoneminder_db }}:/var/lib/mysql"
environment:
- "MYSQL_DATABASE={{ zoneminder_host }}"
- "MYSQL_ROOT_PASSWORD={{ vault_mysql_root_password }}"
- "MYSQL_USER={{ mysql_user }}"
- "MYSQL_PASSWORD={{ vault_mysql_user_password }}"
- "MAX_LOG_SIZE_BYTES=1000000"
- "MAX_LOG_NUMBER=20"
- "TZ=Europe/Berlin"
zoneminder:
image: ghcr.io/zoneminder-containers/zoneminder-base:latest
container_name: zoneminder
restart: unless-stopped
stop_grace_period: 45s
depends_on:
- db
networks:
- zoneminder
- net
ports:
- "{{ zoneminder_port }}:80"
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ zoneminder_data }}:/data"
- "{{ zoneminder_config }}:/config"
- "{{ zoneminder_log}}:/log"
- type: tmpfs
target: /dev/shm
tmpfs:
size: 1000000000
environment:
- "MYSQL_DATABASE={{ zoneminder_host }}"
- "MYSQL_ROOT_PASSWORD={{ vault_mysql_root_password }}"
- "MYSQL_USER={{ mysql_user }}"
- "MYSQL_PASSWORD={{ vault_mysql_user_password }}"
- "MAX_LOG_SIZE_BYTES=1000000"
- "MAX_LOG_NUMBER=20"
- "TZ=Europe/Berlin"
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ zoneminder_host }}.rule=Host(`{{ zoneminder_host}}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ zoneminder_host }}.loadbalancer.server.port=80"
pihole:
image: pihole/pihole:latest
container_name: pihole
restart: unless-stopped
depends_on:
- traefik
networks:
- net
ports:
@ -100,10 +51,65 @@ services:
- "traefik.http.routers.{{ pihole_host }}.rule=Host(`{{ pihole_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ pihole_host }}.loadbalancer.server.port=80"
db:
image: mariadb
container_name: zoneminder_db
restart: unless-stopped
networks:
- zoneminder
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ zoneminder_db }}:/var/lib/mysql"
environment:
- "MYSQL_DATABASE={{ zoneminder_host }}"
- "MYSQL_ROOT_PASSWORD={{ vault_mysql_root_password }}"
- "MYSQL_USER={{ mysql_user }}"
- "MYSQL_PASSWORD={{ vault_mysql_user_password }}"
- "MAX_LOG_SIZE_BYTES=1000000"
- "MAX_LOG_NUMBER=20"
- "TZ=Europe/Berlin"
zoneminder:
image: ghcr.io/zoneminder-containers/zoneminder-base:latest
container_name: zoneminder
restart: unless-stopped
stop_grace_period: 45s
depends_on:
- db
- traefik
networks:
- zoneminder
- net
ports:
- "{{ zoneminder_port }}:80"
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ zoneminder_data }}:/data"
- "{{ zoneminder_config }}:/config"
- "{{ zoneminder_log}}:/log"
- type: tmpfs
target: /dev/shm
tmpfs:
size: 1000000000
environment:
- "MYSQL_DATABASE={{ zoneminder_host }}"
- "MYSQL_ROOT_PASSWORD={{ vault_mysql_root_password }}"
- "MYSQL_USER={{ mysql_user }}"
- "MYSQL_PASSWORD={{ vault_mysql_user_password }}"
- "MAX_LOG_SIZE_BYTES=1000000"
- "MAX_LOG_NUMBER=20"
- "TZ=Europe/Berlin"
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ zoneminder_host }}.rule=Host(`{{ zoneminder_host}}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ zoneminder_host }}.loadbalancer.server.port=80"
syncthing:
image: syncthing/syncthing
container_name: syncthing
restart: unless-stopped
depends_on:
- pihole
networks:
- net
ports:
@ -127,6 +133,8 @@ services:
container_name: soft-serve
image: charmcli/soft-serve:latest
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -142,6 +150,8 @@ services:
container_name: cupsd
image: olbat/cupsd
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -162,6 +172,8 @@ services:
container_name: kuma
image: louislam/uptime-kuma:1
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -181,6 +193,8 @@ services:
image: lscr.io/linuxserver/plex:latest
container_name: plex
restart: unless-stopped
depends_on:
- pihole
networks:
- net
ports:
@ -211,6 +225,8 @@ services:
image: lscr.io/linuxserver/sonarr:latest
container_name: sonarr
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -232,6 +248,8 @@ services:
image: lscr.io/linuxserver/radarr:latest
container_name: radarr
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -253,6 +271,8 @@ services:
image: lscr.io/linuxserver/lidarr:latest
container_name: lidarr
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -274,6 +294,8 @@ services:
image: lscr.io/linuxserver/prowlarr:latest
container_name: prowlarr
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
@ -293,6 +315,8 @@ services:
image: wantguns/bin
container_name: pastebin
restart: unless-stopped
depends_on:
- pihole
networks:
- net
ports:
@ -315,6 +339,8 @@ services:
container_name: {{ qbit_host }}
restart: unless-stopped
privileged: true
depends_on:
- pihole
networks:
- net
ports:
@ -341,6 +367,8 @@ services:
image: lscr.io/linuxserver/tautulli:latest
container_name: tautulli
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:

View File

@ -3,6 +3,7 @@ services:
swag:
image: lscr.io/linuxserver/swag:latest
container_name: swag
restart: unless-stopped
networks:
net: {}
dns:
@ -30,7 +31,6 @@ services:
ports:
- "{{ swag_port }}:443"
- 80:80 #optional
restart: unless-stopped
networks:
net:

View File

@ -12,7 +12,8 @@ server {
location / {
include /config/nginx/resolver.conf;
proxy_pass http://{{ aya01_ip | replace('.', '-') }}.{{ vault_plex_server_id }}.plex.direct:{{ plex_port }}/;
proxy_pass http://{{ plex_host }}.{{ aya01_host }}.{{ local_domain }};
proxy_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier;
proxy_set_header X-Plex-Device $http_x_plex_device;

View File

@ -3,7 +3,7 @@ services:
traefik:
container_name: traefik
image: traefik:latest
restart: always
restart: unless-stopped
networks:
net: {}
volumes:
@ -14,46 +14,10 @@ services:
ports:
- "{{ traefik_user_port }}:80"
- "{{ traefik_admin_port }}:8080"
ddns-updater:
container_name: ddns-updater
image: "ghcr.io/qdm12/ddns-updater"
restart: always
networks:
net: {}
volumes:
- "{{ ddns_data }}:/updater/data/"
ports:
- "{{ ddns_port }}:8000/tcp"
labels:
- "traefik.enable=true"
- "traefik.http.routers.ddns-updater.rule=Host(`{{ ddns_host }}.{{ pi_host }}.{{local_domain}}`)"
- "traefik.http.services.ddns-updater.loadbalancer.server.port={{ ddns_port }}"
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
restart: always
networks:
net: {}
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ ha_config }}:/config/"
privileged: true
ports:
- "{{ ha_port }}:8123"
- 4357:4357
- 5683:5683
- 5683:5683/udp
labels:
- "traefik.enable=true"
- "traefik.http.routers.homeassistant.rule=Host(`{{ ha_host }}.{{ pi_host }}.{{ local_domain }}`)"
- "traefik.http.services.homeassistant.loadbalancer.server.port={{ ha_port }}"
pihole:
container_name: pihole
image: pihole/pihole:latest
restart: always
restart: unless-stopped
networks:
net: {}
ports:
@ -81,6 +45,45 @@ services:
- "traefik.http.routers.pihole.rule=Host(`{{ pihole_host }}.{{ pi_host }}.{{ local_domain }}`)"
- "traefik.http.services.pihole.loadbalancer.server.port={{ 80 }}"
ddns-updater:
container_name: ddns-updater
image: "ghcr.io/qdm12/ddns-updater"
restart: unless-stopped
depends_on:
- pihole
networks:
net: {}
volumes:
- "{{ ddns_data }}:/updater/data/"
ports:
- "{{ ddns_port }}:8000/tcp"
labels:
- "traefik.enable=true"
- "traefik.http.routers.ddns-updater.rule=Host(`{{ ddns_host }}.{{ pi_host }}.{{local_domain}}`)"
- "traefik.http.services.ddns-updater.loadbalancer.server.port={{ ddns_port }}"
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
restart: unless-stopped
depends_on:
- pihole
networks:
net: {}
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ ha_config }}:/config/"
privileged: true
ports:
- "{{ ha_port }}:8123"
- 4357:4357
- 5683:5683
- 5683:5683/udp
labels:
- "traefik.enable=true"
- "traefik.http.routers.homeassistant.rule=Host(`{{ ha_host }}.{{ pi_host }}.{{ local_domain }}`)"
- "traefik.http.services.homeassistant.loadbalancer.server.port={{ ha_port }}"
networks:
net:
driver: bridge