mirror of
https://github.com/batonogov/learn-devops.git
synced 2025-12-01 17:53:02 +00:00
patroni-postgresql-cluster (#13)
* Описана инфрастуктура кластера * Добавлена роль etcd * Добавлена роль haproxy * Добавлена роль keepalived * Добавлена роль ntp_install * Добавлена роль patroni * Добавлена групповые переменные --------- Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
committed by
GitHub
parent
5b7920bdca
commit
f8fe304cd9
8
ansible/roles/haproxy/handlers/main.yml
Normal file
8
ansible/roles/haproxy/handlers/main.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# handlers file for haproxy
|
||||
- name: Перезапускаю haproxy.service
|
||||
ansible.builtin.systemd:
|
||||
name: haproxy.service
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
13
ansible/roles/haproxy/tasks/config.yml
Normal file
13
ansible/roles/haproxy/tasks/config.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Создаю директорию /usr/local/etc/haproxy/
|
||||
ansible.builtin.file:
|
||||
path: /usr/local/etc/haproxy/
|
||||
state: directory
|
||||
|
||||
- name: Наливаю haproxy.cfg
|
||||
ansible.builtin.template:
|
||||
src: haproxy.cfg.j2
|
||||
dest: "/usr/local/etc/haproxy/haproxy.cfg"
|
||||
mode: "755"
|
||||
notify:
|
||||
- Перезапускаю haproxy.service
|
||||
13
ansible/roles/haproxy/tasks/install.yml
Normal file
13
ansible/roles/haproxy/tasks/install.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Наливаю юнит файл haproxy
|
||||
ansible.builtin.template:
|
||||
src: haproxy.service.j2
|
||||
dest: /etc/systemd/system/haproxy.service
|
||||
notify:
|
||||
- Перезапускаю haproxy.service
|
||||
|
||||
- name: Настраиваю haproxy.service
|
||||
ansible.builtin.systemd:
|
||||
name: haproxy.service
|
||||
state: started
|
||||
enabled: true
|
||||
7
ansible/roles/haproxy/tasks/main.yml
Normal file
7
ansible/roles/haproxy/tasks/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# tasks file for haproxy
|
||||
- name: Копирую конфигурацию haproxy
|
||||
ansible.builtin.import_tasks: config.yml
|
||||
|
||||
- name: Устанавливаю haproxy
|
||||
ansible.builtin.import_tasks: install.yml
|
||||
36
ansible/roles/haproxy/templates/haproxy.cfg.j2
Normal file
36
ansible/roles/haproxy/templates/haproxy.cfg.j2
Normal file
@@ -0,0 +1,36 @@
|
||||
global
|
||||
maxconn 100
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode tcp
|
||||
retries 2
|
||||
timeout client 30m
|
||||
timeout connect 4s
|
||||
timeout server 30m
|
||||
timeout check 5s
|
||||
|
||||
listen stats
|
||||
mode http
|
||||
bind *:7000
|
||||
stats enable
|
||||
stats uri /
|
||||
|
||||
listen patroni-postgresql-primary
|
||||
bind *:5000
|
||||
option httpchk OPTIONS /master
|
||||
http-check expect status 200
|
||||
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
|
||||
server 10.0.75.111 10.0.75.111:5432 maxconn 100 check port 8008
|
||||
server 10.0.75.112 10.0.75.112:5432 maxconn 100 check port 8008
|
||||
server 10.0.75.113 10.0.75.113:5432 maxconn 100 check port 8008
|
||||
|
||||
listen patroni-postgresql-standbys
|
||||
balance roundrobin
|
||||
bind *:5001
|
||||
option httpchk OPTIONS /replica
|
||||
http-check expect status 200
|
||||
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
|
||||
server 10.0.75.111 10.0.75.111:5432 maxconn 100 check port 8008
|
||||
server 10.0.75.112 10.0.75.112:5432 maxconn 100 check port 8008
|
||||
server 10.0.75.113 10.0.75.113:5432 maxconn 100 check port 8008
|
||||
21
ansible/roles/haproxy/templates/haproxy.service.j2
Normal file
21
ansible/roles/haproxy/templates/haproxy.service.j2
Normal file
@@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=haproxy
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
ExecStartPre=-/usr/bin/docker rm -f haproxy
|
||||
ExecStart=/usr/bin/docker run \
|
||||
--rm \
|
||||
--publish 5000:5000 \
|
||||
--publish 5001:5001 \
|
||||
--publish 7000:7000 \
|
||||
--volume /usr/local/etc/haproxy/:/usr/local/etc/haproxy/:ro \
|
||||
--sysctl net.ipv4.ip_unprivileged_port_start=0 \
|
||||
--name haproxy \
|
||||
haproxy:{{ haproxy_version }}
|
||||
ExecStop=/usr/bin/docker stop -t 10 haproxy
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
3
ansible/roles/haproxy/vars/main.yml
Normal file
3
ansible/roles/haproxy/vars/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
# vars file for haproxy
|
||||
haproxy_version: 3.0.2-alpine
|
||||
Reference in New Issue
Block a user