diff --git a/roles/database_backup/database_backup-mysql/tasks/cleanup-rolling.yml b/roles/database_backup/database_backup-mysql/tasks/cleanup-rolling.yml index 374e65ca..6d132cd5 100644 --- a/roles/database_backup/database_backup-mysql/tasks/cleanup-rolling.yml +++ b/roles/database_backup/database_backup-mysql/tasks/cleanup-rolling.yml @@ -8,3 +8,5 @@ login_password: "{{ _mysql_password }}" with_sequence: start={{ [previous_build_number | int - cleanup_history_depth, 0] | max }} end={{ [previous_build_number | int - mysql_backup.keep, 0] | max }} run_once: true + when: + - database.is_replica is not defined diff --git a/roles/database_backup/database_backup-mysql/tasks/deploy-dump.yml b/roles/database_backup/database_backup-mysql/tasks/deploy-dump.yml index 49bda27e..32108e0a 100644 --- a/roles/database_backup/database_backup-mysql/tasks/deploy-dump.yml +++ b/roles/database_backup/database_backup-mysql/tasks/deploy-dump.yml @@ -20,7 +20,9 @@ login_host: "{{ _mysql_host }}" login_user: "{{ _mysql_user }}" login_password: "{{ _mysql_password }}" - when: previous_build_number == 0 or _build_db_status.rc == 1 + when: + - previous_build_number == 0 or _build_db_status.rc == 1 + - database.is_replica is not defined run_once: true - name: Ensure the dump directory exists. diff --git a/roles/database_backup/database_backup-mysql/tasks/deploy-none.yml b/roles/database_backup/database_backup-mysql/tasks/deploy-none.yml index aa8c7317..fadc79bb 100644 --- a/roles/database_backup/database_backup-mysql/tasks/deploy-none.yml +++ b/roles/database_backup/database_backup-mysql/tasks/deploy-none.yml @@ -4,13 +4,6 @@ - ansible.builtin.set_fact: _mysql_previous_build_database_name: "{{ database.database }}" -- name: Pause to allow replication to catch up. - ansible.builtin.pause: - seconds: "{{ database.pause_seconds }}" - when: - - database.is_replica is defined - - database.is_replica - - name: Check if the database exists already. ansible.builtin.shell: "set -o pipefail && mysql --defaults-extra-file={{ database.credentials_file }} -e 'SHOW DATABASES;' | grep -w {{ _mysql_build_database_name }}" register: _build_db_status @@ -27,5 +20,7 @@ login_host: "{{ _mysql_host }}" login_user: "{{ _mysql_user }}" login_password: "{{ _mysql_password }}" - when: previous_build_number == 0 or _build_db_status.rc == 1 + when: + - previous_build_number == 0 or _build_db_status.rc == 1 + - database.is_replica is not defined run_once: true diff --git a/roles/database_backup/database_backup-mysql/tasks/deploy-rolling.yml b/roles/database_backup/database_backup-mysql/tasks/deploy-rolling.yml index 30fbaa62..38e82fa4 100644 --- a/roles/database_backup/database_backup-mysql/tasks/deploy-rolling.yml +++ b/roles/database_backup/database_backup-mysql/tasks/deploy-rolling.yml @@ -20,6 +20,8 @@ config_file: "{{ database.credentials_file }}" config_overrides_defaults: true run_once: true + when: + - database.is_replica is not defined - name: Check if the previous database exists. ansible.builtin.shell: "set -o pipefail && mysql --defaults-extra-file={{ database.credentials_file }} -e 'SHOW DATABASES;' | grep -w {{ _mysql_previous_build_database_name }}" diff --git a/roles/database_backup/database_backup-mysql/tasks/revert-dump.yml b/roles/database_backup/database_backup-mysql/tasks/revert-dump.yml index 6040c73a..e99a8bda 100644 --- a/roles/database_backup/database_backup-mysql/tasks/revert-dump.yml +++ b/roles/database_backup/database_backup-mysql/tasks/revert-dump.yml @@ -19,7 +19,9 @@ args: executable: /bin/bash run_once: true - when: previous_build_number > 0 + when: + - previous_build_number > 0 + - database.is_replica is not defined - name: Delete unpacked dump file. ansible.builtin.file: