Make things even nicer

This commit is contained in:
Joshua Boniface 2023-09-01 15:42:19 -04:00
parent a22203c887
commit 8fbbce3d16
3 changed files with 33 additions and 17 deletions

View File

@ -10,6 +10,8 @@
- include: zookeeper.yml
tags: pvc-zookeeper
- meta: flush_handlers
- include: libvirt.yml
tags: pvc-libvirt

View File

@ -10,10 +10,10 @@
update-cache: yes
- name: first run check
shell: "echo 'bootstrapped' > /etc/postgresql/pvc"
shell: "echo 'bootstrapped' > /etc/patroni-install"
register: newinstance
args:
creates: /etc/postgresql/pvc
creates: /etc/patroni-install
- name: stop and disable postgresql
service:
@ -66,14 +66,6 @@
dest: /usr/lib/check_mk_agent/plugins/postgres
mode: 0755
- name: ensure patroni services are enabled and started
service:
name: "{{ item }}.service"
state: started
enabled: yes
with_items:
- patroni
- name: install initial schema files
copy:
src: "{{ item.src }}"
@ -85,14 +77,27 @@
- { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" }
- block:
- 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
when: newinstance.changed
run_once: yes
- block:
- name: create user for role
postgresql_user:
name: "{{ pvc_dns_database_user }}"
password: "{{ pvc_dns_database_password }}"
encrypted: yes
state: present
login_host: /run/postgresql
@ -124,4 +129,13 @@
become: yes
become_user: postgres
when: newinstance.changed and ansible_local.host_id == '1'
when: newinstance.changed
run_once: yes
- name: ensure patroni services are enabled and started
service:
name: "{{ item }}.service"
state: started
enabled: yes
with_items:
- patroni

View File

@ -1,13 +1,13 @@
scope: pvcdns
namespace: /patroni
namespace: /patroni/
name: {{ ansible_hostname }}
restapi:
listen: '0.0.0.0:8008'
connect_address: '{{ ansible_fqdn }}:8008'
connect_address: '{{ ansible_hostname }}.{{ pvc_cluster_domain }}:8008'
zookeeper:
hosts: [ {% for host in groups[ansible_local.host_group] %}'{{ host }}.{{ ansible_domain }}:2181',{% endfor %} ]
hosts: [ {% for host in groups[hostvars[inventory_hostname].group_names[0]] %}'{{ host }}.{{ pvc_cluster_domain }}:2181',{% endfor %} ]
bootstrap:
dcs:
@ -25,8 +25,8 @@ bootstrap:
pg_hba:
- local all all peer
- host replication replicator 127.0.0.1/32 trust
{% for host in groups[ansible_local.host_group] %}
- host replication replicator {{ host }}.{{ ansible_domain }} trust
{% for host in groups[hostvars[inventory_hostname].group_names[0]] %}
- host replication replicator {{ host }}.{{ pvc_cluster_domain }} trust
{% endfor %}
- host all all 0.0.0.0/0 md5
@ -39,7 +39,7 @@ bootstrap:
postgresql:
listen: '0.0.0.0:5432'
connect_address: '{{ ansible_fqdn }}:5432'
connect_address: '{{ ansible_hostname }}.{{ pvc_cluster_domain }}:5432'
log_destination: 'stderr'
log_min_messages: INFO
custom_conf: /etc/postgresql/postgresql.pvc.conf