homeserver/roles/mgrote.postgresql/tasks/main.yml

33 lines
881 B
YAML
Raw Normal View History

2020-08-18 11:57:53 +02:00
- name: install "postgres"
become: yes
apt:
name: "{{ postgres_programme }}"
state: present
update_cache: yes
cache_valid_time: 1800 #https://stackoverflow.com/questions/41535838/how-to-run-apt-update-and-upgrade-via-ansible-shell
- name: install "setfacl support"
become: yes
apt:
name: acl
- name: Create database
become: true
become_user: postgres
postgresql_db:
name: "{{ item.name_db }}"
loop: "{{ postgres_user_and_db }}"
no_log: true
- name: Connect to database, create users and grant access to database
become: true
become_user: postgres
postgresql_user:
db: "{{ item.name_db }}"
name: "{{ item.name_db_user }}"
password: "{{ item.password_db_user }}"
priv: "ALL"
role_attr_flags: SUPERUSER
no_log: true
loop: "{{ postgres_user_and_db }}"