feat(docker): Split docker compose to be deployed different services on different hosts. See host_vars of each host.

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2024-12-11 19:58:57 +01:00
parent 711dc58f2e
commit 6d099061ac
6 changed files with 76 additions and 10 deletions

View File

@@ -8,3 +8,19 @@ ansible_become_pass: "{{ vault.docker.host00.sudo }}"
host:
hostname: "docker-host00"
ip: "{{ ansible_host }}"
enable_nginx: true
enable_syncthing: true
enable_kuma: true
enable_plex: true
enable_arr: true
enable_prometheus: false
enable_grafana: false
enable_ddns_updater: true
enable_homeassistant: false
enable_stirling: true
enable_jellyfin: false
enable_paperless: true
enable_gitea: false
enable_changedetection: true
enable_calibre: false

View File

@@ -0,0 +1,26 @@
---
ansible_user: "{{ user }}"
ansible_host: 192.168.20.36
ansible_port: 22
ansible_ssh_private_key_file: "{{ pk_path }}"
ansible_become_pass: "{{ vault.docker.host02.sudo }}"
host:
hostname: "docker-host02"
ip: "{{ ansible_host }}"
enable_nginx: true
enable_syncthing: false
enable_kuma: false
enable_plex: false
enable_arr: false
enable_prometheus: false
enable_grafana: false
enable_ddns_updater: false
enable_homeassistant: true
enable_stirling: false
enable_jellyfin: true
enable_paperless: false
enable_gitea: true
enable_changedetection: false
enable_calibre: false

View File

@@ -42,6 +42,7 @@ k3s-longhorn00
k3s-longhorn01
k3s-longhorn02
docker-host00
docker-host02
[k3s_nodes]
k3s-server00
@@ -65,9 +66,11 @@ ansible_ssh_common_args='-o ProxyCommand="ssh -p 22 -W %h:%p -q aya01"'
[docker]
docker-host00
docker-host02
[docker_host]
docker-host00
docker-host02
[proxmox]
aya01

View File

@@ -1,7 +1,7 @@
---
- name: Copy docker compose file to target
ansible.builtin.template:
src: "files/{{ item }}"
src: "templates/{{ item }}.j2"
dest: "/opt/docker/compose/{{ item }}"
owner: "{{ user }}"
group: "{{ user }}"

View File

@@ -97,12 +97,3 @@
opts: defaults,nolock
state: mounted
become: true
- name: Ensure /opt/docker is mounted via NFS
ansible.posix.mount:
path: /opt/docker
src: 192.168.20.12:/opt/docker
fstype: nfs
opts: defaults,nolock
state: mounted
become: true

View File

@@ -1,4 +1,5 @@
services:
{% if enable_nginx %}
nginx:
container_name: "nginx"
image: "jc21/nginx-proxy-manager:latest"
@@ -13,7 +14,9 @@ services:
- "/opt/docker/config/nginx/data:/data"
- "/opt/docker/config/nginx/letsencrypt:/etc/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock"
{% endif %}
{% if enable_syncthing %}
syncthing:
image: syncthing/syncthing
container_name: syncthing
@@ -33,7 +36,9 @@ services:
- PGID=1000
- TZ=Europe/Berlin
hostname: syncthing
{% endif %}
{% if enable_kuma %}
kuma:
container_name: kuma
image: louislam/uptime-kuma:1
@@ -50,7 +55,9 @@ services:
- "3001:3001"
volumes:
- "/opt/local/kuma/:/app/data"
{% endif %}
{% if enable_plex %}
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
@@ -80,7 +87,9 @@ services:
- "/media/series:/tv:ro"
- "/media/movies:/movies:ro"
- "/media/songs:/music:ro"
{% endif %}
{% if enable_arr %}
sonarr:
image: lscr.io/linuxserver/sonarr:latest
container_name: sonarr
@@ -206,7 +215,9 @@ services:
volumes:
- /opt/docker/config/qbit/config:/config
- /media/docker/data/arr_downloads:/downloads
{% endif %}
{% if enable_prometheus %}
prometheus:
image: prom/prometheus
container_name: prometheus
@@ -222,7 +233,9 @@ services:
volumes:
- /opt/docker/config/prometheus/:/etc/prometheus/
- prometheus_data:/prometheus/
{% endif %}
{% if enable_grafana %}
grafana:
image: grafana/grafana-oss
container_name: grafana
@@ -239,7 +252,9 @@ services:
volumes:
- /media/docker/data/grafana/:/var/lib/grafana/
- /opt/docker/config/grafana/config/:/etc/grafana/
{% endif %}
{% if enable_ddns_updater %}
ddns-updater:
container_name: ddns-updater
image: "ghcr.io/qdm12/ddns-updater"
@@ -250,7 +265,9 @@ services:
net: {}
volumes:
- "/opt/docker/config/ddns-updater/data/:/updater/data/"
{% endif %}
{% if enable_homeassistant %}
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
@@ -268,7 +285,9 @@ services:
- 4357:4357
- 5683:5683
- 5683:5683/udp
{% endif %}
{% if enable_stirling %}
stirling:
container_name: stirling
image: frooodle/s-pdf:latest
@@ -277,7 +296,9 @@ services:
- nginx
networks:
net: {}
{% endif %}
{% if enable_jellyfin %}
jellyfin:
container_name: jellyfin
image: jellyfin/jellyfin
@@ -296,7 +317,9 @@ services:
- /media/songs:/music:ro
ports:
- "8096:8096"
{% endif %}
{% if enable_paperless %}
paperless-broker:
container_name: paperless-broker
image: docker.io/library/redis:7
@@ -353,7 +376,9 @@ services:
- "PAPERLESS_URL=https://paperless.docker-host00.lulu.seyshiro.de"
- "PAPERLESS_TIME_ZONE=Europe/Berlin"
- "PAPERLESS_OCR_LANGUAGE=deu"
{% endif %}
{% if enable_gitea %}
git:
container_name: git
image: gitea/gitea:1.20.5-rootless
@@ -373,7 +398,9 @@ services:
environment:
- USER_UID=1000
- USER_GID=1000
{% endif %}
{% if enable_changedetection %}
changedetection:
container_name: changedetection
image: dgtlmoon/changedetection.io
@@ -384,7 +411,9 @@ services:
- net
volumes:
- "/opt/docker/config/changedetection/data/:/datastore"
{% endif %}
{% if enable_calibre %}
calibre:
container_name: calibre
image: lscr.io/linuxserver/calibre-web:latest
@@ -401,6 +430,7 @@ services:
volumes:
- "/opt/local/calibre/:/config"
- "/media/docker/data/calibre/:/books"
{% endif %}
networks:
net: