From d555f919beefd91f0ea7492544b7a645e6f17ce3 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 19 Oct 2025 09:14:43 +0200 Subject: [PATCH] Also ensure backup dirs present in main.yml in order to make it work also when not using the 'run each role twice, backyp.yml then main.yml' scenario --- tasks/backup.yml | 4 ++-- tasks/main.yml | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tasks/backup.yml b/tasks/backup.yml index cb05134..64668dc 100644 --- a/tasks/backup.yml +++ b/tasks/backup.yml @@ -1,12 +1,12 @@ ## The playbook first runs the 'backup.yml' from each role -- name: create the /backup-dirs file +- name: create the /backup-dirs file # this also runs on main in case someone doesn't run the backup.yml file: path: "/backup-dirs" state: "touch" mode: "0400" changed_when: "true" # we always want ti give roles a chance to register dirs -- name: Ensure file contains lines from array +- name: Ensure file contains lines from array # this also runs on main in case someone doesn't run the backup.yml lineinfile: path: /backup-dirs line: "{{ item }}" diff --git a/tasks/main.yml b/tasks/main.yml index 5c86d65..ea7f6a6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,17 @@ -- debug: - var: group_names +- name: create the /backup-dirs file # this also runs on main in case someone doesn't run the backup.yml + file: + path: "/backup-dirs" + state: "touch" + mode: "0400" + changed_when: "true" # we always want ti give roles a chance to register dirs + +- name: Ensure file contains lines from array # this also runs on main in case someone doesn't run the backup.yml + lineinfile: + path: /backup-dirs + line: "{{ item }}" + create: yes + state: present + loop: "{{ extra_backup_paths }}" - name: make sure restic is installed apt: state=latest pkg=restic