move database role to external repo

This commit is contained in:
Pim Kunis 2023-06-17 14:26:35 +02:00
parent 0d9dc3c02d
commit a249b92069
4 changed files with 5 additions and 41 deletions

View file

@ -18,7 +18,8 @@
- name: Create databases
with_items: "{{ database_passwords | dict2items }}"
include_role:
name: database
name: postgresql_database
vars:
database_name: "{{ item.key }}"
database_user: "{{ item.key }}"
database_password: "{{ item.value }}"

View file

@ -7,3 +7,6 @@
- name: cloudinit_wait
src: https://git.pim.kunis.nl/pim/ansible-role-cloudinit-wait
scm: git
- name: postgresql_database
src: https://git.pim.kunis.nl/home/ansible-role-postgresql-database
scm: git

View file

@ -1,4 +0,0 @@
- name: restart postgres
systemd:
name: postgresql
state: restarted

View file

@ -1,36 +0,0 @@
- name: Create database user
postgresql_user:
name: "{{ database_name }}"
password: "{{ database_password }}"
become: true
become_user: postgres
- name: Create database
postgresql_db:
name: "{{ database_name }}"
owner: "{{ database_name }}"
become: true
become_user: postgres
- name: Grant access to database
postgresql_privs:
type: database
database: "{{ database_name }}"
role: "{{ database_name }}"
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_name }}"
address: all
create: true
become: true
become_user: postgres
notify: restart postgres