init
This commit is contained in:
commit
04ea137dd7
5 changed files with 742 additions and 0 deletions
38
tasks/main.yml
Normal file
38
tasks/main.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
- name: Create database user
|
||||
postgresql_user:
|
||||
name: "{{ database_name }}"
|
||||
password: "{{ database_password }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
notify: restart postgres
|
||||
|
||||
- name: Create database
|
||||
postgresql_db:
|
||||
name: "{{ database_name }}"
|
||||
owner: "{{ database_user }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
notify: restart postgres
|
||||
|
||||
- name: Grant access to database
|
||||
postgresql_privs:
|
||||
type: database
|
||||
database: "{{ database_name }}"
|
||||
role: "{{ database_user }}"
|
||||
grant_option: no
|
||||
privs: all
|
||||
become: true
|
||||
become_user: postgres
|
||||
notify: restart postgres
|
||||
|
||||
- name: Allow remote access to database
|
||||
postgresql_pg_hba:
|
||||
dest: /etc/postgresql/15/main/pg_hba.conf
|
||||
contype: host
|
||||
databases: "{{ database_name }}"
|
||||
users: "{{ database_user }}"
|
||||
address: all
|
||||
create: true
|
||||
become: true
|
||||
become_user: postgres
|
||||
notify: restart postgres
|
Reference in a new issue