From e857902dcc5a4a214f9e85cb0a1aea521948e5a7 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Fri, 4 Jun 2021 10:29:13 -0400 Subject: [PATCH] Fail task if pg_dump command fails --- roles/backup/tasks/postgres.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/backup/tasks/postgres.yml b/roles/backup/tasks/postgres.yml index 77384f6c..c9d74d0c 100644 --- a/roles/backup/tasks/postgres.yml +++ b/roles/backup/tasks/postgres.yml @@ -92,6 +92,11 @@ k8s_exec: namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" - command: >- - bash -c "PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db" + command: | + bash -c """ + set -e -o pipefail + PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db + echo 'Successful' + """ register: data_migration + failed_when: "'Successful' not in data_migration.stdout"