From c391a07485400b4afebe189a89311ef8c12ebabc Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:37:01 +0000 Subject: [PATCH 01/16] =?UTF-8?q?Nutze=20Handler=20f=C3=BCr=20ein=20simple?= =?UTF-8?q?res=20Playbook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/start.yaml => handlers/main.yaml | 10 ++- tasks/main.yaml | 91 ++++++++++++++------------ 2 files changed, 55 insertions(+), 46 deletions(-) rename tasks/start.yaml => handlers/main.yaml (54%) diff --git a/tasks/start.yaml b/handlers/main.yaml similarity index 54% rename from tasks/start.yaml rename to handlers/main.yaml index 27e37b9..283dafa 100644 --- a/tasks/start.yaml +++ b/handlers/main.yaml @@ -1,12 +1,16 @@ -- name: Start Gitea +- name: Ensure Gitea is running community.docker.docker_compose: project_src: /opt/gitea - register: docker_compose -- name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200 +- name: Check Gitea HTTP Response ansible.builtin.uri: url: "https://{{ gitea.hostname }}.{{ gitea.domain }}" register: _result until: _result.status == 200 retries: 30 delay: 2 + +- name: Output Docker Compose State + ansible.builtin.debug: + var: docker_compose + when: gitea_docker_compose.changed diff --git a/tasks/main.yaml b/tasks/main.yaml index 36f2d4d..d5d4bd0 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -39,44 +39,54 @@ enabled: true state: started -- name: Backup Files +- name: Stop Gitea for Backup + community.docker.docker_compose: + project_src: /opt/gitea + state: present + stopped: true + notify: + - Ensure Gitea is running + +- name: Backup Gitea Directory + ansible.builtin.copy: + src: /opt/gitea/ + dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" + mode: "700" + remote_src: true + directory_mode: true + register: backup + +- name: Upload Environment File + ansible.builtin.template: + src: environment.env.j2 + dest: "/opt/gitea/environment.env" + owner: root + mode: "600" + +- name: Upload docker-compose.yaml + ansible.builtin.template: + src: docker-compose.yaml.j2 + dest: /opt/gitea/docker-compose.yaml + owner: root + mode: "600" + validate: /usr/bin/docker compose -f %s config -q + notify: + - Output Docker Compose State + +- name: Try to reach Gitea block: - - name: Stop Gitea for Backup + + - name: Start Gitea community.docker.docker_compose: project_src: /opt/gitea - state: present - stopped: true - - name: Backup Gitea Directory - ansible.builtin.copy: - src: /opt/gitea/ - dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" - mode: "700" - remote_src: true - directory_mode: true - register: backup - -- name: Apply Changes - block: - - name: Upload Environment File - ansible.builtin.template: - src: environment.env.j2 - dest: "/opt/gitea/environment.env" - owner: root - mode: "600" - register: gitea_env - - - name: Upload docker-compose.yaml - ansible.builtin.template: - src: docker-compose.yaml.j2 - dest: /opt/gitea/docker-compose.yaml - owner: root - mode: "600" - validate: /usr/bin/docker compose -f %s config -q - - - name: Start Gitea and try reaching it - ansible.builtin.include_tasks: - file: start.yaml + - name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200 + ansible.builtin.uri: + url: "https://{{ gitea.hostname }}.{{ gitea.domain }}" + register: _result + until: _result.status == 200 + retries: 30 + delay: 2 rescue: - name: Stop Gitea for Backup @@ -84,6 +94,8 @@ project_src: /opt/gitea state: present stopped: true + notify: + - Ensure Gitea is running - name: Restore Gitea Directory from Backup ansible.builtin.copy: @@ -91,12 +103,5 @@ dest: "{{ backup.src }}" remote_src: true mode: "700" - - - name: Start Gitea and try reaching it - ansible.builtin.include_tasks: - file: start.yaml - - always: - - name: Output Docker Compose State - ansible.builtin.debug: - var: docker_compose + notify: + - Check Gitea HTTP Response From 6817fe0ff94c281769b510e965c8ed11598a425d Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 19:52:00 +0000 Subject: [PATCH 02/16] [FIX] Repariere den Backup-Wiederherstellungsprozess --- handlers/main.yaml | 22 ++++++++++++++++++++ tasks/main.yaml | 50 ++++++++++++++++++++++++++++------------------ 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/handlers/main.yaml b/handlers/main.yaml index 283dafa..ad32af1 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -1,3 +1,25 @@ +- name: Stop Gitea for Backup + community.docker.docker_compose: + project_src: /opt/gitea + state: present + stopped: true + ignore_errors: true + listen: + - Backup Gitea + notify: + - Ensure Gitea is running + +- name: Backup Gitea Directory + ansible.builtin.copy: + src: /opt/gitea/ + dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" + mode: preserve + remote_src: true + directory_mode: true + listen: + - Backup Gitea + register: backup + - name: Ensure Gitea is running community.docker.docker_compose: project_src: /opt/gitea diff --git a/tasks/main.yaml b/tasks/main.yaml index d5d4bd0..e71b162 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -39,22 +39,30 @@ enabled: true state: started -- name: Stop Gitea for Backup - community.docker.docker_compose: - project_src: /opt/gitea - state: present - stopped: true +- name: Check if environment.env will get changed + ansible.builtin.template: + src: environment.env.j2 + dest: "/opt/gitea/environment.env" + owner: root + mode: "600" + register: env_diff + check_mode: true notify: - - Ensure Gitea is running + - Backup Gitea -- name: Backup Gitea Directory - ansible.builtin.copy: - src: /opt/gitea/ - dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" - mode: "700" - remote_src: true - directory_mode: true - register: backup +- name: Check if docker-compose.yaml will get changed + ansible.builtin.template: + src: docker-compose.yaml.j2 + dest: /opt/gitea/docker-compose.yaml + owner: root + mode: "600" + register: docker_compose_diff + check_mode: true + notify: + - Backup Gitea + +- name: Execute Handlers before changing configfiles + meta: flush_handlers - name: Upload Environment File ansible.builtin.template: @@ -69,11 +77,10 @@ dest: /opt/gitea/docker-compose.yaml owner: root mode: "600" - validate: /usr/bin/docker compose -f %s config -q notify: - Output Docker Compose State -- name: Try to reach Gitea +- name: Try to start and reach Gitea block: - name: Start Gitea @@ -97,11 +104,16 @@ notify: - Ensure Gitea is running + - name: Clean up Gitea Directory before restoring Backup + ansible.builtin.file: + path: /opt/gitea + state: absent + - name: Restore Gitea Directory from Backup ansible.builtin.copy: - src: "{{ backup.dest }}" - dest: "{{ backup.src }}" + src: "{{ backup.dest }}/" + dest: /opt/gitea remote_src: true - mode: "700" + mode: preserve notify: - Check Gitea HTTP Response From e8e05f839184b80b6a54c95fdd9595171afbe197 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 20:22:03 +0000 Subject: [PATCH 03/16] =?UTF-8?q?[FIX]=20Starte=20Gitea=20neu,=20wenn=20di?= =?UTF-8?q?e=20Config=20ge=C3=A4ndert=20wurde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handlers/main.yaml | 5 +++++ tasks/main.yaml | 21 ++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/handlers/main.yaml b/handlers/main.yaml index ad32af1..fec8721 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -20,6 +20,11 @@ - Backup Gitea register: backup +- name: Ensure Gitea is restarted + community.docker.docker_compose: + project_src: /opt/gitea + restarted: true + - name: Ensure Gitea is running community.docker.docker_compose: project_src: /opt/gitea diff --git a/tasks/main.yaml b/tasks/main.yaml index e71b162..0f3ef0f 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -70,6 +70,9 @@ dest: "/opt/gitea/environment.env" owner: root mode: "600" + notify: + - Ensure Gitea is restarted + - Check Gitea HTTP Response - name: Upload docker-compose.yaml ansible.builtin.template: @@ -79,21 +82,13 @@ mode: "600" notify: - Output Docker Compose State + - Ensure Gitea is restarted + - Check Gitea HTTP Response -- name: Try to start and reach Gitea +- name: Update Config block: - - - name: Start Gitea - community.docker.docker_compose: - project_src: /opt/gitea - - - name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200 - ansible.builtin.uri: - url: "https://{{ gitea.hostname }}.{{ gitea.domain }}" - register: _result - until: _result.status == 200 - retries: 30 - delay: 2 + - name: + meta: flush_handlers rescue: - name: Stop Gitea for Backup From f9d1e42513ff3b6d59409738cdccf9038402455f Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 20:22:48 +0000 Subject: [PATCH 04/16] Benenne Task --- tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yaml b/tasks/main.yaml index 0f3ef0f..a8880b5 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -87,7 +87,7 @@ - name: Update Config block: - - name: + - name: Flush Handlers meta: flush_handlers rescue: From 0f9d5f53c458dbe64c6f4b39113f748a48a3855e Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 20:37:28 +0000 Subject: [PATCH 05/16] [FIX] Versuche nicht, Backups automatisch wiederherzustellen --- tasks/main.yaml | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tasks/main.yaml b/tasks/main.yaml index a8880b5..c70c9e0 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -84,31 +84,3 @@ - Output Docker Compose State - Ensure Gitea is restarted - Check Gitea HTTP Response - -- name: Update Config - block: - - name: Flush Handlers - meta: flush_handlers - - rescue: - - name: Stop Gitea for Backup - community.docker.docker_compose: - project_src: /opt/gitea - state: present - stopped: true - notify: - - Ensure Gitea is running - - - name: Clean up Gitea Directory before restoring Backup - ansible.builtin.file: - path: /opt/gitea - state: absent - - - name: Restore Gitea Directory from Backup - ansible.builtin.copy: - src: "{{ backup.dest }}/" - dest: /opt/gitea - remote_src: true - mode: preserve - notify: - - Check Gitea HTTP Response From 130a53ed58ce964732f85a2e367274acaee05cd9 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sat, 29 Apr 2023 20:49:54 +0000 Subject: [PATCH 06/16] lint --- .ansible-lint-ignore | 2 +- handlers/main.yaml | 1 - tasks/main.yaml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore index 2bd0723..19ccc8a 100644 --- a/.ansible-lint-ignore +++ b/.ansible-lint-ignore @@ -3,4 +3,4 @@ # Warnungen und Fehler von ansible-lint ignoriert werden. tasks/main.yaml no-handler # Der Restart / Recreate Gitea Task ist gut dort, wo er ist -tasks/start.yaml name[template] # Es braucht zwei Templates, um den FQDN zusammenzusetzen. +tasks/start.yaml ignore-errors # Der Task darf das Playbook nicht abbrechen. diff --git a/handlers/main.yaml b/handlers/main.yaml index fec8721..6ab2165 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -40,4 +40,3 @@ - name: Output Docker Compose State ansible.builtin.debug: var: docker_compose - when: gitea_docker_compose.changed diff --git a/tasks/main.yaml b/tasks/main.yaml index c70c9e0..c703a16 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -62,7 +62,7 @@ - Backup Gitea - name: Execute Handlers before changing configfiles - meta: flush_handlers + ansible.builtin.meta: flush_handlers - name: Upload Environment File ansible.builtin.template: From 124456ae0787dd2d339ead12c0fe9514ab64a316 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:48:07 +0000 Subject: [PATCH 07/16] Verschiebe Backup Tasks --- handlers/backup.yaml | 21 +++++++++++++++++++++ handlers/main.yaml | 24 +++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 handlers/backup.yaml diff --git a/handlers/backup.yaml b/handlers/backup.yaml new file mode 100644 index 0000000..31a6a52 --- /dev/null +++ b/handlers/backup.yaml @@ -0,0 +1,21 @@ +- name: Stop Gitea for Backup + community.docker.docker_compose: + project_src: /opt/gitea + state: present + stopped: true + ignore_errors: true + listen: + - Backup Gitea + notify: + - Ensure Gitea is running + +- name: Backup Gitea Directory + ansible.builtin.copy: + src: /opt/gitea/ + dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" + mode: preserve + remote_src: true + directory_mode: true + listen: + - Backup Gitea + register: backup diff --git a/handlers/main.yaml b/handlers/main.yaml index 6ab2165..19f3dbb 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -1,24 +1,6 @@ -- name: Stop Gitea for Backup - community.docker.docker_compose: - project_src: /opt/gitea - state: present - stopped: true - ignore_errors: true - listen: - - Backup Gitea - notify: - - Ensure Gitea is running - -- name: Backup Gitea Directory - ansible.builtin.copy: - src: /opt/gitea/ - dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" - mode: preserve - remote_src: true - directory_mode: true - listen: - - Backup Gitea - register: backup +- name: Import Backup Handler + ansible.builtin.import_tasks: + file: backup.yaml - name: Ensure Gitea is restarted community.docker.docker_compose: From d8a29adb5633c7c031198251a97356f3cf22ffdd Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:56:59 +0000 Subject: [PATCH 08/16] Behalte File-Ownership beim kopieren --- handlers/backup.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index 31a6a52..d0ea999 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -10,12 +10,11 @@ - Ensure Gitea is running - name: Backup Gitea Directory - ansible.builtin.copy: + ansible.builtin.synchronize: src: /opt/gitea/ dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" - mode: preserve - remote_src: true - directory_mode: true + recursive: true + delegate_to: "{{ inventory_hostname }}" listen: - Backup Gitea register: backup From 4f1c51475c211eaa1df35eef7c91567f3d93db98 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:59:58 +0000 Subject: [PATCH 09/16] Stoppe Gitea nur, wenn eine docker-compose.yaml existiert --- handlers/backup.yaml | 10 +++++++++- handlers/main.yaml | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index d0ea999..83dd9d0 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -1,13 +1,21 @@ +- name: Get stats of docker-compose.yaml + ansible.builtin.stat: + path: /opt/gitea/docker-compose.yaml + register: docker_compose_stat + listen: + - Backup Gitea + - name: Stop Gitea for Backup community.docker.docker_compose: project_src: /opt/gitea state: present stopped: true - ignore_errors: true + register: docker_compose listen: - Backup Gitea notify: - Ensure Gitea is running + when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists - name: Backup Gitea Directory ansible.builtin.synchronize: diff --git a/handlers/main.yaml b/handlers/main.yaml index 19f3dbb..5299767 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -6,10 +6,12 @@ community.docker.docker_compose: project_src: /opt/gitea restarted: true + register: docker_compose - name: Ensure Gitea is running community.docker.docker_compose: project_src: /opt/gitea + register: docker_compose - name: Check Gitea HTTP Response ansible.builtin.uri: From 1025b8f0763504e25d2411fca761a11340fcef44 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 00:02:56 +0000 Subject: [PATCH 10/16] =?UTF-8?q?Separater=20Handler=20f=C3=BCr=20den=20HT?= =?UTF-8?q?TP=20Response=20Check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handlers/main.yaml | 12 +++++++++--- tasks/main.yaml | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/handlers/main.yaml b/handlers/main.yaml index 5299767..3b5fef5 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -13,11 +13,17 @@ project_src: /opt/gitea register: docker_compose -- name: Check Gitea HTTP Response +- name: Get Gitea HTTP Response ansible.builtin.uri: url: "https://{{ gitea.hostname }}.{{ gitea.domain }}" - register: _result - until: _result.status == 200 + register: gitea_http_response + failed_when: 400 <= gitea_http_response.status < 500 + +- name: Wait until Gitea is up + ansible.builtin.uri: + url: "https://{{ gitea.hostname }}.{{ gitea.domain }}" + register: gitea_http_response + until: gitea_http_response.status == 200 retries: 30 delay: 2 diff --git a/tasks/main.yaml b/tasks/main.yaml index c703a16..fcfc825 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -72,7 +72,7 @@ mode: "600" notify: - Ensure Gitea is restarted - - Check Gitea HTTP Response + - Wait until Gitea is up - name: Upload docker-compose.yaml ansible.builtin.template: @@ -83,4 +83,4 @@ notify: - Output Docker Compose State - Ensure Gitea is restarted - - Check Gitea HTTP Response + - Wait until Gitea is up From d32e4f360836b27d150d87a9dfc806542aa07cf6 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 00:16:38 +0000 Subject: [PATCH 11/16] Verwende den korrekten FQCN des moduls --- handlers/backup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index 83dd9d0..fc68ccf 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -18,7 +18,7 @@ when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists - name: Backup Gitea Directory - ansible.builtin.synchronize: + ansible.posix.synchronize: src: /opt/gitea/ dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" recursive: true From 4857f2d5b93152b8e9138d55740fa2c79644bbd4 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 15:08:26 +0000 Subject: [PATCH 12/16] [lint] Ignoriere Fehler nicht mehr --- .ansible-lint-ignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore index 19ccc8a..e69de29 100644 --- a/.ansible-lint-ignore +++ b/.ansible-lint-ignore @@ -1,6 +0,0 @@ - -# In den hier aufgelisteten Dateien sollen die dahinter stehenden -# Warnungen und Fehler von ansible-lint ignoriert werden. - -tasks/main.yaml no-handler # Der Restart / Recreate Gitea Task ist gut dort, wo er ist -tasks/start.yaml ignore-errors # Der Task darf das Playbook nicht abbrechen. From 657b7717905138fbf359f939a7eaf419ea20bedf Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 15:14:00 +0000 Subject: [PATCH 13/16] Formatierung --- templates/environment.env.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/environment.env.j2 b/templates/environment.env.j2 index 90f8197..68454f3 100644 --- a/templates/environment.env.j2 +++ b/templates/environment.env.j2 @@ -93,7 +93,7 @@ GITEA__service__ENABLE_NOTIFY_MAIL={{ gitea_vars.service.enable_notify_mail }} GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE={{ gitea_vars.service.default_keep_email_private }} {% endif %} {% if 'default_allow_create_organization' in gitea_vars['service'] %} -GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION ={{ gitea_vars.service.default_allow_create_organization }} +GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION={{ gitea_vars.service.default_allow_create_organization }} {% endif %} {% if 'default_enable_timetracking' in gitea_vars['service'] %} GITEA__service__DEFAULT_ENABLE_TIMETRACKING={{ gitea_vars.service.default_enable_timetracking }} From b5986b9592a6b749b9776f58f5004d65f1ce2d38 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 15:25:07 +0000 Subject: [PATCH 14/16] Backup nach /var/backups --- handlers/backup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index fc68ccf..e031bf8 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -20,7 +20,7 @@ - name: Backup Gitea Directory ansible.posix.synchronize: src: /opt/gitea/ - dest: "/opt/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" + dest: "/var/backups/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" recursive: true delegate_to: "{{ inventory_hostname }}" listen: From 283d63a37a7962acda46d888118a8b126ef6adcf Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 15:27:30 +0000 Subject: [PATCH 15/16] FQDN im Dateinamen --- handlers/backup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index e031bf8..8eee21b 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -20,7 +20,7 @@ - name: Backup Gitea Directory ansible.posix.synchronize: src: /opt/gitea/ - dest: "/var/backups/gitea.backup@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" + dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" recursive: true delegate_to: "{{ inventory_hostname }}" listen: From a451843b85d18785b52d891cbbfe2a47eae0a3e7 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 1 May 2023 16:07:56 +0000 Subject: [PATCH 16/16] Archiviere das Backup --- handlers/backup.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/handlers/backup.yaml b/handlers/backup.yaml index 8eee21b..746b357 100644 --- a/handlers/backup.yaml +++ b/handlers/backup.yaml @@ -18,11 +18,13 @@ when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists - name: Backup Gitea Directory - ansible.posix.synchronize: - src: /opt/gitea/ - dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}" - recursive: true - delegate_to: "{{ inventory_hostname }}" + community.general.archive: + path: /opt/gitea/ + dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date --utc --iso-8601=seconds') }}.tar.gz" + force_archive: true + format: gz + owner: root + mode: "400" listen: - Backup Gitea register: backup