untested: localsevices

This commit is contained in:
Kyattsukuro 2026-10-18 19:14:53 +02:00
parent fcc8cf57e0
commit f656f415bd
6 changed files with 108 additions and 46 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# localservices

23
defaults/main.yml Normal file
View File

@ -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: ""

9
handlers/main.yml Normal file
View File

@ -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

20
meta/main.yml Normal file
View File

@ -0,0 +1,20 @@
---
galaxy_info:
author: "Niklas Freese <niklas@urmel.de>"
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

32
tasks/main.yml Normal file
View File

@ -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"

View File

@ -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"