From 842ccd54b48300d1aa70c6a2ef45267ddc6bbac3 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 26 Dec 2023 12:41:51 +0100 Subject: [PATCH] Made execution dependent on database parameter --- roles/backup-docker-to-local/tasks/main.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/roles/backup-docker-to-local/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml index 9eab4fc0..e67b8ca0 100644 --- a/roles/backup-docker-to-local/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -38,6 +38,12 @@ command: cmd: "python database_entry_seeder.py databases.csv {{database_instance}} {{database_host}} {{database_databasename}} {{database_username}} {{database_password}}" chdir: "{{backup_docker_to_local_folder}}" + when: > + database_instance is defined or + database_host is defined or + database_databasename is defined or + database_username is defined or + database_password is defined - name: Set file permissions for databases.csv to be readable, writable, and executable by root only ansible.builtin.file: @@ -45,7 +51,19 @@ mode: '0700' owner: root group: root - when: run_once_backup_docker_to_local is not defined + when: > + (database_instance is defined or + database_host is defined or + database_databasename is defined or + database_username is defined or + database_password is defined) and + run_once_backup_docker_to_local_file_permission is not defined + register: file_permission_result + +- name: run the backup_docker_to_local_file_permission tasks once + set_fact: + run_once_backup_docker_to_local_file_permission: true + when: run_once_backup_docker_to_local_file_permission is not defined and file_permission_result is defined and file_permission_result.changed - name: run the backup_docker_to_local tasks once set_fact: