From e66ef52220b526ee2668d7e0e17f2e86c2850401 Mon Sep 17 00:00:00 2001 From: dtrdnk <> Date: Fri, 17 May 2024 09:22:42 +0300 Subject: [PATCH] Refactoring defaults for db and users --- config_pgcluster.yml | 3 ++- roles/postgresql-databases/defaults/main.yml | 7 +++++++ roles/postgresql-users/defaults/main.yml | 9 +++++++++ vars/main.yml | 16 ---------------- 4 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 roles/postgresql-databases/defaults/main.yml create mode 100644 roles/postgresql-users/defaults/main.yml diff --git a/config_pgcluster.yml b/config_pgcluster.yml index 42110ab41..ee314f9a9 100644 --- a/config_pgcluster.yml +++ b/config_pgcluster.yml @@ -127,7 +127,8 @@ firewall_additional_rules: "{{ firewall_rules_dynamic_var | default([]) | unique }}" when: firewall_enabled_at_boot | bool tags: firewall - + - role: pg_cluster_defaults + tags: always - role: hostname - role: resolv_conf - role: etc_hosts diff --git a/roles/postgresql-databases/defaults/main.yml b/roles/postgresql-databases/defaults/main.yml new file mode 100644 index 000000000..65fd05812 --- /dev/null +++ b/roles/postgresql-databases/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# (optional) list of databases to be created (if not already exists) +postgresql_databases: [] +# - { db: "mydatabase", encoding: "UTF8", lc_collate: "ru_RU.UTF-8", lc_ctype: "ru_RU.UTF-8", owner: "mydb-user" } +# - { db: "mydatabase2", encoding: "UTF8", lc_collate: "ru_RU.UTF-8", lc_ctype: "ru_RU.UTF-8", owner: "mydb-user", conn_limit: "50" } +# - { db: "", encoding: "UTF8", lc_collate: "en_US.UTF-8", lc_ctype: "en_US.UTF-8", owner: "" } +# - { db: "", encoding: "UTF8", lc_collate: "en_US.UTF-8", lc_ctype: "en_US.UTF-8", owner: "" } diff --git a/roles/postgresql-users/defaults/main.yml b/roles/postgresql-users/defaults/main.yml new file mode 100644 index 000000000..646d8aa7e --- /dev/null +++ b/roles/postgresql-users/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# (optional) list of users to be created (if not already exists) +postgresql_users: + - { name: "{{ pgbouncer_auth_username }}", password: "{{ pgbouncer_auth_password }}", flags: "LOGIN", role: "" } +# - { name: "monitoring_auth_username", password: "monitoring_user_password", flags: "LOGIN", role: "pg_monitor" } # monitoring Service Account +# - { name: "mydb-user", password: "mydb-user-pass", flags: "SUPERUSER" } +# - { name: "", password: "", flags: "NOSUPERUSER" } +# - { name: "", password: "", flags: "NOSUPERUSER" } +# - { name: "", password: "", flags: "NOLOGIN" } diff --git a/vars/main.yml b/vars/main.yml index 40ae769e2..724489b36 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -153,22 +153,6 @@ postgresql_locale: "en_US.UTF-8" # for bootstrap only (initdb) postgresql_data_checksums: true # for bootstrap only (initdb) postgresql_password_encryption_algorithm: "scram-sha-256" # or "md5" if your clients do not work with passwords encrypted with SCRAM-SHA-256 -# (optional) list of users to be created (if not already exists) -postgresql_users: - - { name: "{{ pgbouncer_auth_username }}", password: "{{ pgbouncer_auth_password }}", flags: "LOGIN", role: "" } -# - { name: "monitoring_auth_username", password: "monitoring_user_password", flags: "LOGIN", role: "pg_monitor" } # monitoring Service Account -# - { name: "mydb-user", password: "mydb-user-pass", flags: "SUPERUSER" } -# - { name: "", password: "", flags: "NOSUPERUSER" } -# - { name: "", password: "", flags: "NOSUPERUSER" } -# - { name: "", password: "", flags: "NOLOGIN" } - -# (optional) list of databases to be created (if not already exists) -postgresql_databases: [] -# - { db: "mydatabase", encoding: "UTF8", lc_collate: "ru_RU.UTF-8", lc_ctype: "ru_RU.UTF-8", owner: "mydb-user" } -# - { db: "mydatabase2", encoding: "UTF8", lc_collate: "ru_RU.UTF-8", lc_ctype: "ru_RU.UTF-8", owner: "mydb-user", conn_limit: "50" } -# - { db: "", encoding: "UTF8", lc_collate: "en_US.UTF-8", lc_ctype: "en_US.UTF-8", owner: "" } -# - { db: "", encoding: "UTF8", lc_collate: "en_US.UTF-8", lc_ctype: "en_US.UTF-8", owner: "" } - # (optional) list of schemas to be created (if not already exists) postgresql_schemas: [] # - { schema: "myschema", db: "mydatabase", owner: "mydb-user" }