diff --git a/group_vars/all/plain.yml b/group_vars/all/plain.yml index 75c089a..387717a 100644 --- a/group_vars/all/plain.yml +++ b/group_vars/all/plain.yml @@ -222,3 +222,5 @@ prometheus_alert_pg_replication_lag: 120 upstream_dns_servers: - 185.12.64.1 - 185.12.64.2 + +wordpress_haproxy_admin_password: "{{ wordpress_haproxy_admin_password_vault | default('haproxy-admin') }}" diff --git a/group_vars/connect_wordpress/main.yml b/group_vars/connect_wordpress/main.yml index ede22ad..07151e0 100644 --- a/group_vars/connect_wordpress/main.yml +++ b/group_vars/connect_wordpress/main.yml @@ -1,6 +1,6 @@ --- -connect_wordpress_maria_host: "{{ shared_service_maria_hostname }}" +connect_wordpress_maria_host: "mariaproxy" connect_wordpress_maria_database: "{{ stage }}_{{ tenant_id }}_{{ cluster_name }}_connect_wordpress" connect_wordpress_maria_username: "{{ connect_wordpress_maria_database }}" connect_wordpress_maria_password: "connect-wordpress-maria-admin" diff --git a/group_vars/stage_dev/plain.yml b/group_vars/stage_dev/plain.yml index 4b6e55c..4261a7c 100644 --- a/group_vars/stage_dev/plain.yml +++ b/group_vars/stage_dev/plain.yml @@ -58,12 +58,18 @@ shared_service_pg_slave_ip: "{{ stage_server_infos | list | first | default('-') }}" -shared_service_maria_ip: "{{ stage_server_infos +shared_service_maria_1st_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-maria-01' ) | map(attribute='private_ip') | list | first | default('-') }}" +shared_service_maria_2nd_ip: "{{ stage_server_infos + | selectattr('name', 'match', stage + '-maria-02' ) + | map(attribute='private_ip') + | list + | first + | default('-') }}" shared_service_keycloak_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-keycloak-01' ) | map(attribute='private_ip') @@ -139,7 +145,8 @@ shared_service_management_ip: "{{ stage_server_infos shared_service_kube_ip: "{{ stage_private_ingress_loadbalancer_ip | default('-') }}" -shared_service_maria_hostname: "{{ stage }}-maria-01" +shared_service_maria_1st_hostname: "{{ stage }}-maria-01" +shared_service_maria_2nd_hostname: "{{ stage }}-maria-02" shared_service_postgres_01_hostname: "{{ stage }}-postgres-01" shared_service_elastic_stack_01_hostname: "{{ stage }}-elastic-stack-elastic-01" shared_service_elastic_stack_02_hostname: "{{ stage }}-elastic-stack-elastic-02" @@ -193,8 +200,12 @@ shared_service_hosts: [ name: "{{ shared_service_elastic_stack_logstash_01_hostname }}" }, { - ip: "{{ shared_service_maria_ip }}", - name: "{{ shared_service_maria_hostname }}" + ip: "{{ shared_service_maria_1st_ip }}", + name: "{{ shared_service_maria_1st_hostname }}" + }, + { + ip: "{{ shared_service_maria_2nd_ip }}", + name: "{{ shared_service_maria_2nd_hostname }}" }, { ip: "{{ shared_service_pg_master_ip }}", diff --git a/group_vars/stage_prodnso/plain.yml b/group_vars/stage_prodnso/plain.yml index 544e575..bd1ee7b 100644 --- a/group_vars/stage_prodnso/plain.yml +++ b/group_vars/stage_prodnso/plain.yml @@ -58,12 +58,18 @@ shared_service_pg_slave_ip: "{{ stage_server_infos | list | first | default('-') }}" -shared_service_maria_ip: "{{ stage_server_infos +shared_service_maria_1st_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-maria-01' ) | map(attribute='private_ip') | list | first | default('-') }}" +shared_service_maria_2nd_ip: "{{ stage_server_infos + | selectattr('name', 'match', stage + '-maria-02' ) + | map(attribute='private_ip') + | list + | first + | default('-') }}" shared_service_keycloak_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-keycloak-01' ) | map(attribute='private_ip') @@ -139,7 +145,8 @@ shared_service_management_ip: "{{ stage_server_infos shared_service_kube_ip: "{{ stage_private_ingress_loadbalancer_ip | default('-') }}" -shared_service_maria_hostname: "{{ stage }}-maria-01" +shared_service_maria_1st_hostname: "{{ stage }}-maria-01" +shared_service_maria_2nd_hostname: "{{ stage }}-maria-02" shared_service_postgres_01_hostname: "{{ stage }}-postgres-01" shared_service_elastic_stack_01_hostname: "{{ stage }}-elastic-stack-elastic-01" shared_service_elastic_stack_02_hostname: "{{ stage }}-elastic-stack-elastic-02" @@ -193,8 +200,12 @@ shared_service_hosts: [ name: "{{ shared_service_elastic_stack_logstash_01_hostname }}" }, { - ip: "{{ shared_service_maria_ip }}", - name: "{{ shared_service_maria_hostname }}" + ip: "{{ shared_service_maria_1st_ip }}", + name: "{{ shared_service_maria_1st_hostname }}" + }, + { + ip: "{{ shared_service_maria_2nd_ip }}", + name: "{{ shared_service_maria_2nd_hostname }}" }, { ip: "{{ shared_service_pg_master_ip }}", diff --git a/group_vars/stage_qa/plain.yml b/group_vars/stage_qa/plain.yml index b53a187..7f3f779 100644 --- a/group_vars/stage_qa/plain.yml +++ b/group_vars/stage_qa/plain.yml @@ -58,12 +58,18 @@ shared_service_pg_slave_ip: "{{ stage_server_infos | list | first | default('-') }}" -shared_service_maria_ip: "{{ stage_server_infos +shared_service_maria_1st_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-maria-01' ) | map(attribute='private_ip') | list | first | default('-') }}" +shared_service_maria_2nd_ip: "{{ stage_server_infos + | selectattr('name', 'match', stage + '-maria-02' ) + | map(attribute='private_ip') + | list + | first + | default('-') }}" shared_service_keycloak_ip: "{{ stage_server_infos | selectattr('name', 'match', stage + '-keycloak-01' ) | map(attribute='private_ip') @@ -139,7 +145,8 @@ shared_service_management_ip: "{{ stage_server_infos shared_service_kube_ip: "{{ stage_private_ingress_loadbalancer_ip | default('-') }}" -shared_service_maria_hostname: "{{ stage }}-maria-01" +shared_service_maria_1st_hostname: "{{ stage }}-maria-01" +shared_service_maria_2nd_hostname: "{{ stage }}-maria-02" shared_service_postgres_01_hostname: "{{ stage }}-postgres-01" shared_service_elastic_stack_01_hostname: "{{ stage }}-elastic-stack-elastic-01" shared_service_elastic_stack_02_hostname: "{{ stage }}-elastic-stack-elastic-02" @@ -193,10 +200,13 @@ shared_service_hosts: [ name: "{{ shared_service_elastic_stack_logstash_01_hostname }}" }, { - ip: "{{ shared_service_maria_ip }}", - name: "{{ shared_service_maria_hostname }}" + ip: "{{ shared_service_maria_1st_ip }}", + name: "{{ shared_service_maria_1st_hostname }}" }, { + ip: "{{ shared_service_maria_2nd_ip }}", + name: "{{ shared_service_maria_2nd_hostname }}" + }, ip: "{{ shared_service_pg_master_ip }}", name: "{{ shared_service_postgres_01_hostname }}" }, diff --git a/roles/connect_wordpress/vars/main.yml b/roles/connect_wordpress/vars/main.yml index e4c9459..3c00d59 100644 --- a/roles/connect_wordpress/vars/main.yml +++ b/roles/connect_wordpress/vars/main.yml @@ -27,6 +27,23 @@ wordpress_docker: { }, ], services: [ + { + name: "mariaproxy", + image_name: "haproxytech/haproxy-alpine", + image_version: "2.2.24", + ports: [ + { + "external": "16666", + "internal": "6666", + }, + ], + volumes: [ + '"./config/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"', + ], + networks: [ + '"back-tier"', + ], + }, { name: "{{ wordpress_id }}", image_name: "{{ wordpress_image_name }}", diff --git a/templates/wordpress/config/haproxy.cfg.j2 b/templates/wordpress/config/haproxy.cfg.j2 new file mode 100644 index 0000000..2cc8549 --- /dev/null +++ b/templates/wordpress/config/haproxy.cfg.j2 @@ -0,0 +1,32 @@ +global + user haproxy + group haproxy + daemon + maxconn 4096 + +defaults + mode tcp + balance roundrobin + timeout client 30000ms + timeout server 30000ms + timeout connect 3000ms + retries 3 + +frontend stats + bind *:6666 + mode http + stats enable + stats uri /haproxystats + stats show-node + stats auth {{ wordpress_haproxy_admin_username | default('haproxy-admin') }}:{{ wordpress_haproxy_admin_password }} + stats refresh 10s + +frontend wordpress_backend + bind 0.0.0.0:3306 + default_backend mariadb_servers + +backend mariadb_servers + option tcp-check + server maria-01 {{ shared_service_maria_1st_hostname }}:3306 maxconn 2048 check +# TODO - disabled till M-M-replication is in place +# server maria-02 {{ shared_service_maria_2nd_hostname }}:3306 maxconn 2048 check