feat(postgresql): add playbooks to provision users, databases, hba entries and entire client(s)
This commit is contained in:
parent
3816daa679
commit
f9f00d1919
24
playbooks/postgresql_client.yml
Normal file
24
playbooks/postgresql_client.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
- import_playbook: finallycoffee.databases.postgresql_user
|
||||
vars:
|
||||
postgresql_users:
|
||||
- name: "{{ postgresql_client_username }}"
|
||||
password: "{{ postgresql_client_password }}"
|
||||
- import_playbook: finallycoffee.databases.postgresql_database
|
||||
vars:
|
||||
postgresql_databases:
|
||||
- name: "{{ postgresql_client_database }}"
|
||||
owner: "{{ postgresql_client_username }}"
|
||||
encoding: "{{ postgresql_client_database_encoding | default('UTF8', true) }}"
|
||||
lc_ctype: "{{ postgresql_client_database_lc_ctype | default('en_US.UTF-8', true) }}"
|
||||
lc_collate: "{{ postgresql_client_database_lc_collate | default('en_US.UTF-8', true) }}"
|
||||
- import_playbook: finallycoffee.databases.postgresql_host_based_authentication
|
||||
vars:
|
||||
postgresql_authentications:
|
||||
- users: "{{ postgresql_client_username }}"
|
||||
databases: "{{ postgresql_client_database }}"
|
||||
contype: "{{ postgresql_client_database_contype | default('local') }}"
|
||||
method: "{{ postgresql_client_database_auth_method | default('md5') }}"
|
||||
options: "{{ postgresql_client_options | default(false, true) }}"
|
||||
address: "{{ postgresql_client_address | default(false, true) }}"
|
||||
netmask: "{{ postgresql_client_netmask | default(false, true) }}"
|
4
playbooks/postgresql_clients.yml
Normal file
4
playbooks/postgresql_clients.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
- import_playbook: finallycoffee.databases.postgresql_user
|
||||
- import_playbook: finallycoffee.databases.postgresql_database
|
||||
- import_playbook: finallycoffee.databases.postgresql_host_based_authentication
|
26
playbooks/postgresql_database.yml
Normal file
26
playbooks/postgresql_database.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Configure postgresql databases
|
||||
hosts: "{{ postgresql_hosts | default('postgresql', true) }}"
|
||||
become: "{{ postgresql_become | default(false, true) }}"
|
||||
gather_facts: "{{ postgresql_gather_facts | default(false, true) }}"
|
||||
tasks:
|
||||
- name: Configure individual postgresql database
|
||||
community.postgresql.postgresql_db:
|
||||
name: "{{ postgresql_database.name }}"
|
||||
owner: "{{ postgresql_database.owner | default(omit) }}"
|
||||
state: "{{ postgresql_database_state }}"
|
||||
template: "{{ postgresql_database.template | default(omit, true) }}"
|
||||
encoding: "{{ postgresql_database.encoding | default(omit, true) }}"
|
||||
lc_ctype: "{{ postgresql_database.lc_ctype | default(omit, true) }}"
|
||||
lc_collate: "{{ postgresql_database.lc_collate | default(omit, true) }}"
|
||||
login_host: "{{ postgresql_connection_host | default(omit, true) }}"
|
||||
login_port: "{{ postgresql_connection_port | default(omit, true) }}"
|
||||
login_unix_socket: "{{ postgresql_connection_unix_socket | default(omit, true) }}"
|
||||
login_user: "{{ postgresql_connection_user | default(omit, true) }}"
|
||||
login_password: "{{ postgresql_connection_password | default(omit, true) }}"
|
||||
vars:
|
||||
postgresql_database_state: "{{ postgresql_database.state | default('present', true) }}"
|
||||
loop: "{{ postgresql_databases | default([]) }}"
|
||||
loop_control:
|
||||
loop_var: postgresql_database
|
||||
label: "{{ postgresql_database.name }}"
|
23
playbooks/postgresql_host_based_authentication.yml
Normal file
23
playbooks/postgresql_host_based_authentication.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Configure postgresql host based authentications
|
||||
hosts: "{{ postgresql_hosts | default('postgresql', true) }}"
|
||||
become: "{{ postgresql_become | default(false, true) }}"
|
||||
gather_facts: "{{ postgresql_gather_facts | default(false, true) }}"
|
||||
tasks:
|
||||
- name: Configure individual postgresql host based authentication
|
||||
community.postgresql.postgresql_pg_hba:
|
||||
dest: "{{ postgresql_pg_hba_conf_file }}"
|
||||
users: "{{ postgresql_auth.users | default(omit) }}"
|
||||
databases: "{{ postgresql_auth.databases | default(omit) }}"
|
||||
contype: "{{ postgresql_auth.contype }}"
|
||||
state: "{{ postgresql_auth_state }}"
|
||||
method: "{{ postgresql_auth.method | default(omit, true) }}"
|
||||
options: "{{ postgresql_auth.options | default(omit, true) }}"
|
||||
address: "{{ postgresql_auth.address | default(omit, true) }}"
|
||||
netmask: "{{ postgresql_auth.netmask | default(omit, true) }}"
|
||||
vars:
|
||||
postgresql_auth_state: "{{ postgresql_auth.state | default('present', true) }}"
|
||||
loop: "{{ postgresql_authentications | default([]) }}"
|
||||
loop_control:
|
||||
loop_var: postgresql_auth
|
||||
label: "{{ postgresql_auth.users }}@{{ postgresql_auth.databases }}"
|
24
playbooks/postgresql_user.yml
Normal file
24
playbooks/postgresql_user.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: Configure postgresql users
|
||||
hosts: "{{ postgresql_hosts | default('postgresql', true) }}"
|
||||
become: "{{ postgresql_become | default(false, true) }}"
|
||||
gather_facts: "{{ postgresql_gather_facts | default(false, true) }}"
|
||||
tasks:
|
||||
- name: Configure individual postgresql user
|
||||
community.postgresql.postgresql_user:
|
||||
name: "{{ postgresql_user.name }}"
|
||||
state: "{{ postgresql_user_state }}"
|
||||
password: "{{ postgresql_user_password }}"
|
||||
login_host: "{{ postgresql_connection_host | default(omit, true) }}"
|
||||
login_port: "{{ postgresql_connection_port | default(omit, true) }}"
|
||||
login_unix_socket: "{{ postgresql_connection_unix_socket | default(omit, true) }}"
|
||||
login_user: "{{ postgresql_connection_user | default(omit, true) }}"
|
||||
login_password: "{{ postgresql_connection_password | default(omit, true) }}"
|
||||
vars:
|
||||
postgresql_user_state: "{{ postgresql_user.state | default('present', true) }}"
|
||||
postgresql_user_password: >-2
|
||||
{{ (postgresql_user_state != 'absent') | ternary(postgresql_user.password, omit) }}
|
||||
loop: "{{ postgresql_users | default([]) }}"
|
||||
loop_control:
|
||||
loop_var: postgresql_user
|
||||
label: "{{ postgresql_user.name }}"
|
Loading…
x
Reference in New Issue
Block a user