patroni: disable full configuration
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2805|20|2785|13|:-1: Output truncated. Details
gitea/ansible-roles/pipeline/head This commit looks good Details

This commit is contained in:
Jérémy Lecour 2023-06-06 10:30:08 +02:00 committed by Jérémy Lecour
parent a3ec1d6712
commit d83ae339d8
6 changed files with 91 additions and 48 deletions

View File

@ -5,4 +5,11 @@
name:
- etcd-client
- etcd-server
update_cache: yes
update_cache: yes
- name: Install python dependencies for Patroni
ansible.builtin.apt:
name:
- python3-etcd
- python3-psycopg2
when: etcd_install_dependencies_for_patroni | bool

View File

@ -3,39 +3,49 @@
# Install Patroni from backport Evolix
patroni_backport: false
# Define variable for Patroni
etcd_install_dependencies_for_patroni: True
patroni_scope: "mycluster"
patroni_name: "{{ patroni_scope }}-{{ ansible_hostname }}"
#########################################################################
# Disabled for now
# It's too much work to completely manage a Patroni cluster from Ansible
##########
# # Define variable for Patroni
# Binding host:port for the cluster (must not be localhost)
patroni_restapi_connect_address_host: "0.0.0.0"
patroni_restapi_connect_address_port: "8008"
patroni_restapi_connect_address: "{{ patroni_restapi_connect_address_host }}:{{ patroni_restapi_connect_address_port }}"
# Additional binding for health-checks…
patroni_restapi_listen_host: "127.0.0.1"
patroni_restapi_listen_port: "8008"
patroni_restapi_listen: "{{ patroni_restapi_listen_host }}:{{ patroni_restapi_listen_port }}"
# patroni_scope: "13-main"
# patroni_name: "{{ ansible_hostname }}"
patroni_postgresql_connect_address_host: "0.0.0.0"
patroni_postgresql_connect_address_port: "5432"
patroni_postgresql_connect_address: "{{ patroni_postgresql_connect_address_host }}:{{ patroni_postgresql_connect_address_port }}"
# # Binding host:port for the cluster (must not be localhost)
# patroni_restapi_connect_address_host: "0.0.0.0"
# patroni_restapi_connect_address_port: "8008"
# patroni_restapi_connect_address: "{{ patroni_restapi_connect_address_host }}:{{ patroni_restapi_connect_address_port }}"
# # Additional binding for health-checks…
# patroni_restapi_listen_host: "127.0.0.1"
# patroni_restapi_listen_port: "8008"
# patroni_restapi_listen: "{{ patroni_restapi_listen_host }}:{{ patroni_restapi_listen_port }}"
patroni_postgresql_listen_hosts:
- "127.0.0.1"
patroni_postgresql_listen_port: "5432"
patroni_postgresql_listen: "{{ patroni_postgresql_listen_hosts | join(',') }}:{{ patroni_postgresql_listen_port }}"
# patroni_postgresql_connect_address_host: "0.0.0.0"
# patroni_postgresql_connect_address_port: "5432"
# patroni_postgresql_connect_address: "{{ patroni_postgresql_connect_address_host }}:{{ patroni_postgresql_connect_address_port }}"
patroni_postgresql_datadir: "/home/{{ patroni_name }}"
patroni_postgresql_pgpass: "/tmp/{{ patroni_name }}-pgpass"
patroni_postgresql_hosts_cluster: []
patroni_postgresql_listen_ips: 127.0.0.1
patroni_postgresql_connect_ip: 127.0.0.1
patroni_postgresql_version: ''
patroni_postgresql_replication_user: 'repl'
patroni_postgresql_superuser: 'admin'
# patroni_postgresql_listen_hosts:
# - "127.0.0.1"
# patroni_postgresql_listen_port: "5432"
# patroni_postgresql_listen: "{{ patroni_postgresql_listen_hosts | join(',') }}:{{ patroni_postgresql_listen_port }}"
# Define variable for etcd
etcd_hosts: []
etcd_port: "2379"
# patroni_postgresql_datadir: "/home/{{ patroni_scope }}"
# patroni_postgresql_pgpass: "/tmp/{{ patroni_scope }}-pgpass"
# patroni_postgresql_listen_ips: 127.0.0.1
# patroni_postgresql_connect_ip: 127.0.0.1
# patroni_postgresql_version: ''
# patroni_postgresql_replication_user: 'repl'
# patroni_postgresql_superuser: 'admin'
# # Each entry must look like this :
# # { name: replication, user: foo, host: "1.2.3.4/32", hash_type: md5/scram-sha-256 }
# patroni_postgresql_hba_roles: []
# # Define variable for etcd
# etcd_hosts: []
# etcd_port: "2379"
#########################################################################

View File

@ -1,19 +1,38 @@
---
#########################################################################
# Disabled for now
# It's too much work to completely manage a Patroni cluster from Ansible
#########################################################################
# - name: Create a password for PostgreSQL repl user
# command: "apg -M LCN -n1 -m 16"
# register: patroni_postgresql_replication_password
# check_mode: no
# - name: Create a password for PostgreSQL superuser user
# command: "apg -M LCN -n1 -m 16"
# register: patroni_postgresql_superuser_password
# check_mode: no
- name: Create a password for PostgreSQL repl user
command: "apg -M LCN -n1 -m 16"
local_action:
module: ansible.builtin.command
cmd: "apg -M LCN -n1 -m 16"
register: patroni_postgresql_replication_password
check_mode: no
run_once: True
- name: Create a password for PostgreSQL superuser user
command: "apg -M LCN -n1 -m 16"
local_action:
module: ansible.builtin.command
cmd: "apg -M LCN -n1 -m 16"
register: patroni_postgresql_superuser_password
check_mode: no
run_once: True
- name: Create Patroni config file
ansible.builtin.template:
src: config.j2
dest: /etc/patroni/config.yml
src: config.yml.j2
dest: /etc/patroni/{{ patroni_scope }}.yml
owner: root
group: root
mode: "0644"

View File

@ -1,7 +1,14 @@
---
- ansible.builtin.import_tasks: backports.yml
when: patroni_backport | bool
when: patroni_backport | bool | default(False)
- ansible.builtin.import_tasks: packages.yml
- ansible.builtin.import_tasks: config.yml
#########################################################################
# Disabled for now
# It's too much work to completely manage a Patroni cluster from Ansible
##########
# - ansible.builtin.import_tasks: config.yml
#########################################################################

View File

@ -29,26 +29,26 @@ bootstrap:
checkpoint_timeout: 30
initdb:
- encoding: UTF8
- data-checksums
- encoding: UTF8
- data-checksums
pg_hba:
- host replication repl 127.0.0.1/32 md5
{% for server in groups['patroni'] %}
- host replication repl {{ hostvars[server]['postgresql_hosts_cluster'] }}/0 md5
- host replication repl 127.0.0.1/32 md5
{% for host in patroni_postgresql_replication_hosts %}
- host {{ patroni_postgresql_replication_role }} {{ patroni_postgresql_replication_user }} {{ host }} {{ patroni_postgresql_replication_hash_type }}
{% endfor %}
- host all all 0.0.0.0/0 md5
- host all all 0.0.0.0/0 md5
users:
{{ patroni_postgresql_superuser }}:
password: {{ patroni_postgresql_superuser_password.stdout }}
options:
- createrole
- createdb
- createrole
- createdb
{{ patroni_postgresql_replication_user }}:
password: {{ patroni_postgresql_replication_password.stdout }}
options:
- replication
- replication
postgresql:
listen: {{ patroni_postgresql_listen }}

View File

@ -1,5 +1,5 @@
---
- name: Restart PgBouncer
- name: restart pgbouncer
ansible.builtin.systemd:
name: pgbouncer.service
state: restarted