Make things even nicer
This commit is contained in:
parent
a22203c887
commit
8fbbce3d16
|
@ -10,6 +10,8 @@
|
||||||
- include: zookeeper.yml
|
- include: zookeeper.yml
|
||||||
tags: pvc-zookeeper
|
tags: pvc-zookeeper
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
|
||||||
- include: libvirt.yml
|
- include: libvirt.yml
|
||||||
tags: pvc-libvirt
|
tags: pvc-libvirt
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
update-cache: yes
|
update-cache: yes
|
||||||
|
|
||||||
- name: first run check
|
- name: first run check
|
||||||
shell: "echo 'bootstrapped' > /etc/postgresql/pvc"
|
shell: "echo 'bootstrapped' > /etc/patroni-install"
|
||||||
register: newinstance
|
register: newinstance
|
||||||
args:
|
args:
|
||||||
creates: /etc/postgresql/pvc
|
creates: /etc/patroni-install
|
||||||
|
|
||||||
- name: stop and disable postgresql
|
- name: stop and disable postgresql
|
||||||
service:
|
service:
|
||||||
|
@ -66,14 +66,6 @@
|
||||||
dest: /usr/lib/check_mk_agent/plugins/postgres
|
dest: /usr/lib/check_mk_agent/plugins/postgres
|
||||||
mode: 0755
|
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
|
- name: install initial schema files
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
|
@ -85,14 +77,27 @@
|
||||||
- { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" }
|
- { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" }
|
||||||
|
|
||||||
- block:
|
- 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
|
- name: wait 15s for cluster to initialize
|
||||||
pause:
|
pause:
|
||||||
seconds: 15
|
seconds: 15
|
||||||
|
|
||||||
|
when: newinstance.changed
|
||||||
|
run_once: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
- name: create user for role
|
- name: create user for role
|
||||||
postgresql_user:
|
postgresql_user:
|
||||||
name: "{{ pvc_dns_database_user }}"
|
name: "{{ pvc_dns_database_user }}"
|
||||||
password: "{{ pvc_dns_database_password }}"
|
password: "{{ pvc_dns_database_password }}"
|
||||||
|
encrypted: yes
|
||||||
state: present
|
state: present
|
||||||
login_host: /run/postgresql
|
login_host: /run/postgresql
|
||||||
|
|
||||||
|
@ -124,4 +129,13 @@
|
||||||
|
|
||||||
become: yes
|
become: yes
|
||||||
become_user: postgres
|
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
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
scope: pvcdns
|
scope: pvcdns
|
||||||
namespace: /patroni
|
namespace: /patroni/
|
||||||
name: {{ ansible_hostname }}
|
name: {{ ansible_hostname }}
|
||||||
|
|
||||||
restapi:
|
restapi:
|
||||||
listen: '0.0.0.0:8008'
|
listen: '0.0.0.0:8008'
|
||||||
connect_address: '{{ ansible_fqdn }}:8008'
|
connect_address: '{{ ansible_hostname }}.{{ pvc_cluster_domain }}:8008'
|
||||||
|
|
||||||
zookeeper:
|
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:
|
bootstrap:
|
||||||
dcs:
|
dcs:
|
||||||
|
@ -25,8 +25,8 @@ bootstrap:
|
||||||
pg_hba:
|
pg_hba:
|
||||||
- local all all peer
|
- local all all peer
|
||||||
- host replication replicator 127.0.0.1/32 trust
|
- host replication replicator 127.0.0.1/32 trust
|
||||||
{% for host in groups[ansible_local.host_group] %}
|
{% for host in groups[hostvars[inventory_hostname].group_names[0]] %}
|
||||||
- host replication replicator {{ host }}.{{ ansible_domain }} trust
|
- host replication replicator {{ host }}.{{ pvc_cluster_domain }} trust
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
- host all all 0.0.0.0/0 md5
|
- host all all 0.0.0.0/0 md5
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ bootstrap:
|
||||||
|
|
||||||
postgresql:
|
postgresql:
|
||||||
listen: '0.0.0.0:5432'
|
listen: '0.0.0.0:5432'
|
||||||
connect_address: '{{ ansible_fqdn }}:5432'
|
connect_address: '{{ ansible_hostname }}.{{ pvc_cluster_domain }}:5432'
|
||||||
log_destination: 'stderr'
|
log_destination: 'stderr'
|
||||||
log_min_messages: INFO
|
log_min_messages: INFO
|
||||||
custom_conf: /etc/postgresql/postgresql.pvc.conf
|
custom_conf: /etc/postgresql/postgresql.pvc.conf
|
||||||
|
|
Loading…
Reference in New Issue