From c6b4cb700b64e18ba0d7cefe30776a226d002473 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 11 Oct 2024 18:09:01 +0200 Subject: [PATCH] refactor wallabag --- .../docker-compose.yaml} | 0 .../templates/{ => wallabag}/wallabag.env.j2 | 0 playbooks/apps/wallabag.yaml | 40 ++++++++++++++----- 3 files changed, 29 insertions(+), 11 deletions(-) rename playbooks/apps/files/{wallabag-docker-compose.yaml => wallabag/docker-compose.yaml} (100%) rename playbooks/apps/templates/{ => wallabag}/wallabag.env.j2 (100%) diff --git a/playbooks/apps/files/wallabag-docker-compose.yaml b/playbooks/apps/files/wallabag/docker-compose.yaml similarity index 100% rename from playbooks/apps/files/wallabag-docker-compose.yaml rename to playbooks/apps/files/wallabag/docker-compose.yaml diff --git a/playbooks/apps/templates/wallabag.env.j2 b/playbooks/apps/templates/wallabag/wallabag.env.j2 similarity index 100% rename from playbooks/apps/templates/wallabag.env.j2 rename to playbooks/apps/templates/wallabag/wallabag.env.j2 diff --git a/playbooks/apps/wallabag.yaml b/playbooks/apps/wallabag.yaml index 75dafc4..6effc2e 100644 --- a/playbooks/apps/wallabag.yaml +++ b/playbooks/apps/wallabag.yaml @@ -1,5 +1,5 @@ --- -- name: Setup wallabag +- name: Wallabag hosts: servers gather_facts: false tasks: @@ -8,22 +8,40 @@ path: "{{ dir }}" state: directory mode: "0775" - - name: Write env file - ansible.builtin.template: - src: templates/wallabag.env.j2 - dest: "{{ dir }}/wallabag.env" - mode: "0644" - - name: Write docker-compose.yaml + - name: Write files ansible.builtin.copy: - src: files/wallabag-docker-compose.yaml - dest: "{{ dir }}/docker-compose.yaml" - mode: "0644" + src: "{{ item }}" + dest: "{{ dir }}/" + mode: preserve + with_fileglob: + - files/{{ app_name }}/* + - files/{{ app_name }}/.* + notify: + - Restart service + - name: Write templates + ansible.builtin.template: + src: "{{ item }}" + dest: "{{ dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}" + mode: preserve + with_fileglob: + - templates/{{ app_name }}/*.j2 + - templates/{{ app_name }}/.*.j2 + notify: + - Restart service - name: Ensure service is started community.docker.docker_compose_v2: project_src: "{{ dir }}" state: present + + handlers: + - name: Restart service + community.docker.docker_compose_v2: + project_src: "{{ dir }}" + state: restarted + vars: - dir: /mnt/data/wallabag + app_name: wallabag + dir: /mnt/data/{{ app_name }} secret_key: !vault | $ANSIBLE_VAULT;1.1;AES256 31346432623062383331306633383230376264326530643236393838356166346563653637376666