From ae06d5ca67a66a7aa22924ce2d9d76c6a36cb203 Mon Sep 17 00:00:00 2001 From: Kyattsukuro Date: Sun, 11 Oct 2026 01:16:35 +0200 Subject: [PATCH] working ansible role --- README.md | 1 + defaults/main.yml | 8 ++++++++ handlers/main.yml | 8 ++++++++ meta/main.yml | 20 ++++++++++++++++++++ tasks/main.yml | 21 +++++++++++++++++++++ compose.yml => templates/compose.yml.j2 | 19 ++++++++----------- 6 files changed, 66 insertions(+), 11 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 (83%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..44f4aab --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# changedetection diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..4108cb6 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,8 @@ +path: /srv/{{ role_name }} + +changedetection_override: {} +changedetection_defaults: + version: "latest" + url: "" + oidc: + forwardauth_url: "" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..e5a8b4f --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,8 @@ +- name: restart container + community.docker.docker_compose_v2: + project_src: "{{ path }}" + project_name: "{{ role_name }}" + recreate: "always" + services: ["changedetection"] + state: "restarted" + when: not _changedetection_already_restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..7967d3d --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,20 @@ +--- +galaxy_info: + author: "Niklas Freese " + description: changedetection + 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..4ffba8d --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: "set local variables from overrides and defaults" + set_fact: + changedetection: "{{ (changedetection_defaults | combine(changedetection_override, recursive=True)) if changedetection_override else changedetection_defaults }}" + +- name: ensure that path exists + file: + path: "{{ path }}/config/changedetection" + state: directory + +- 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 83% rename from compose.yml rename to templates/compose.yml.j2 index 3c7ead6..cfd376e 100644 --- a/compose.yml +++ b/templates/compose.yml.j2 @@ -1,9 +1,8 @@ services: changedetection: - image: ghcr.io/dgtlmoon/changedetection.io:0.55.3 - hostname: changedetection + image: "ghcr.io/dgtlmoon/changedetection.io:{{ changedetection.version }}" #0.55.3 volumes: - - changedetection-data:/datastore + - ./data/changedetection:/datastore # Configurable proxy list support, see https://github.com/dgtlmoon/changedetection.io/wiki/Proxy-configuration#proxy-list-support # - ./proxies.json:/datastore/proxies.json @@ -33,20 +32,21 @@ services: traefik.http.services.changedetection.loadbalancer.server.port: "5000" traefik.http.services.changedetection.loadbalancer.passhostheader: "true" - traefik.http.routers.changedetection-diff.rule: "Host(`changedetection.urmel.de`) && PathPrefix(`/preview`)" + traefik.http.routers.changedetection-diff.rule: "Host(`{{ changedetection.url }}`) && PathPrefix(`/preview`)" traefik.http.routers.changedetection-diff.priority: 100 traefik.http.routers.changedetection-diff.service: changedetection - traefik.http.routers.changedetection.rule: "Host(`changedetection.urmel.de`) && PathPrefix(`/`)" + traefik.http.routers.changedetection.rule: "Host(`{{ changedetection.url }}`) && PathPrefix(`/`)" traefik.http.routers.changedetection.tls: "true" traefik.http.routers.changedetection.tls.certresolver: hetzner traefik.http.routers.changedetection.priority: 90 - traefik.http.routers.changedetection.middlewares: changedetection-auth traefik.http.routers.changedetection.service: changedetection - - traefik.http.middlewares.changedetection-auth.forwardauth.address: "http://authentik-proxy:9000/outpost.goauthentik.io/auth/traefik" + {% if changedetection.oidc.forwardauth_url | length > 0 -%} + traefik.http.routers.changedetection.middlewares: changedetection-auth + traefik.http.middlewares.changedetection-auth.forwardauth.address: "{{ changedetection.oidc.forwardauth_url }}" traefik.http.middlewares.changedetection-auth.forwardauth.trustForwardHeader: true traefik.http.middlewares.changedetection-auth.forwardauth.authResponseHeaders: X-authentik-username,X-authentik-groups,X-authentik-entitlements,X-authentik-email,X-authentik-name + {% endif %} restart: unless-stopped depends_on: @@ -74,6 +74,3 @@ networks: proxy: name: traefik_exposed external: true - -volumes: - changedetection-data: