aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/absent.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/absent.yml')
-rw-r--r--tasks/absent.yml74
1 files changed, 45 insertions, 29 deletions
diff --git a/tasks/absent.yml b/tasks/absent.yml
index b1a5592..6afb7f3 100644
--- a/tasks/absent.yml
+++ b/tasks/absent.yml
@@ -38,6 +38,12 @@
register: timer_stat
become: true
+- name: Check if prune systemd timer exists
+ ansible.builtin.stat:
+ path: /etc/systemd/system/{{ borg_prune_timer_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.timer
+ register: prune_timer_stat
+ become: true
+
- name: Stop systemd timer
ansible.builtin.systemd:
name: "{{ borg_backup_timer_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.timer"
@@ -46,12 +52,26 @@
become: true
when: timer_stat.stat.exists
+- name: Stop prune systemd timer
+ ansible.builtin.systemd:
+ name: "{{ borg_prune_timer_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.timer"
+ state: stopped
+ enabled: false
+ become: true
+ when: prune_timer_stat.stat.exists
+
- name: Check if systemd service exists
ansible.builtin.stat:
path: /etc/systemd/system/{{ borg_backup_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service
register: service_stat
become: true
+- name: Check if prune systemd service exists
+ ansible.builtin.stat:
+ path: /etc/systemd/system/{{ borg_prune_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service
+ register: prune_service_stat
+ become: true
+
- name: Stop systemd service
ansible.builtin.systemd:
name: "{{ borg_backup_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service"
@@ -60,59 +80,55 @@
become: true
when: service_stat.stat.exists
+- name: Stop prune systemd service
+ ansible.builtin.systemd:
+ name: "{{ borg_prune_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service"
+ state: stopped
+ enabled: false
+ become: true
+ when: prune_service_stat.stat.exists
+
- name: Remove systemd timer file
ansible.builtin.file:
path: /etc/systemd/system/{{ borg_backup_timer_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.timer
state: absent
become: true
+- name: Remove prune systemd timer file
+ ansible.builtin.file:
+ path: /etc/systemd/system/{{ borg_prune_timer_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.timer
+ state: absent
+ become: true
+
- name: Remove systemd service file
ansible.builtin.file:
path: /etc/systemd/system/{{ borg_backup_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service
state: absent
become: true
+- name: Remove prune systemd service file
+ ansible.builtin.file:
+ path: /etc/systemd/system/{{ borg_prune_service_name }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}.service
+ state: absent
+ become: true
+
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true
become: true
-- name: Check if base backup script exists
- ansible.builtin.stat:
- path: "{{ borg_backup_script_location }}"
- register: base_script_stat
- become: true
-
-- name: Remove repo-specific backup script
+- name: Remove repository-specific backup script
ansible.builtin.file:
- path: "{{ borg_backup_script_location }}{{ '@' if borg_backup_argument != '' }}{{ borg_backup_argument }}"
- state: absent
- become: true
- when: borg_backup_argument | length > 0
-
-- name: Remove block from base backup script
- ansible.builtin.blockinfile:
- path: "{{ borg_backup_script_location }}"
- marker: "## {mark} ANSIBLE MANAGED BLOCK for {{ borg_server_host_url }}/{{ borg_repo_name }}"
+ path: "{{ borg_backup_script_location }}{{ '@' if borg_backup_argument != '' else '' }}{{ borg_backup_argument }}"
state: absent
become: true
- when: base_script_stat.stat.exists
-- name: Read base script content
- ansible.builtin.slurp:
- src: "{{ borg_backup_script_location }}"
- register: base_script_content
- become: true
- when: base_script_stat.stat.exists
-
-- name: Remove empty base script
+- name: Remove repository-specific prune script
ansible.builtin.file:
- path: "{{ borg_backup_script_location }}"
+ path: "{{ borg_prune_script_location }}{{ '@' if borg_backup_argument != '' else '' }}{{ borg_backup_argument }}"
state: absent
become: true
- when:
- - base_script_stat.stat.exists
- - ('ANSIBLE MANAGED BLOCK' not in (base_script_content.content | b64decode))
+ when: borg_prune_script_location | length > 0
- name: Remove per-repo SSH private key
ansible.builtin.file: