Added syncthing,grafana and wireguard

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
pull/1/head
TuDatTr 2022-12-10 03:21:11 +01:00
parent cbb3bfd854
commit 2ba4259dd6
10 changed files with 106 additions and 14 deletions

View File

@ -118,8 +118,8 @@ Endpoint = tudattr.dev:51820
AllowedIPs = 0.0.0.0/0
```
used ipv4:
- genesis: 192.168.200.250
- xiaomi: 192.168.200.249
- tudattr: 192.168.200.250
- livei: 192.168.200.240
#### notes
- wireguard->add
@ -142,4 +142,4 @@ when problems with docker: `docker system prune -a`
## Todo
- Role to load customization/configurations from backup to servers
- split docker containers to different composes
- split docker containers to different composes or tag

View File

@ -9,3 +9,5 @@
- backup
- role: power_management
- role: docker
tags:
- reload_compose

View File

@ -5,6 +5,8 @@ user: tudattr
timezone: Europe/Berlin
local_domain: borg.land
rclone_config: "/root/.config/rclone/"
puid: 1000
pgid: 1000
#
@ -55,7 +57,13 @@ mysql_user: user
#
zoneminder_config: "{{ docker_dir }}/zm/"
zoneminder_data: "{{ docker_data_dir }}/zm/data"
zoneminder_data: "{{ docker_data_dir }}/zm/data/"
syncthing_data: "{{docker_data_dir}}/syncthing/"
grafana_data: "{{docker_data_dir}}/grafana/"
grafana_log: "{{docker_dir}}/grafana/logs/"
grafana_config: "{{docker_dir}}/grafana/config/"
#
# pi
@ -68,6 +76,8 @@ ha_config: "{{ docker_dir }}/home-assistant/config/"
pihole_pihole: "{{ docker_dir }}/pihole/etc-pihole/"
pihole_dnsmasq: "{{ docker_dir }}/pihole/etc-dnsmasq.d/"
#
# backblaze
#

View File

@ -1,9 +1,17 @@
---
- name: Shut down docker
shell:
cmd: "docker compose down --remove-orphans"
chdir: "{{ docker_compose_dir }}"
- name: Backing up for "{{ inventory_hostname }}"
shell:
cmd: "rclone sync {{ item.1 }} secret:{{ item.1 }}"
when: item.0.key == inventory_hostname
loop: "{{ backblaze_paths | dict2items | subelements('value') }}"
become: true
tags:
- backup
- name: Shut down docker
shell:
cmd: "docker compose down --remove-orphans"
chdir: "{{ docker_compose_dir }}"

View File

@ -3,3 +3,5 @@
- include_tasks: install.yml
- include_tasks: config.yml
- include_tasks: backup.yml
tags:
- backup

View File

@ -20,12 +20,34 @@
file:
path: "{{ item }}"
owner: 911
mode: '766'
mode: '755'
state: directory
loop:
- "{{ zoneminder_data }}"
become: true
- name: Create syncthing directory
file:
path: "{{ item }}"
owner: 1000
mode: '755'
state: directory
loop:
- "{{ syncthing_data }}"
become: true
- name: Create grafana data directory
file:
path: "{{ item }}"
owner: 1000
mode: '755'
state: directory
loop:
- "{{ grafana_data }}"
- "{{ grafana_log }}"
- "{{ grafana_config}}"
become: true
# Todo, check if docker compose is running
# - name: Shut down docker
# shell:
@ -36,8 +58,12 @@
template:
src: templates/aya01/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

@ -3,5 +3,9 @@
- 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

View File

@ -55,8 +55,12 @@
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

@ -76,7 +76,39 @@ services:
- "traefik.http.routers.pihole.rule=Host(`pihole.{{local_domain}}`)"
- "traefik.http.routers.pihole.entrypoints=web"
- "traefik.http.services.pihole.loadbalancer.server.port=8089"
syncthing:
image: syncthing/syncthing
container_name: syncthing
hostname: syncthing
networks:
- net
environment:
- PUID=1000
- PGID=1000
volumes:
- "{{syncthing_data}}:/var/syncthing"
ports:
- 8384:8384 # Web UI
- 22000:22000/tcp # TCP file transfers
- 22000:22000/udp # QUIC file transfers
- 21027:21027/udp # Receive local discovery broadcasts
restart: unless-stopped
grafana:
image: grafana/grafana-oss
container_name: grafana
hostname: grafana
networks:
- net
environment:
- "PUID={{ puid }}"
- "PGID={{ pgid }}"
- "GF_LOG_MODE=console file"
volumes:
- "{{ grafana_data }}:/var/lib/grafana/"
- "{{ grafana_log }}:/var/log/grafana/"
- "{{ grafana_config }}:/etc/grafana/"
ports:
- 3000:3000
networks:

View File

@ -18,8 +18,8 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik.{{local_domain}}`)"
- "traefik.http.routers.traefik.entrypoints=web"
- "traefik.http.services.traefik.loadbalancer.server.port=80"
# - "traefik.http.routers.traefik.entrypoints=web"
# - "traefik.http.services.traefik.loadbalancer.server.port=80"
ddns-updater:
container_name: ddns-updater
image: "ghcr.io/qdm12/ddns-updater"
@ -34,17 +34,21 @@ services:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
restart: unless-stopped
# network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ ha_config }}:/config/"
privileged: true
ports:
- 8123:8123
- 4357:4357
- 5683:5683
- 5683:5683/udp
labels:
- "traefik.enable=true"
- "traefik.http.routers.homeassistant.rule=Host(`hass.{{local_domain}}`)"
- "traefik.http.routers.homeassistant.entrypoints=web"
- "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
# - "traefik.http.routers.homeassistant.entrypoints=web"
# - "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
pihole:
container_name: pihole
image: pihole/pihole:latest
@ -74,8 +78,8 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.routers.pihole.rule=Host(`pihole.{{local_domain}}`)"
- "traefik.http.routers.pihole.entrypoints=web"
- "traefik.http.services.pihole.loadbalancer.server.port=8089"
# - "traefik.http.routers.pihole.entrypoints=web"
# - "traefik.http.services.pihole.loadbalancer.server.port=8089"
networks:
net: