WIP: use the systemd unit and config conventions of Patroni 3
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2798|13|2785|8|:-1: Output truncated.
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Jérémy Lecour 2023-05-12 18:12:06 +02:00 committed by Jérémy Lecour
parent 921e384358
commit 5cb3762080
3 changed files with 24 additions and 48 deletions

View file

@ -2,25 +2,18 @@
- name: Create a password for PostgreSQL repl user - name: Create a password for PostgreSQL repl user
command: "apg -M LCN -n1 -m 16" command: "apg -M LCN -n1 -m 16"
register: postgresql_replication_password register: patroni_postgresql_replication_password
check_mode: no
- name: Create a password for PostgreSQL superuser user - name: Create a password for PostgreSQL superuser user
command: "apg -M LCN -n1 -m 16" command: "apg -M LCN -n1 -m 16"
register: postgresql_superuser_password register: patroni_postgresql_superuser_password
check_mode: no
- name: Create Patroni config file - name: Create Patroni config file
ansible.builtin.template: ansible.builtin.template:
src: patroni.conf.j2 src: config.j2
dest: /etc/patroni/config-{{ cluster_name }}.yml dest: /etc/patroni/config.yml
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"
- mane: Create Systemd Unit for Patroni
ansible.builtin.template:
src: patroni.service.j2
dest: /etc/systemd/system/patroni.service
owner: root
group: root
mode: "0644"

View file

@ -1,9 +1,9 @@
scope: {{ cluster_name }} scope: {{ patroni_scope }}
name: {{ cluster_name_host }} name: {{ patroni_name }}
restapi: restapi:
listen: {{ patroni_restapi_listen }}:{{ patroni_restapi_port }} listen: {{ patroni_restapi_listen }}
connect_address: {{ patroni_restapi_listen }}:{{ patroni_restapi_port }} connect_address: {{ patroni_restapi_connect_address }}
etcd: etcd:
hosts: hosts:
@ -40,29 +40,29 @@ bootstrap:
- host all all 0.0.0.0/0 md5 - host all all 0.0.0.0/0 md5
users: users:
{{ postgresql_superuser }}: {{ patroni_postgresql_superuser }}:
password: {{ postgresql_superuser_password.stdout }} password: {{ patroni_postgresql_superuser_password.stdout }}
options: options:
- createrole - createrole
- createdb - createdb
{{ postgresql_replication_user }}: {{ patroni_postgresql_replication_user }}:
password: {{ postgresql_replication_password.stdout }} password: {{ patroni_postgresql_replication_password.stdout }}
options: options:
- replication - replication
postgresql: postgresql:
listen: {{ postgresql_listen_ips }}:{{ postgresql_port }} listen: {{ patroni_postgresql_listen }}
connect_address: {{ postgresql_connect_ip }}:{{ postgresql_port }} connect_address: {{ patroni_postgresql_connect_address }}
bin_dir: /usr/lib/postgresql/{{ postgresql_version }}/bin/ bin_dir: /usr/lib/postgresql/{{ patroni_postgresql_version }}/bin/
data_dir: /home/{{ cluster_name_host }} data_dir: {{ patroni_postgresql_datadir }}
pgpass: /tmp/{{ cluster_name_host }}-pgpass pgpass: {{ patroni_postgresql_pgpass }}
authentication: authentication:
replication: replication:
username: {{ postgresql_replication_user }} username: {{ patroni_postgresql_replication_user }}
password: {{ postgresql_replication_password.stdout }} password: {{ patroni_postgresql_replication_password.stdout }}
superuser: superuser:
username: {{ postgresql_superuser }} username: {{ patroni_postgresql_superuser }}
password: {{ postgresql_superuser_password.stdout }} password: {{ patroni_postgresql_superuser_password.stdout }}
parameters: parameters:
unix_socket_directories: '/tmp' unix_socket_directories: '/tmp'

View file

@ -1,17 +0,0 @@
[Unit]
Description=Runners to orchestrate a high-availability PostgreSQL
After=syslog.target network.target
[Service]
Type=simple
User=postgres
Group=postgres
ExecStart=/usr/bin/patroni /etc/patroni/config-{{ cluster_name }}.yml
KillMode=process
TimeoutSec=30
Restart=no
[Install]
WantedBy=multi-user.targ