pvc-ansible/roles/pvc/tasks/patroni/main.yml

100 lines
2.1 KiB
YAML
Raw Normal View History

2019-06-12 21:06:06 -04:00
---
- set_fact:
package_list:
- python3-psycopg2
2019-06-12 21:06:06 -04:00
- python3-kazoo
- python-psycopg2
- python-kazoo
2019-06-12 21:06:06 -04:00
- patroni
- postgresql-11
when: debian_version|int <= 10
2021-07-18 22:13:09 -04:00
- set_fact:
package_list:
- python3-psycopg2
- python3-kazoo
- patroni
2021-12-15 02:22:10 -05:00
- postgresql
when: debian_version|int >= 11
2021-07-18 22:13:09 -04:00
- name: install patroni packages via apt
apt:
name: "{{ package_list }}"
2019-06-12 21:06:06 -04:00
state: latest
update-cache: yes
- name: stop and disable postgresql
service:
name: "{{ item }}"
state: stopped
enabled: no
with_items:
- postgresql
- postgresql@11-main
when: newhost is defined and newhost
- name: remove obsolete database directories
file:
dest: "{{ item }}"
state: absent
with_items:
- /etc/postgresql/11
- /var/lib/postgresql/11
when: newhost is defined and newhost
- name: create patroni database directory
file:
dest: /var/lib/postgresql/patroni/pvc
state: directory
owner: postgres
mode: 0700
when: newhost is defined and newhost
- name: install postgresql customization configuration file
template:
src: patroni/postgresql.pvc.conf.j2
dest: /etc/postgresql/postgresql.pvc.conf
owner: postgres
group: sudo
mode: 0640
notify: restart patroni
- name: install patroni configuration file
template:
src: patroni/patroni.yml.j2
dest: /etc/patroni/config.yml
owner: postgres
group: postgres
mode: 0640
notify: restart patroni
- name: install check_mk agent check
copy:
src: patroni/postgres
dest: /usr/lib/check_mk_agent/plugins/postgres
mode: 0755
- name: install initial schema files
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: postgres
group: sudo
mode: 0640
with_items:
- { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" }
- include: patroni/bootstrap.yml
run_once: yes
when: bootstrap is defined and bootstrap
- name: start but disable services (managed by PVC)
2019-06-12 21:06:06 -04:00
service:
name: "{{ item }}"
2019-06-12 21:06:06 -04:00
state: started
enabled: no
2019-06-12 21:06:06 -04:00
with_items:
- patroni
- meta: flush_handlers