patroni-postgresql-cluster (#13)

* Описана инфрастуктура кластера

* Добавлена роль etcd

* Добавлена роль haproxy

* Добавлена роль keepalived

* Добавлена роль ntp_install

* Добавлена роль patroni

* Добавлена групповые переменные

---------

Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
github-actions[bot]
2024-06-18 10:37:21 +03:00
committed by GitHub
parent 5b7920bdca
commit f8fe304cd9
43 changed files with 930 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
---
- name: Перезапускаю etcd.service
ansible.builtin.systemd:
name: etcd.service
state: restarted
enabled: true
daemon_reload: true

View File

@@ -0,0 +1,3 @@
---
- name: Наливаю юнит файл
ansible.builtin.import_tasks: service.yml

View File

@@ -0,0 +1,21 @@
---
- name: Задаю права для директории
ansible.builtin.file:
path: /var/lib/etcd
state: directory
recurse: true
owner: "{{ patroni_uid }}"
group: "{{ patroni_uid }}"
- name: Наливаю юнит файл etcd
ansible.builtin.template:
src: etcd.service.j2
dest: /etc/systemd/system/etcd.service
notify:
- Перезапускаю etcd.service
- name: Настраиваю etcd.service
ansible.builtin.systemd:
name: etcd.service
state: started
enabled: true

View File

@@ -0,0 +1,34 @@
[Unit]
Description=etcd
Requires=docker.service
After=docker.service
[Service]
User={{ patroni_user }}
Restart=always
Environment="TOKEN={{ lookup('password', 'secrets/patroni-postgresql/etcd_cluster_token length=64') }}"
Environment="CLUSTER=patroni-postgresql-01=http://10.0.75.111:2380,patroni-postgresql-02=http://10.0.75.112:2380,patroni-postgresql-03=http://10.0.75.113:2380"
ExecStartPre=-/usr/bin/docker rm -f etcd
ExecStart=/usr/bin/docker run \
--rm \
--user {{ patroni_uid }}:{{ patroni_uid }} \
--publish 2379:2379 \
--publish 2380:2380 \
--name etcd \
--volume=/var/lib/etcd:/etcd-data \
quay.io/coreos/etcd:{{ etcd_version }} \
/usr/local/bin/etcd \
--data-dir=/etcd-data \
--name {{ inventory_hostname }} \
--initial-advertise-peer-urls http://{{ ansible_host }}:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--advertise-client-urls http://{{ ansible_host }}:2379 \
--listen-client-urls http://0.0.0.0:2379 \
--initial-cluster ${CLUSTER} \
--initial-cluster-state new \
--initial-cluster-token ${TOKEN} \
--enable-v2=true
ExecStop=/usr/bin/docker stop -t 10 etcd
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1 @@
etcd_version: v3.5.14