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" dest: "{{ docker_compose_dir }}/compose.yaml"
register: compose 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: install.yml
- include_tasks: user_group_setup.yml - include_tasks: user_group_setup.yml
- include_tasks: pi_compose.yml # - include_tasks: pi_compose.yml
when: inventory_hostname == "pi" # when: inventory_hostname == "pi"
tags: # tags:
- reload_compose # - reload_compose
- include_tasks: aya01_compose.yml # - include_tasks: aya01_compose.yml
when: inventory_hostname == "aya01" # when: inventory_hostname == "aya01"
tags: # tags:
- reload_compose # - reload_compose
- include_tasks: mii_compose.yml #- include_tasks: mii_compose.yml
when: inventory_hostname == "mii" # when: inventory_hostname == "mii"
# tags:
# - reload_compose
- include_tasks: "{{ inventory_hostname }}_compose.yml"
tags: tags:
- reload_compose - 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: tags:
- reload_compose - 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: tags:
- pihole - 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 - name: Copy the compose file
template: template:
src: templates/pi/compose.yaml src: templates/pi/compose.yaml
dest: "{{ docker_compose_dir }}/compose.yaml" dest: "{{ docker_compose_dir }}/compose.yaml"
tags: tags:
- reload_compose - 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_user_port}}:80"
- "{{ traefik_admin_port}}:8080" - "{{ 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: pihole:
image: pihole/pihole:latest image: pihole/pihole:latest
container_name: pihole container_name: pihole
restart: unless-stopped restart: unless-stopped
depends_on:
- traefik
networks: networks:
- net - net
ports: ports:
@ -100,10 +51,65 @@ services:
- "traefik.http.routers.{{ pihole_host }}.rule=Host(`{{ pihole_host }}.{{ aya01_host }}.{{ local_domain }}`)" - "traefik.http.routers.{{ pihole_host }}.rule=Host(`{{ pihole_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ pihole_host }}.loadbalancer.server.port=80" - "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: syncthing:
image: syncthing/syncthing image: syncthing/syncthing
container_name: syncthing container_name: syncthing
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
ports: ports:
@ -127,6 +133,8 @@ services:
container_name: soft-serve container_name: soft-serve
image: charmcli/soft-serve:latest image: charmcli/soft-serve:latest
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -142,6 +150,8 @@ services:
container_name: cupsd container_name: cupsd
image: olbat/cupsd image: olbat/cupsd
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -162,6 +172,8 @@ services:
container_name: kuma container_name: kuma
image: louislam/uptime-kuma:1 image: louislam/uptime-kuma:1
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -181,6 +193,8 @@ services:
image: lscr.io/linuxserver/plex:latest image: lscr.io/linuxserver/plex:latest
container_name: plex container_name: plex
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
ports: ports:
@ -211,6 +225,8 @@ services:
image: lscr.io/linuxserver/sonarr:latest image: lscr.io/linuxserver/sonarr:latest
container_name: sonarr container_name: sonarr
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -232,6 +248,8 @@ services:
image: lscr.io/linuxserver/radarr:latest image: lscr.io/linuxserver/radarr:latest
container_name: radarr container_name: radarr
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -253,6 +271,8 @@ services:
image: lscr.io/linuxserver/lidarr:latest image: lscr.io/linuxserver/lidarr:latest
container_name: lidarr container_name: lidarr
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -274,6 +294,8 @@ services:
image: lscr.io/linuxserver/prowlarr:latest image: lscr.io/linuxserver/prowlarr:latest
container_name: prowlarr container_name: prowlarr
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:
@ -293,6 +315,8 @@ services:
image: wantguns/bin image: wantguns/bin
container_name: pastebin container_name: pastebin
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
ports: ports:
@ -315,6 +339,8 @@ services:
container_name: {{ qbit_host }} container_name: {{ qbit_host }}
restart: unless-stopped restart: unless-stopped
privileged: true privileged: true
depends_on:
- pihole
networks: networks:
- net - net
ports: ports:
@ -341,6 +367,8 @@ services:
image: lscr.io/linuxserver/tautulli:latest image: lscr.io/linuxserver/tautulli:latest
container_name: tautulli container_name: tautulli
restart: unless-stopped restart: unless-stopped
depends_on:
- pihole
networks: networks:
- net - net
environment: environment:

View File

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

View File

@ -12,7 +12,8 @@ server {
location / { location / {
include /config/nginx/resolver.conf; 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-Client-Identifier $http_x_plex_client_identifier;
proxy_set_header X-Plex-Device $http_x_plex_device; proxy_set_header X-Plex-Device $http_x_plex_device;

View File

@ -3,7 +3,7 @@ services:
traefik: traefik:
container_name: traefik container_name: traefik
image: traefik:latest image: traefik:latest
restart: always restart: unless-stopped
networks: networks:
net: {} net: {}
volumes: volumes:
@ -14,46 +14,10 @@ services:
ports: ports:
- "{{ traefik_user_port }}:80" - "{{ traefik_user_port }}:80"
- "{{ traefik_admin_port }}:8080" - "{{ 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: pihole:
container_name: pihole container_name: pihole
image: pihole/pihole:latest image: pihole/pihole:latest
restart: always restart: unless-stopped
networks: networks:
net: {} net: {}
ports: ports:
@ -81,6 +45,45 @@ services:
- "traefik.http.routers.pihole.rule=Host(`{{ pihole_host }}.{{ pi_host }}.{{ local_domain }}`)" - "traefik.http.routers.pihole.rule=Host(`{{ pihole_host }}.{{ pi_host }}.{{ local_domain }}`)"
- "traefik.http.services.pihole.loadbalancer.server.port={{ 80 }}" - "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: networks:
net: net:
driver: bridge driver: bridge