From aab9b9e2173c62e2a8cef012ad6d52583e09ec51 Mon Sep 17 00:00:00 2001 From: Jamal Boukaffal Date: Fri, 1 Sep 2023 17:43:47 +0200 Subject: [PATCH] Prevent users, databases and schemas deletion In our case we prefer to prevent this kind of deletion through ansible --- README.md | 4 ---- tasks/databases.yml | 2 +- tasks/schemas.yml | 2 +- tasks/users.yml | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4903dabed..b5340ee62 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,6 @@ postgresql_databases: uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no) citext: yes # flag to install the citext extension on this database (yes/no) encoding: "UTF-8" # override global {{ postgresql_encoding }} variable per database - state: "present" # optional; one of 'present', 'absent', 'dump', 'restore' lc_collate: "en_GB.UTF-8" # override global {{ postgresql_locale }} variable per database lc_ctype: "en_GB.UTF-8" # override global {{ postgresql_ctype }} variable per database @@ -114,18 +113,15 @@ postgresql_users: - name: baz pass: pass encrypted: yes # if password should be encrypted, postgresql >= 10 does only accepts encrypted passwords - state: "present" # optional; one of 'present', 'absent' # List of schemas to be created (optional) postgresql_database_schemas: - database: foobar # database name schema: acme # schema name - state: present - database: foobar # database name schema: acme_baz # schema name owner: baz # owner name - state: present # List of user privileges to be applied (optional) postgresql_user_privileges: diff --git a/tasks/databases.yml b/tasks/databases.yml index 97cfb3adb..e6b038890 100644 --- a/tasks/databases.yml +++ b/tasks/databases.yml @@ -14,7 +14,7 @@ lc_ctype: "{{ item.lc_ctype | default(postgresql_ctype) }}" port: "{{postgresql_port}}" template: "template0" - state: "{{ item.state | default('present') }}" + state: "present" login_user: "{{postgresql_admin_user}}" become: yes become_user: "{{postgresql_admin_user}}" diff --git a/tasks/schemas.yml b/tasks/schemas.yml index 7de47ba61..41cd6440d 100644 --- a/tasks/schemas.yml +++ b/tasks/schemas.yml @@ -9,7 +9,7 @@ login_password: "{{ item.password | default(omit) }}" login_user: "{{ postgresql_admin_user }}" port: "{{ postgresql_port }}" - state: "{{ item.state | default('present') }}" + state: "present" become: yes become_user: "{{ postgresql_admin_user }}" no_log: "{{ postgresql_hide_passwords }}" diff --git a/tasks/users.yml b/tasks/users.yml index cca86fd60..e8df94ac5 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -11,7 +11,7 @@ password: "{{ item.pass | default(omit) }}" encrypted: "{{ item.encrypted | default(omit) }}" port: "{{postgresql_port}}" - state: "{{ item.state | default('present') }}" + state: "present" login_user: "{{postgresql_admin_user}}" no_log: "{{ postgresql_hide_passwords }}" become: yes