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

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: name:
- etcd-client - etcd-client
- etcd-server - 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 # Install Patroni from backport Evolix
patroni_backport: false 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_scope: "13-main"
patroni_restapi_connect_address_host: "0.0.0.0" # patroni_name: "{{ ansible_hostname }}"
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_connect_address_host: "0.0.0.0" # # Binding host:port for the cluster (must not be localhost)
patroni_postgresql_connect_address_port: "5432" # patroni_restapi_connect_address_host: "0.0.0.0"
patroni_postgresql_connect_address: "{{ patroni_postgresql_connect_address_host }}:{{ patroni_postgresql_connect_address_port }}" # 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: # patroni_postgresql_connect_address_host: "0.0.0.0"
- "127.0.0.1" # patroni_postgresql_connect_address_port: "5432"
patroni_postgresql_listen_port: "5432" # patroni_postgresql_connect_address: "{{ patroni_postgresql_connect_address_host }}:{{ patroni_postgresql_connect_address_port }}"
patroni_postgresql_listen: "{{ patroni_postgresql_listen_hosts | join(',') }}:{{ patroni_postgresql_listen_port }}"
patroni_postgresql_datadir: "/home/{{ patroni_name }}" # patroni_postgresql_listen_hosts:
patroni_postgresql_pgpass: "/tmp/{{ patroni_name }}-pgpass" # - "127.0.0.1"
patroni_postgresql_hosts_cluster: [] # patroni_postgresql_listen_port: "5432"
patroni_postgresql_listen_ips: 127.0.0.1 # patroni_postgresql_listen: "{{ patroni_postgresql_listen_hosts | join(',') }}:{{ patroni_postgresql_listen_port }}"
patroni_postgresql_connect_ip: 127.0.0.1
patroni_postgresql_version: ''
patroni_postgresql_replication_user: 'repl'
patroni_postgresql_superuser: 'admin'
# Define variable for etcd # patroni_postgresql_datadir: "/home/{{ patroni_scope }}"
etcd_hosts: [] # patroni_postgresql_pgpass: "/tmp/{{ patroni_scope }}-pgpass"
etcd_port: "2379" # 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 - 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 register: patroni_postgresql_replication_password
check_mode: no run_once: True
- name: Create a password for PostgreSQL superuser user - 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 register: patroni_postgresql_superuser_password
check_mode: no run_once: True
- name: Create Patroni config file - name: Create Patroni config file
ansible.builtin.template: ansible.builtin.template:
src: config.j2 src: config.yml.j2
dest: /etc/patroni/config.yml dest: /etc/patroni/{{ patroni_scope }}.yml
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"

View file

@ -1,7 +1,14 @@
--- ---
- ansible.builtin.import_tasks: backports.yml - 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: 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 checkpoint_timeout: 30
initdb: initdb:
- encoding: UTF8 - encoding: UTF8
- data-checksums - data-checksums
pg_hba: pg_hba:
- host replication repl 127.0.0.1/32 md5 - host replication repl 127.0.0.1/32 md5
{% for server in groups['patroni'] %} {% for host in patroni_postgresql_replication_hosts %}
- host replication repl {{ hostvars[server]['postgresql_hosts_cluster'] }}/0 md5 - host {{ patroni_postgresql_replication_role }} {{ patroni_postgresql_replication_user }} {{ host }} {{ patroni_postgresql_replication_hash_type }}
{% endfor %} {% endfor %}
- host all all 0.0.0.0/0 md5 - host all all 0.0.0.0/0 md5
users: users:
{{ patroni_postgresql_superuser }}: {{ patroni_postgresql_superuser }}:
password: {{ patroni_postgresql_superuser_password.stdout }} password: {{ patroni_postgresql_superuser_password.stdout }}
options: options:
- createrole - createrole
- createdb - createdb
{{ patroni_postgresql_replication_user }}: {{ patroni_postgresql_replication_user }}:
password: {{ patroni_postgresql_replication_password.stdout }} password: {{ patroni_postgresql_replication_password.stdout }}
options: options:
- replication - replication
postgresql: postgresql:
listen: {{ patroni_postgresql_listen }} listen: {{ patroni_postgresql_listen }}

View file

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