feat: add database owner
This commit is contained in:
parent
186894b7c1
commit
0c2cb81ea1
5 changed files with 31 additions and 25 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
```
|
```
|
||||||
|
|
|
@ -34,4 +34,4 @@ postgresql_config_default:
|
||||||
lc_time: C.UTF-8
|
lc_time: C.UTF-8
|
||||||
default_text_search_config: pg_catalog.english
|
default_text_search_config: pg_catalog.english
|
||||||
include_dir: conf.d
|
include_dir: conf.d
|
||||||
postgresql_config_full: '{{ postgresql_config_default|combine(postgresql_config) }}'
|
postgresql_config_full: '{{ postgresql_config_default | combine(postgresql_config) }}'
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -40,29 +40,30 @@
|
||||||
port: 5432
|
port: 5432
|
||||||
tags: postgresql
|
tags: postgresql
|
||||||
|
|
||||||
- name: manage databases
|
- name: manage users
|
||||||
community.general.postgresql_db:
|
community.general.postgresql_user:
|
||||||
name: '{{ item.name }}'
|
name: '{{ item.key }}'
|
||||||
encoding: '{{ item.encoding|default("UTF-8") }}'
|
password: '{{ item.value.password }}'
|
||||||
state: '{{ item.state|default("present") }}'
|
role_attr_flags: '{{ item.value.attributes | default([]) | join(",") }}'
|
||||||
lc_collate: '{{ item.lc_collate|default("C.UTF-8") }}'
|
state: '{{ item.value.state | default("present") }}'
|
||||||
lc_ctype: '{{ item.lc_ctype|default("C.UTF-8") }}'
|
loop: '{{ postgresql_users | dict2items }}'
|
||||||
template: '{{ item.template|default("template0") }}'
|
loop_control:
|
||||||
loop: '{{ postgresql_databases }}'
|
label: '{{ item.key }}'
|
||||||
become: true
|
become: true
|
||||||
become_user: postgres
|
become_user: postgres
|
||||||
when: postgresql_primary
|
when: postgresql_primary
|
||||||
tags: postgresql
|
tags: postgresql
|
||||||
|
|
||||||
- name: manage users
|
- name: manage databases
|
||||||
community.general.postgresql_user:
|
community.general.postgresql_db:
|
||||||
name: '{{ item.key }}'
|
name: '{{ item.name }}'
|
||||||
password: '{{ item.value.password }}'
|
encoding: '{{ item.encoding | default("UTF-8") }}'
|
||||||
role_attr_flags: '{{ item.value.attributes|default([])|join(",") }}'
|
state: '{{ item.state | default("present") }}'
|
||||||
state: '{{ item.value.state|default("present") }}'
|
lc_collate: '{{ item.lc_collate | default("C.UTF-8") }}'
|
||||||
loop: '{{ postgresql_users|dict2items }}'
|
lc_ctype: '{{ item.lc_ctype | default("C.UTF-8") }}'
|
||||||
loop_control:
|
template: '{{ item.template | default("template0") }}'
|
||||||
label: '{{ item.key }}'
|
owner: '{{ item.owner }}'
|
||||||
|
loop: '{{ postgresql_databases }}'
|
||||||
become: true
|
become: true
|
||||||
become_user: postgres
|
become_user: postgres
|
||||||
when: postgresql_primary
|
when: postgresql_primary
|
||||||
|
@ -72,10 +73,10 @@
|
||||||
community.postgresql.postgresql_privs:
|
community.postgresql.postgresql_privs:
|
||||||
db: '{{ item.database }}'
|
db: '{{ item.database }}'
|
||||||
roles: '{{ item.role }}'
|
roles: '{{ item.role }}'
|
||||||
type: '{{ item.type|default("table") }}'
|
type: '{{ item.type | default("table") }}'
|
||||||
objs: '{{ item.objets|default(["ALL_IN_SCHEMA"])|join(",") }}'
|
objs: '{{ item.objets | default(["ALL_IN_SCHEMA"]) | join(",") }}'
|
||||||
privs: '{{ item.privileges|join(",") }}'
|
privs: '{{ item.privileges | join(",") }}'
|
||||||
state: '{{ item.state|default("present") }}'
|
state: '{{ item.state | default("present") }}'
|
||||||
loop: '{{ postgresql_privileges }}'
|
loop: '{{ postgresql_privileges }}'
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.role }}/{{ item.database }}'
|
label: '{{ item.role }}/{{ item.database }}'
|
||||||
|
@ -88,8 +89,8 @@
|
||||||
community.postgresql.postgresql_membership:
|
community.postgresql.postgresql_membership:
|
||||||
groups: '{{ item.key }}'
|
groups: '{{ item.key }}'
|
||||||
target_roles: '{{ item.value.roles }}'
|
target_roles: '{{ item.value.roles }}'
|
||||||
state: '{{ item.value.state|default("present") }}'
|
state: '{{ item.value.state | default("present") }}'
|
||||||
loop: '{{ postgresql_role_memberships|dict2items }}'
|
loop: '{{ postgresql_role_memberships | dict2items }}'
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.key }}'
|
label: '{{ item.key }}'
|
||||||
become: true
|
become: true
|
||||||
|
|
Loading…
Reference in a new issue