39 lines
No EOL
1.2 KiB
YAML
39 lines
No EOL
1.2 KiB
YAML
---
|
|
# Needs variables:
|
|
# - site: dict describing the site install (cf group_vars/all/vars.yml)
|
|
|
|
- name: "Create database {{ site.postgres_database }} if inexistent"
|
|
postgresql_db:
|
|
name: "{{ site.postgres_database }}"
|
|
owner: "{{ site.postgres_username }}"
|
|
encoding: "UTF-8"
|
|
lc_collate: "C"
|
|
lc_ctype: "C"
|
|
template: template0
|
|
state: present
|
|
become: yes
|
|
become_user: postgres
|
|
|
|
- name: "Add database user {{ site.postgres_username }} and grant all privileges on {{ site.postgres_database }}"
|
|
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
|
|
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
|
|
become_user: postgres
|
|
notify: Restart postgres |