From 43ab5619e203d064b9fddbfdaf3dafbab6cc5363 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 2 Oct 2023 14:44:47 +0200 Subject: [PATCH 1/2] Assert that database username and password are defined. Signed-off-by: Bas Meijer --- .../jfrog/platform/roles/postgres/tasks/install.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml b/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml index d8b0c941..df6b5dd6 100644 --- a/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml +++ b/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml @@ -81,6 +81,16 @@ timeout: 120 sleep: 10 +- name: Assert database username and password are defined + ansible.builtin.assert: + that: + - curr_user.username is defined + - curr_user.password is defined + loop: "{{ database | dict2items | map(attribute='value') | list }}" + loop_control: + loop_var: curr_user + when: curr_user.enabled | bool + - name: Create user become: true become_user: postgres From d6c17ad37d25b332b83a061577ef8e315daf88b2 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 9 Oct 2023 15:03:00 +0200 Subject: [PATCH 2/2] Assertion at the start of the postgres role. --- .../platform/roles/postgres/tasks/install.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml b/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml index df6b5dd6..e6b9700b 100644 --- a/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml +++ b/Ansible/ansible_collections/jfrog/platform/roles/postgres/tasks/install.yml @@ -1,3 +1,13 @@ +- name: Assert database username and password are defined + ansible.builtin.assert: + that: + - curr_user.username is defined + - curr_user.password is defined + loop: "{{ database | dict2items | map(attribute='value') | list }}" + loop_control: + loop_var: curr_user + when: curr_user.enabled | bool + - name: Define OS-specific variables ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" @@ -81,16 +91,6 @@ timeout: 120 sleep: 10 -- name: Assert database username and password are defined - ansible.builtin.assert: - that: - - curr_user.username is defined - - curr_user.password is defined - loop: "{{ database | dict2items | map(attribute='value') | list }}" - loop_control: - loop_var: curr_user - when: curr_user.enabled | bool - - name: Create user become: true become_user: postgres