From 9ef6202fdf7da5f4c4fe4c378970bf504a35794f Mon Sep 17 00:00:00 2001 From: Jeltz Date: Wed, 10 Mar 2021 13:23:52 +0100 Subject: [PATCH] Add configuration for users and databases --- roles/postgresql_server/defaults/main.yml | 4 ++++ roles/postgresql_server/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 roles/postgresql_server/defaults/main.yml diff --git a/roles/postgresql_server/defaults/main.yml b/roles/postgresql_server/defaults/main.yml new file mode 100644 index 0000000..643fc0a --- /dev/null +++ b/roles/postgresql_server/defaults/main.yml @@ -0,0 +1,4 @@ +--- +postgresql_db: [] +postgresql_users: [] +... diff --git a/roles/postgresql_server/tasks/main.yml b/roles/postgresql_server/tasks/main.yml index 7f119dd..6748c04 100644 --- a/roles/postgresql_server/tasks/main.yml +++ b/roles/postgresql_server/tasks/main.yml @@ -37,3 +37,17 @@ - postgresql.conf notify: - restart postgresql + +- name: Create databases + postgresql_db: + name: "{{ item.name }}" + loop: "{{ postgresql_databases }}" + +- name: Create users + postgresql_user: + db: "{{ item.database }}" + name: "{{ item.name }}" + password: "{{ item.password }}" + priv: "{{ item.priv }}" + loop: "{{ postgresql_users }}" +...