add postgresql role for ens. psql and opt. some dbs and users are set up
Add postgresql role for ensuring postgresql is installed. Furthermore the role optionally takes some basic configuration to ensure databases with their owners and users are set up as specified. This is a requirement for a new netbox role.
This commit is contained in:
parent
1080932235
commit
c307e81d9f
4 changed files with 95 additions and 0 deletions
roles/postgresql/tasks
28
roles/postgresql/tasks/main.yaml
Normal file
28
roles/postgresql/tasks/main.yaml
Normal file
|
@ -0,0 +1,28 @@
|
|||
- name: Ensure postgresql is installed
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- postgresql
|
||||
become: true
|
||||
|
||||
- name: Ensure Python library for community.postgresql is installed if needed
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- python3-psycopg
|
||||
become: true
|
||||
when: postgresql__dbs != [ ] or postgresql__users != [ ]
|
||||
|
||||
- name: Ensure users
|
||||
community.postgresql.postgresql_user:
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password | default('') }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
loop: "{{ postgresql__users }}"
|
||||
|
||||
- name: Ensure dbs with owners
|
||||
community.postgresql.postgresql_db:
|
||||
name: "{{ item.name }}"
|
||||
owner: "{{ item.owner }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
loop: "{{ postgresql__dbs }}"
|
Loading…
Add table
Add a link
Reference in a new issue