2020-06-01 06:21:27 +00:00
|
|
|
---
|
|
|
|
# Needs variables:
|
|
|
|
# - site: dict describing the site install (cf group_vars/all/vars.yml)
|
|
|
|
|
2020-06-02 10:54:54 +00:00
|
|
|
- name: "Create database {{ site.postgres_database }} if inexistent"
|
|
|
|
postgresql_db:
|
|
|
|
name: "{{ site.postgres_database }}"
|
2020-06-29 18:03:37 +00:00
|
|
|
owner: "{{ site.postgres_username }}"
|
2020-06-29 16:33:37 +00:00
|
|
|
encoding: "UTF-8"
|
|
|
|
lc_collate: "C"
|
|
|
|
lc_ctype: "C"
|
|
|
|
template: template0
|
2020-06-02 10:54:54 +00:00
|
|
|
state: present
|
|
|
|
become: yes
|
|
|
|
become_user: postgres
|
2020-06-01 06:21:27 +00:00
|
|
|
|
2020-06-29 16:33:37 +00:00
|
|
|
- name: "Add database user {{ site.postgres_username }} and grant all privileges on {{ site.postgres_database }}"
|
2020-06-02 10:54:54 +00:00
|
|
|
postgresql_user:
|
|
|
|
# Credentials of the new db user
|
|
|
|
name: "{{ site.postgres_username }}"
|
|
|
|
password: "{{ site.postgres_password }}"
|
|
|
|
db: "{{ site.postgres_database }}"
|
|
|
|
priv: ALL
|
|
|
|
# host: "{{ site.subnet_site_ip }}"
|
|
|
|
become: yes
|
2020-06-29 16:33:37 +00:00
|
|
|
become_user: postgres
|
|
|
|
|
|
|
|
- name: "Authorize {{ site.subnet_site_ip }} to login to Postres as user {{ site.postgres_username }}"
|
|
|
|
postgresql_pg_hba:
|
|
|
|
dest: "{{ postgres.pg_hba_path }}"
|
|
|
|
contype: host
|
|
|
|
users: "{{ site.postgres_username }}"
|
|
|
|
source: "{{ site.subnet_site_ip }}"
|
|
|
|
databases: "{{ site.postgres_database }}"
|
|
|
|
method: md5
|
|
|
|
state: present
|
|
|
|
become: yes
|
2020-06-29 18:03:37 +00:00
|
|
|
become_user: postgres
|
|
|
|
notify: Restart postgres
|