diff --git a/defaults/main.yml b/defaults/main.yml index 5c2a33b3..d8a8180d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,6 +15,7 @@ postgresql_service_group: "{{ postgresql_admin_user }}" postgresql_cluster_name: "main" postgresql_cluster_reset: false +postgresql_database_owner: "{{ postgresql_admin_user }}" # Extensions postgresql_ext_install_contrib: no postgresql_ext_install_dev_headers: no diff --git a/tasks/databases.yml b/tasks/databases.yml index f22f2f3d..c87cee79 100644 --- a/tasks/databases.yml +++ b/tasks/databases.yml @@ -8,6 +8,7 @@ - name: PostgreSQL | Make sure the PostgreSQL databases are present postgresql_db: name: "{{item.name}}" + owner: "{{postgresql_database_owner}}" encoding: "{{postgresql_encoding}}" lc_collate: "{{postgresql_locale}}" lc_ctype: "{{postgresql_locale}}" diff --git a/tasks/main.yml b/tasks/main.yml index 053d6e4b..9b5dab63 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -7,6 +7,7 @@ tags: [postgresql, postgresql-extensions] - include: configure.yml +<<<<<<< HEAD tags: [postgresql, postgresql-configure] - include: databases.yml @@ -15,6 +16,11 @@ - include: users.yml tags: [postgresql, postgresql-users] +======= +- include: users.yml +- include: databases.yml +- include: users_priv.yml +>>>>>>> c20146400af29681dc4faed4d6744e74bd6aacd6 - include: monit.yml when: monit_protection is defined and monit_protection == true tags: [postgresql, postgresql-monit] diff --git a/tasks/users.yml b/tasks/users.yml index 9323d86a..58739a52 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -13,13 +13,3 @@ login_host: "{{item.host | default('localhost')}}" with_items: postgresql_users when: postgresql_users|length > 0 - -- name: PostgreSQL | Update the user privileges - postgresql_user: - name: "{{item.name}}" - db: "{{item.db}}" - priv: "{{item.priv | default('ALL')}}" - state: present - login_host: "{{item.host | default('localhost')}}" - with_items: postgresql_user_privileges - when: postgresql_users|length > 0 diff --git a/tasks/users_privileges.yml b/tasks/users_privileges.yml new file mode 100644 index 00000000..56b377c3 --- /dev/null +++ b/tasks/users_privileges.yml @@ -0,0 +1,11 @@ +# file: postgresql/tasks/users_privileges.yml + +- name: PostgreSQL | Update the user privileges + postgresql_user: + name: "{{item.name}}" + db: "{{item.db}}" + priv: "{{item.priv | default('ALL')}}" + state: present + login_host: "{{item.host | default('localhost')}}" + with_items: postgresql_user_privileges + when: postgresql_users|length > 0