feat: add database owner

This commit is contained in:
Adrien Waksberg 2022-07-20 10:35:39 +02:00
parent 186894b7c1
commit 0c2cb81ea1
5 changed files with 31 additions and 25 deletions

View file

@ -11,6 +11,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Added ### Added
- add database owner
- add variable postrgresql_primary - add variable postrgresql_primary
- add user attributes - add user attributes

View file

@ -45,6 +45,7 @@ Example:
| Name | Type | Required | Default | Comment | | Name | Type | Required | Default | Comment |
|------------|------|----------|-----------|-----------------------------------------------------| |------------|------|----------|-----------|-----------------------------------------------------|
| name | str | yes | | the database name | | name | str | yes | | the database name |
| owner | str | yes | | the owner's database name |
| encoding | str | no | UTF-8 | encoding to use | | encoding | str | no | UTF-8 | encoding to use |
| lc_collate | str | no | C.UTF-8 | lc_collate to use | | lc_collate | str | no | C.UTF-8 | lc_collate to use |
| lc_ctype | str | no | C.UTF-8 | lc_ctype to use | | lc_ctype | str | no | C.UTF-8 | lc_ctype to use |
@ -56,6 +57,7 @@ Example:
``` ```
- name: test - name: test
owner: user
encoding: UTF-8 encoding: UTF-8
state: present state: present
``` ```

View file

@ -17,7 +17,9 @@
method: md5 method: md5
postgresql_databases: postgresql_databases:
- name: myappli - name: myappli
owner: test
- name: myappli2 - name: myappli2
owner: test
postgresql_users: postgresql_users:
test: test:
password: secret password: secret

View file

@ -40,20 +40,6 @@
port: 5432 port: 5432
tags: postgresql tags: postgresql
- name: manage databases
community.general.postgresql_db:
name: '{{ item.name }}'
encoding: '{{ item.encoding|default("UTF-8") }}'
state: '{{ item.state|default("present") }}'
lc_collate: '{{ item.lc_collate|default("C.UTF-8") }}'
lc_ctype: '{{ item.lc_ctype|default("C.UTF-8") }}'
template: '{{ item.template|default("template0") }}'
loop: '{{ postgresql_databases }}'
become: true
become_user: postgres
when: postgresql_primary
tags: postgresql
- name: manage users - name: manage users
community.general.postgresql_user: community.general.postgresql_user:
name: '{{ item.key }}' name: '{{ item.key }}'
@ -68,6 +54,21 @@
when: postgresql_primary when: postgresql_primary
tags: postgresql tags: postgresql
- name: manage databases
community.general.postgresql_db:
name: '{{ item.name }}'
encoding: '{{ item.encoding | default("UTF-8") }}'
state: '{{ item.state | default("present") }}'
lc_collate: '{{ item.lc_collate | default("C.UTF-8") }}'
lc_ctype: '{{ item.lc_ctype | default("C.UTF-8") }}'
template: '{{ item.template | default("template0") }}'
owner: '{{ item.owner }}'
loop: '{{ postgresql_databases }}'
become: true
become_user: postgres
when: postgresql_primary
tags: postgresql
- name: manage user's privileges - name: manage user's privileges
community.postgresql.postgresql_privs: community.postgresql.postgresql_privs:
db: '{{ item.database }}' db: '{{ item.database }}'