44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
|
- name: Install packages.
|
||
|
tags: postgresql
|
||
|
become: true
|
||
|
ansible.builtin.package:
|
||
|
name:
|
||
|
- postgresql
|
||
|
- postgresql-client
|
||
|
- python3-psycopg2
|
||
|
|
||
|
- name: Create databases.
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
tags: postgresql
|
||
|
community.postgresql.postgresql_db:
|
||
|
encoding: "{{ item.encoding | default('utf8') }}"
|
||
|
target: "{{ item.target | default(omit) }}"
|
||
|
name: "{{ item.name }}"
|
||
|
state: "{{ item.state | default('present') }}"
|
||
|
with_items: "{{ psql_databases }}"
|
||
|
|
||
|
- name: Create database users.
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
tags: postgresql
|
||
|
community.postgresql.postgresql_user:
|
||
|
name: "{{ item.name }}"
|
||
|
host: "{{ item.host | default(omit) }}"
|
||
|
password: "{{ item.password | default(omit) }}"
|
||
|
state: "{{ item.state | default('present') }}"
|
||
|
with_items: "{{ psql_users }}"
|
||
|
|
||
|
- name: Create database privileges
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
tags: postgresql
|
||
|
community.postgresql.postgresql_privs:
|
||
|
db: "{{ item.db | default(omit) }}"
|
||
|
privs: "{{ item.privs | default('SELECT,INSERT,UPDATE') }}"
|
||
|
objs: "{{ item.objs }}"
|
||
|
type: "{{ item.type | default(omit) }}"
|
||
|
database: "{{ item.database | default(omit) }}"
|
||
|
roles: "{{ item.roles }}"
|
||
|
grant_option: "{{ item.grant_option | default('yes') }}"
|
||
|
with_items: "{{ psql_privileges }}"
|