diff --git a/README.md b/README.md index cb3f8d6..35af27c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/aya01.yml b/aya01.yml index fd60ad7..00cd14a 100644 --- a/aya01.yml +++ b/aya01.yml @@ -9,3 +9,5 @@ - backup - role: power_management - role: docker + tags: + - reload_compose diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml index 6722cac..13a496e 100644 --- a/group_vars/all/vars.yml +++ b/group_vars/all/vars.yml @@ -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 # diff --git a/roles/backblaze/tasks/backup.yml b/roles/backblaze/tasks/backup.yml index dad6fb7..7cf24f7 100644 --- a/roles/backblaze/tasks/backup.yml +++ b/roles/backblaze/tasks/backup.yml @@ -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 }}" diff --git a/roles/backblaze/tasks/main.yml b/roles/backblaze/tasks/main.yml index 9e7df93..e6a018b 100644 --- a/roles/backblaze/tasks/main.yml +++ b/roles/backblaze/tasks/main.yml @@ -3,3 +3,5 @@ - include_tasks: install.yml - include_tasks: config.yml - include_tasks: backup.yml + tags: + - backup diff --git a/roles/docker/tasks/aya01_compose.yml b/roles/docker/tasks/aya01_compose.yml index 8c8b674..ef5a223 100644 --- a/roles/docker/tasks/aya01_compose.yml +++ b/roles/docker/tasks/aya01_compose.yml @@ -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 diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index c0c2a60..794729c 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -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 diff --git a/roles/docker/tasks/pi_compose.yml b/roles/docker/tasks/pi_compose.yml index 10cc666..8a6cca5 100644 --- a/roles/docker/tasks/pi_compose.yml +++ b/roles/docker/tasks/pi_compose.yml @@ -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 diff --git a/roles/docker/templates/aya01/compose.yaml b/roles/docker/templates/aya01/compose.yaml index c333fba..96bbea3 100644 --- a/roles/docker/templates/aya01/compose.yaml +++ b/roles/docker/templates/aya01/compose.yaml @@ -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: diff --git a/roles/docker/templates/pi/compose.yaml b/roles/docker/templates/pi/compose.yaml index 6e8bc7a..8841073 100644 --- a/roles/docker/templates/pi/compose.yaml +++ b/roles/docker/templates/pi/compose.yaml @@ -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: