2023-09-01 15:42:19 -04:00
|
|
|
---
|
|
|
|
- name: ensure patroni services are enabled and started on this host so it becomes header
|
|
|
|
service:
|
|
|
|
name: "{{ item }}.service"
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
with_items:
|
|
|
|
- patroni
|
|
|
|
|
|
|
|
- name: wait 15s for cluster to initialize
|
|
|
|
pause:
|
|
|
|
seconds: 15
|
|
|
|
|
|
|
|
- block:
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: create user for DNS role
|
2023-09-01 15:42:19 -04:00
|
|
|
postgresql_user:
|
|
|
|
name: "{{ pvc_dns_database_user }}"
|
|
|
|
password: "{{ pvc_dns_database_password }}"
|
|
|
|
encrypted: yes
|
|
|
|
state: present
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: create database for DNS role
|
2023-09-01 15:42:19 -04:00
|
|
|
postgresql_db:
|
|
|
|
name: "{{ pvc_dns_database_name }}"
|
|
|
|
owner: "{{ pvc_dns_database_user }}"
|
|
|
|
encoding: utf8
|
|
|
|
state: present
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: set user privs for DNS role
|
2023-09-01 15:42:19 -04:00
|
|
|
postgresql_user:
|
|
|
|
name: "{{ pvc_dns_database_user }}"
|
|
|
|
db: "{{ pvc_dns_database_name }}"
|
|
|
|
priv: ALL
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: create user for Provisioner role
|
|
|
|
postgresql_user:
|
|
|
|
name: "{{ pvc_prov_database_user }}"
|
|
|
|
password: "{{ pvc_prov_database_password }}"
|
|
|
|
encrypted: yes
|
|
|
|
state: present
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
|
|
|
- name: create database for Provisioner role
|
|
|
|
postgresql_db:
|
|
|
|
name: "{{ pvc_prov_database_name }}"
|
|
|
|
owner: "{{ pvc_prov_database_user }}"
|
|
|
|
encoding: utf8
|
|
|
|
state: present
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
|
|
|
- name: set user privs for Provisioner role
|
|
|
|
postgresql_user:
|
|
|
|
name: "{{ pvc_prov_database_user }}"
|
|
|
|
db: "{{ pvc_prov_database_name }}"
|
|
|
|
priv: ALL
|
|
|
|
login_host: /run/postgresql
|
|
|
|
|
|
|
|
- name: create extensions for DNS database
|
2023-09-01 15:42:19 -04:00
|
|
|
postgresql_ext:
|
|
|
|
name: "{{ item }}"
|
|
|
|
db: "{{ pvc_dns_database_name }}"
|
|
|
|
login_host: /run/postgresql
|
|
|
|
with_items: "{{ extensions }}"
|
|
|
|
when: extensions is defined
|
|
|
|
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: create extensions for Provisioner database
|
|
|
|
postgresql_ext:
|
|
|
|
name: "{{ item }}"
|
|
|
|
db: "{{ pvc_prov_database_name }}"
|
|
|
|
login_host: /run/postgresql
|
|
|
|
with_items: "{{ extensions }}"
|
|
|
|
when: extensions is defined
|
|
|
|
|
|
|
|
- name: import DNS database schema
|
2023-09-01 15:42:19 -04:00
|
|
|
command: "psql -U {{ pvc_dns_database_user }} -f /etc/postgresql/powerdns-schema.sql {{ pvc_dns_database_name }}"
|
|
|
|
|
2023-09-01 15:42:22 -04:00
|
|
|
- name: import Provisioner database schema
|
|
|
|
command: "psql -U {{ pvc_prov_database_user }} -f /etc/postgresql/provisioner-schema.sql {{ pvc_prov_database_name }}"
|
|
|
|
|
2023-09-01 15:42:19 -04:00
|
|
|
become: yes
|
|
|
|
become_user: postgres
|