From f9aa2cfed52f298c522bf7f1304e80a503e2a789 Mon Sep 17 00:00:00 2001 From: NaeiKinDus Date: Sun, 28 Jul 2024 00:00:00 +0000 Subject: [PATCH] fix(postgresql): added check to detect possible errors when executing custom init script --- .../nullified/infrastructure/roles/postgresql/tasks/server.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/collections/ansible_collections/nullified/infrastructure/roles/postgresql/tasks/server.yml b/collections/ansible_collections/nullified/infrastructure/roles/postgresql/tasks/server.yml index c55a7ab..8cfdfe3 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/postgresql/tasks/server.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/postgresql/tasks/server.yml @@ -125,6 +125,8 @@ changed_when: false - name: run initialization file ansible.builtin.shell: "su {{ postgresql_default_user }} -c 'psql < {{ tmp_file.path }}'" + register: run_custom_sql_exec + failed_when: run_custom_sql_exec.rc != 0 or "ERROR" in run_custom_sql_exec.get("stderr", "") - name: cleanup ansible.builtin.file: path: '{{ tmp_file.path }}'