Compare commits

...

8 commits
stable ... etcd

Author SHA1 Message Date
Eric Morino a31b868599 change patroni template
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2798|0|2798|0|:zzz:
gitea/ansible-roles/pipeline/head This commit looks good
2024-04-18 14:26:16 +02:00
Eric Morino 7eb4bda74f Fix variable bin_dir patroni configuration
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2796|6|2790|6|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/6//ansiblelint">Evolix » ansible-roles » etcd #6</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 17:09:52 +02:00
Eric Morino 6f68d17b95 add create etcd datadir
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2796|5|2791|5|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/5//ansiblelint">Evolix » ansible-roles » etcd #5</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:56:37 +02:00
Eric Morino 953c7fc48f change variable in templabe by etcd_listen_ip
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2796|5|2791|4|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/4//ansiblelint">Evolix » ansible-roles » etcd #4</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:50:26 +02:00
Eric Morino 7978edc7b2 add patroni_install_dependencies by default
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2795|5|2790|7|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/3//ansiblelint">Evolix » ansible-roles » etcd #3</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:46:29 +02:00
Eric Morino c930563ce8 add template conf etcd
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2797|4|2793|4|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/2//ansiblelint">Evolix » ansible-roles » etcd #2</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:23:48 +02:00
Eric Morino 851c2ab575 Add task main.yml
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2797|6|2791|6|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/etcd/1//ansiblelint">Evolix » ansible-roles » etcd #1</a>
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:23:04 +02:00
Eric Morino 49cd3fb5b0 création role etcd
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2797|0|2797|0|:zzz:
gitea/ansible-roles/pipeline/head This commit looks good
2023-04-03 16:04:50 +02:00
8 changed files with 71 additions and 8 deletions

3
etcd/README.md Normal file
View file

@ -0,0 +1,3 @@
# Etcd
Installation and basic configuration of etcd for integrate in a Patroni and PostgreSQL cluster.

12
etcd/defaults/main.yml Normal file
View file

@ -0,0 +1,12 @@
---
# Define variable for etcd
patroni_install_dependencies: "True"
etcd_listen_ip: []
etcd_cluster_ips: []
etcd_client_port: "2379"
etcd_peer_port: "2380"
etcd_local_name : ""
etcd_cluster_token : ""
etcd_datadir : "/var/lib/etcd/{{ etcd_cluster_token }}"
etcd_initial_cluster: ""

19
etcd/tasks/config.yml Normal file
View file

@ -0,0 +1,19 @@
---
- name: Create etcd config file
ansible.builtin.template:
src: etcd.j2
dest: /etc/default/etcd
owner: root
group: root
mode: "0644"
- name: Create etcd datadir
ansible.builtin.file:
name: "/var/lib/etcd/{{ etcd_cluster_token }}"
state: directory
owner: etcd
group: etcd
mode: "0700"

4
etcd/tasks/main.yml Normal file
View file

@ -0,0 +1,4 @@
---
- ansible.builtin.import_tasks: packages.yml
- ansible.builtin.import_tasks: config.yml

15
etcd/tasks/packages.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: Install etcd client / server package
ansible.builtin.apt:
name:
- etcd-client
- etcd-server
update_cache: yes
- name: Install python dependencies for Patroni
ansible.builtin.apt:
name:
- python3-etcd
- python3-psycopg2
when: patroni_install_dependencies | bool

10
etcd/templates/etcd.j2 Normal file
View file

@ -0,0 +1,10 @@
ETCD_NAME="{{ etcd_local_name }}"
ETCD_DATA_DIR="{{ etcd_datadir }}"
ETCD_LOG_OUTPUTS="stdout"
ETCD_LISTEN_PEER_URLS="http://{{ etcd_listen_ip }}:{{ etcd_peer_port }}"
ETCD_LISTEN_CLIENT_URLS="http://localhost:{{ etcd_client_port }},http://{{ etcd_listen_ip }}:{{ etcd_client_port }}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://{{ etcd_listen_ip }}:{{ etcd_peer_port }}"
ETCD_INITIAL_CLUSTER="{{ etcd_initial_cluster }},"
ETCD_ADVERTISE_CLIENT_URLS="http://{{ etcd_listen_ip }}:{{ etcd_client_port }}"
ETCD_INITIAL_CLUSTER_TOKEN="{{ etcd_cluster_token }}"
ETCD_INITIAL_CLUSTER_STATE="new"

View file

@ -4,4 +4,4 @@
when: patroni_backport | bool
- ansible.builtin.import_tasks: packages.yml
- ansible.builtin.import_tasks: config.yml
#- ansible.builtin.import_tasks: config.yml

View file

@ -1,5 +1,5 @@
scope: {{ cluster_name }}
name: {{ cluster_name_host }}
name: {{ inventory_hostname }}
restapi:
listen: {{ patroni_restapi_listen }}:{{ patroni_restapi_port }}
@ -33,11 +33,11 @@ bootstrap:
- data-checksums
pg_hba:
- host replication repl 127.0.0.1/32 md5
- host replication repl 127.0.0.1/32 scram-sha-256
{% for server in groups['patroni'] %}
- host replication repl {{ hostvars[server]['postgresql_hosts_cluster'] }}/0 md5
- host replication repl {{ hostvars[server]['postgresql_hosts_cluster'] }}/0 scram-sha-256
{% endfor %}
- host all all 0.0.0.0/0 md5
- host all all 0.0.0.0/0 scram-sha-256
users:
{{ postgresql_superuser }}:
@ -53,9 +53,9 @@ bootstrap:
postgresql:
listen: {{ postgresql_host }}:{{ postgresql_port }}
connect_address: {{ postgresql_host }}:{{ postgresql_port }}
bin_dir: /var/lib/postgresql/{{ postgresql_version }}/bin/
data_dir: /home/{{ cluster_name_host }}
pgpass: /tmp/{{ cluster_name_host }}-pgpass
bin_dir: /usr/lib/postgresql/{{ postgresql_version }}/bin/
data_dir: /srv/{{ cluster_name }}
pgpass: /tmp/{{ cluster_name }}-pgpass
authentication:
replication:
username: {{ postgresql_replication_user }}