From f63cc86e7e087fde2582529dc0fb578b30331080 Mon Sep 17 00:00:00 2001
From: ptomas-adacis
Date: Tue, 31 Oct 2023 11:14:01 +0100
Subject: [PATCH 1/2] hide plain-text passwords into execution output
---
defaults/main.yml | 2 ++
tasks/configure.yml | 1 +
tasks/schemas.yml | 1 +
3 files changed, 4 insertions(+)
diff --git a/defaults/main.yml b/defaults/main.yml
index b34948291..f357697dd 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -858,3 +858,5 @@ postgresql_dnf_repository_gpgkey: "{{ postgresql_yum_repository_gpgkey }}"
postgresql_apt_py3_dependencies: ["python3-psycopg2", "locales"]
postgresql_apt_py2_dependencies: ["python-psycopg2", "python-pycurl", "locales"]
postgresql_apt_dependencies: "{{ postgresql_apt_py3_dependencies if 'python3' in ansible_python_interpreter|default('') else postgresql_apt_py2_dependencies }}"
+
+postgresql_hide_passwords: false
diff --git a/tasks/configure.yml b/tasks/configure.yml
index c9ce93b60..ac0a03cf5 100644
--- a/tasks/configure.yml
+++ b/tasks/configure.yml
@@ -142,6 +142,7 @@
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
mode: 0640
+ no_log: "{{ postgresql_hide_passwords }}"
register: postgresql_configuration_pt1
- name: PostgreSQL | Update configuration - pt. 2 (postgresql.conf)
diff --git a/tasks/schemas.yml b/tasks/schemas.yml
index 6842e6541..7de47ba61 100644
--- a/tasks/schemas.yml
+++ b/tasks/schemas.yml
@@ -12,5 +12,6 @@
state: "{{ item.state | default('present') }}"
become: yes
become_user: "{{ postgresql_admin_user }}"
+ no_log: "{{ postgresql_hide_passwords }}"
with_items: "{{ postgresql_database_schemas }}"
when: postgresql_databases|length > 0
From 33024293f8051fe038d59a4055d6bc938018f138 Mon Sep 17 00:00:00 2001
From: ptomas-adacis
Date: Tue, 31 Oct 2023 12:08:43 +0100
Subject: [PATCH 2/2] hide plain-text passwords into execution output into
tasks/users.yml
---
tasks/users.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tasks/users.yml b/tasks/users.yml
index dafe16cb6..cca86fd60 100644
--- a/tasks/users.yml
+++ b/tasks/users.yml
@@ -13,7 +13,7 @@
port: "{{postgresql_port}}"
state: "{{ item.state | default('present') }}"
login_user: "{{postgresql_admin_user}}"
- no_log: true
+ no_log: "{{ postgresql_hide_passwords }}"
become: yes
become_user: "{{postgresql_admin_user}}"
with_items: "{{postgresql_users}}"