From f656f415bd50c496e611ecb7ebc63e2e5d699e64 Mon Sep 17 00:00:00 2001 From: Kyattsukuro Date: Sun, 18 Oct 2026 19:14:53 +0200 Subject: [PATCH] untested: localsevices --- README.md | 1 + defaults/main.yml | 23 +++++++++ handlers/main.yml | 9 ++++ meta/main.yml | 20 +++++++ tasks/main.yml | 32 ++++++++++++ compose.yml => templates/compose.yml.j2 | 69 +++++++++---------------- 6 files changed, 108 insertions(+), 46 deletions(-) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml rename compose.yml => templates/compose.yml.j2 (67%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c9011f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# localservices diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..2d17960 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,23 @@ +path: /srv/{{ role_name }} + +localservices_override: {} +localservices_defaults: + networkmount: + path: "" + host: "" + host_path: "" + args: "" + + wg_client: + enabled: false + wg_conf: "" + aniworld: + url: "" + data_path: "" + bittorrent: + url: "" + data_path: "" + i2psnark: + url: "" + i2pc_host: "" + data_path: "" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..4c8c43c --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,9 @@ +- name: restart container +community.docker.docker_compose_v2: + project_src: "{{ path }}" + project_name: "{{ role_name }}" + recreate: "always" + services: ["localservices"] + state: "restarted" +when: not _localservices_already_restarted + diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..ebcc494 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,20 @@ +--- +galaxy_info: + author: "Niklas Freese " + description: localservices + company: "Urmel Services" + license: AGPL-3.0-or-later + min_ansible_version: 2.1 + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: + - role: traefik diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..603a678 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,32 @@ +--- +- name: "set local variables from overrides and defaults" + set_fact: + localservices: "{{ (localservices_defaults | combine(localservices_override, recursive=True)) if localservices_override else localservices_defaults }}" + +- name: ensure that path exists + file: + path: "{{ path }}/config/localservices" + state: directory + +- import_role: + name: storage_mount + vars: + storage_mount_override: + host: "{{ localservices.networkmount.host }}" + host_path: "{{ localservices.networkmount.host_path }}" + args: "{{ localservices.networkmount.args }}" + type: "{{ localservices.networkmount.type }}" + dest_path: "{{ localservices.localservices.path }}" + when: localservices.networkmount.host | length > 1 + +- name: template docker compose + template: + src: "compose.yml.j2" + dest: "{{ path }}/compose.yml" + +- name: ensure everything is up + community.docker.docker_compose_v2: + project_src: "{{ path }}" + project_name: "{{ role_name }}" + recreate: always + state: "present" diff --git a/compose.yml b/templates/compose.yml.j2 similarity index 67% rename from compose.yml rename to templates/compose.yml.j2 index 52fe744..9b60b1d 100644 --- a/compose.yml +++ b/templates/compose.yml.j2 @@ -1,10 +1,5 @@ -version: "3.8" - -configs: - wg0_conf: - file: ./aniworld/wg0.conf - services: + {% if localservices.wg_client.enabled %} wireguard: image: linuxserver/wireguard cap_add: @@ -17,37 +12,41 @@ services: restart: unless-stopped sysctls: - net.ipv4.conf.all.src_valid_mark=1 - configs: - - source: wg0_conf - target: /config/wg0.conf + volumes: + - ./config/wg0_conf:/config/wg0.conf networks: - proxy labels: traefik.enable: true + {% if localservices.aniworld.url | length > 0 %} traefik.http.routers.aniworld.service: aniworld - traefik.http.routers.aniworld.rule: Host(`aniworld.arpa.urmel.de`) + traefik.http.routers.aniworld.rule: Host(`{{ localservices.aniworld.url }}`) traefik.http.routers.aniworld.tls: "true" traefik.http.routers.aniworld.tls.certresolver: hetzner traefik.http.services.aniworld.loadbalancer.server.port: 8080 traefik.http.routers.aniworld.middlewares: local-only@file, traefik-auth@file + {% endif %} + {% endif %} - + {% if localservices.aniworld.url | length > 0 %} aniworld: image: ghcr.io/phoenixthrush/aniworld-downloader:latest user: "0:0" network_mode: "service:wireguard" restart: unless-stopped volumes: - - data_aniworld:/app/Downloads - - config_aniworld:/home/aniworld/.aniworld + - {{ localservices.aniworld.url }}:/app/Downloads + - ./confg/.aniworld:/home/aniworld/.aniworld + {% endif %} + {% if localservices.bittorrent.url | length > 0 %} bittorrent: - image: linuxserver/qbittorrent:5.1.4 + image: linuxserver/qbittorrent:latest networks: - proxy volumes: - - config_qbittorrent:/config - - data_qbittorrent:/downloads + - ./config/qbittorrent:/config + - {{ localservices.aniworld.url }}:/downloads ports: - 6881:6881 - 6881:6881/udp @@ -57,7 +56,7 @@ services: - TZ=Europe/Berlin labels: traefik.enable: true - traefik.http.routers.qb.rule: "Host(`qbittorrent.arpa.urmel.de`)" + traefik.http.routers.qb.rule: "Host(`{{ localservices.bittorrent.url }}`)" traefik.http.routers.qb.tls: "true" traefik.http.routers.qb.tls.certresolver: hetzner traefik.http.services.qb.loadbalancer.server.port: "8080" @@ -70,22 +69,22 @@ services: traefik.http.routers.qb.middlewares: local-only@file, traefik-auth@file, qb-headers traefik.http.services.qb.loadbalancer.passhostheader: "false" - + {% if localservices.i2psnark.url | length > 0 %} i2psnark: image: ypopovych/i2psnark:latest volumes: - - config_i2psnark:/snark/config - - data_i2psnark:/snark/downloads + - ./config/i2psnark:/snark/config + - {{ localservices.aniworld.url }}:/snark/downloads networks: - proxy environment: - HOSTNAMES: "i2psnark.arpa.urmel.de" - I2CP_HOST: "i2pendpoint.arpa" + HOSTNAMES: "{{ localservices.i2psnark.url }}" + I2CP_HOST: "{{ localservices.i2psnark.i2pc_host }}" restart: "on-failure" labels: traefik.enable: true - traefik.http.routers.i2psnark.rule: "Host(`i2psnark.arpa.urmel.de`) && (PathPrefix(`/i2psnark/`) || Path(`/`))" + traefik.http.routers.i2psnark.rule: "Host(`{{ localservices.i2psnark.url }}`) && (PathPrefix(`/i2psnark/`) || Path(`/`))" traefik.http.routers.i2psnark.tls: "true" traefik.http.routers.i2psnark.tls.certresolver: hetzner @@ -96,7 +95,7 @@ services: traefik.http.middlewares.i2psnark-redirect.redirectregex.replacement: "/i2psnark/" traefik.http.middlewares.i2psnark-redirect.redirectregex.permanent: "true" - traefik.http.middlewares.i2psnark-headers.headers.customRequestHeaders.Host: i2psnark.arpa.urmel.de + traefik.http.middlewares.i2psnark-headers.headers.customRequestHeaders.Host: {{ localservices.i2psnark.url }} traefik.http.middlewares.i2psnark-headers.headers.customRequestHeaders.X-Forwarded-Proto: https traefik.http.routers.i2psnark.middlewares: local-only@file, traefik-auth@file, i2psnark-redirect, i2psnark-headers @@ -104,25 +103,3 @@ networks: proxy: external: true name: traefik_exposed - -volumes: - data_i2psnark: - driver_opts: - type: nfs4 - o: addr=217.100.0.2,rw,noatime,tcp - device: ":/mnt/Main/servicesData/i2psnark" - config_i2psnark: - - data_aniworld: - driver_opts: - type: nfs4 - o: addr=217.100.0.2,rw,noatime,tcp - device: ":/mnt/Main/servicesData/aniworld" - config_aniworld: - - config_qbittorrent: - data_qbittorrent: - driver_opts: - type: nfs4 - o: addr=217.100.0.2,rw,noatime,tcp - device: ":/mnt/Main/servicesData/qbittorrent"