From a52cab2f61907c398dbb4b022ca1c2a2241701d0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 8 Dec 2023 20:34:41 +0100 Subject: [PATCH] Refactor wallabag stack name and repo variables Brought in line with other stack naming schemes. --- roles/wallabag/README.md | 2 +- roles/wallabag/defaults/main.yml | 2 +- roles/wallabag/handlers/main.yml | 11 +++++------ roles/wallabag/tasks/main.yml | 8 +++----- roles/wallabag/templates/upstream.json.j2 | 8 ++++---- roles/wallabag/vars/main.yml | 6 +++--- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/roles/wallabag/README.md b/roles/wallabag/README.md index 44eefa9..c1eceff 100644 --- a/roles/wallabag/README.md +++ b/roles/wallabag/README.md @@ -6,7 +6,7 @@ Contains only a single deployed image and a couple of simple variables to set. ## Variables ``` -wallabag_upstream_file_dir: "{{ docker_stack_files_dir }}/{{ stack.name }}" +wallabag_upstream_file_dir: "{{ docker_stack_files_dir }}/{{ stack_name }}" ``` The on-target directory where the proxy configuration file should be stashed. diff --git a/roles/wallabag/defaults/main.yml b/roles/wallabag/defaults/main.yml index a1b8116..dcc02b2 100644 --- a/roles/wallabag/defaults/main.yml +++ b/roles/wallabag/defaults/main.yml @@ -2,7 +2,7 @@ wallabag_version: latest -wallabag_upstream_file_dir: "{{ docker_stack_files_dir }}/{{ stack.name }}" +wallabag_upstream_file_dir: "{{ docker_stack_files_dir }}/{{ stack_name }}" wallabag_use_https: true diff --git a/roles/wallabag/handlers/main.yml b/roles/wallabag/handlers/main.yml index 1f6268b..a104112 100644 --- a/roles/wallabag/handlers/main.yml +++ b/roles/wallabag/handlers/main.yml @@ -15,28 +15,28 @@ listen: "update wallabag upstream" # figure out if upstream id exists -- name: check {{ stack.name }} upstream +- name: check {{ stack_name }} upstream community.docker.docker_container_exec: container: "{{ caddy_container_id }}" command: > - curl localhost:2019/id/{{ stack.name }}_upstream/ + curl localhost:2019/id/{{ stack_name }}_upstream/ changed_when: False register: result become: true listen: "update wallabag upstream" # upstream already exists, patch it -- name: remove old {{ stack.name }} upstream +- name: remove old {{ stack_name }} upstream community.docker.docker_container_exec: container: "{{ caddy_container_id }}" command: > - curl -X DELETE localhost:2019/id/{{ stack.name }}_upstream/ + curl -X DELETE localhost:2019/id/{{ stack_name }}_upstream/ become: true when: (result.stdout | from_json)['error'] is not defined listen: "update wallabag upstream" # upstream has to be created -- name: add {{ stack.name }} upstream +- name: add {{ stack_name }} upstream community.docker.docker_container_exec: container: "{{ caddy_container_id }}" command: > @@ -50,4 +50,3 @@ state: absent become: true listen: "update wallabag upstream" - diff --git a/roles/wallabag/tasks/main.yml b/roles/wallabag/tasks/main.yml index 6c789d6..34e5859 100644 --- a/roles/wallabag/tasks/main.yml +++ b/roles/wallabag/tasks/main.yml @@ -4,7 +4,7 @@ community.docker.docker_container_exec: container: "{{ caddy_container_id }}" command: > - curl localhost:2019/id/{{ stack.name }}_upstream/ + curl localhost:2019/id/{{ stack_name }}_upstream/ register: result changed_when: (result.stdout | from_json) != (lookup('template', 'upstream.json.j2') | from_yaml) become: true @@ -12,14 +12,12 @@ - name: Deploy wallabag to swarm community.general.docker_stack: - name: "{{ stack.name }}" + name: "{{ stack_name }}" state: present prune: yes compose: - - "{{ stack.compose }}" - when: stack is defined + - "{{ stack_compose }}" become: true tags: - docker-swarm notify: "update wallabag upstream" - diff --git a/roles/wallabag/templates/upstream.json.j2 b/roles/wallabag/templates/upstream.json.j2 index 6db9d1a..a20061f 100644 --- a/roles/wallabag/templates/upstream.json.j2 +++ b/roles/wallabag/templates/upstream.json.j2 @@ -1,5 +1,5 @@ { - "@id": "{{ stack.name }}_upstream", + "@id": "{{ stack_name }}_upstream", {% if server_domain is not undefined and not none %} "match": [ { @@ -7,7 +7,7 @@ {% if subdomain_alias is not undefined and not none %} "{{ subdomain_alias }}.{{ server_domain }}" {% else %} - "{{ stack.name }}.{{ server_domain }}" + "{{ stack_name }}.{{ server_domain }}" {% endif %} ] } @@ -19,7 +19,7 @@ {% if subdomain_alias is not undefined and not none %} "/{{ subdomain_alias }}*" {% else %} - "/{{ stack.name }}*" + "/{{ stack_name }}*" {% endif %} ] } @@ -30,7 +30,7 @@ "handler": "reverse_proxy", "upstreams": [ { - "dial": "{{ stack.name }}_app:80" + "dial": "{{ stack_name }}_app:80" } ] } diff --git a/roles/wallabag/vars/main.yml b/roles/wallabag/vars/main.yml index 7e281a4..d270fd5 100644 --- a/roles/wallabag/vars/main.yml +++ b/roles/wallabag/vars/main.yml @@ -1,7 +1,7 @@ --- -stack: - name: wallabag - compose: "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}" +stack_name: wallabag stack_image: "wallabag/wallabag" + +stack_compose: "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}"