-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: VIP dictionary and GCP haproxy
- Loading branch information
1 parent
353abe1
commit c81d58f
Showing
9 changed files
with
177 additions
and
159 deletions.
There are no files selected for viewing
309 changes: 156 additions & 153 deletions
309
roles/sap_ha_pacemaker_cluster/tasks/platform/preconfigure_cloud_gcp_ce_vm.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,155 +1,158 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--- | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Install haproxy" | ||
ansible.builtin.package: | ||
name: haproxy | ||
state: present | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Check if haproxy service template exists" | ||
ansible.builtin.stat: | ||
path: /etc/systemd/system/[email protected] | ||
register: __sap_ha_pacemaker_cluster_register_haproxy_template | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy service template" | ||
ansible.builtin.copy: | ||
dest: /etc/systemd/system/[email protected] | ||
remote_src: true | ||
src: /usr/lib/systemd/system/haproxy.service | ||
mode: '0644' | ||
when: | ||
- not __sap_ha_pacemaker_cluster_register_haproxy_template.stat.exists | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Update haproxy service template description" | ||
ansible.builtin.lineinfile: | ||
backup: true | ||
path: /etc/systemd/system/[email protected] | ||
regexp: '^Description=' | ||
line: 'Description=HAProxy Load Balancer %i' | ||
state: present | ||
insertafter: '^[Unit]$' | ||
notify: "systemd daemon-reload" | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Update haproxy service template environment" | ||
ansible.builtin.lineinfile: | ||
backup: true | ||
path: /etc/systemd/system/[email protected] | ||
regexp: '^Environment=' | ||
line: 'Environment="CONFIG=/etc/haproxy/haproxy-%i.cfg" "PIDFILE=/run/haproxy-%i.pid"' | ||
state: present | ||
insertafter: '^[Service]$' | ||
notify: "systemd daemon-reload" | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Define healthcheck details for HANA" | ||
ansible.builtin.set_fact: | ||
__sap_ha_pacemaker_cluster_healthcheck_list_hana: | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_primary_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_primary_port }}" | ||
# If no custom port is defined, calculate the port for the secondary | ||
# by adding 10, to avoid a conflict with the port for the primary hc port. | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_secondary_id }}" | ||
port: >- | ||
{% if sap_ha_pacemaker_cluster_vip_hana_secondary_ip_address | length > 0 -%} | ||
{{ sap_ha_pacemaker_cluster_healthcheck_hana_secondary_port }} | ||
{%- else %}0{%- endif %} | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Define healthcheck details for NW ASCS/ERS" | ||
ansible.builtin.set_fact: | ||
__sap_ha_pacemaker_cluster_healthcheck_list_ascs: | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ascs_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ascs_port }}" | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ers_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ers_port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs') | length > 0 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy config for HANA instances" | ||
ansible.builtin.blockinfile: | ||
backup: false | ||
create: true | ||
path: "/etc/haproxy/haproxy-{{ haproxy_item.name }}.cfg" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
marker: "# {mark} Created by Ansible role sap_ha_pacemaker_cluster" | ||
block: | | ||
global | ||
chroot /var/lib/haproxy | ||
pidfile /var/run/haproxy-%i.pid | ||
user haproxy | ||
group haproxy | ||
daemon | ||
defaults | ||
mode tcp | ||
log global | ||
option dontlognull | ||
option redispatch | ||
retries 3 | ||
timeout queue 1m | ||
timeout connect 10s | ||
timeout client 1m | ||
timeout server 1m | ||
timeout check 10s | ||
maxconn 3000 | ||
# Listener for SAP healthcheck | ||
listen healthcheck | ||
bind *:{{ haproxy_item.port }} | ||
loop: "{{ __sap_ha_pacemaker_cluster_healthcheck_list_hana }}" | ||
loop_control: | ||
loop_var: haproxy_item | ||
label: "{{ haproxy_item.name }}: {{ haproxy_item.port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 | ||
- haproxy_item.port | length > 4 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy config for NWAS ASCS/ERS instances" | ||
ansible.builtin.blockinfile: | ||
create: true | ||
path: "/etc/haproxy/haproxy-{{ haproxy_item.name }}.cfg" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
marker: "# {mark} Created by Ansible role sap_ha_pacemaker_cluster" | ||
block: | | ||
global | ||
chroot /var/lib/haproxy | ||
pidfile /var/run/haproxy-%i.pid | ||
user haproxy | ||
group haproxy | ||
daemon | ||
defaults | ||
mode tcp | ||
log global | ||
option dontlognull | ||
option redispatch | ||
retries 3 | ||
timeout queue 1m | ||
timeout connect 10s | ||
timeout client 1m | ||
timeout server 1m | ||
timeout check 10s | ||
maxconn 3000 | ||
# Listener for SAP healthcheck | ||
listen healthcheck | ||
bind *:{{ haproxy_item.port }} | ||
loop: "{{ __sap_ha_pacemaker_cluster_healthcheck_list_ascs }}" | ||
loop_control: | ||
loop_var: haproxy_item | ||
label: "{{ haproxy_item.name }}: {{ haproxy_item.port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs') | length > 0 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Ensure that haproxy service is running" | ||
ansible.builtin.service: | ||
name: haproxy | ||
enabled: false | ||
state: started | ||
- name: "SAP HA Install Pacemaker - GCP CE VM - haproxy block" | ||
when: sap_ha_pacemaker_cluster_vip_method == 'gcp_nlb_reserved_ip_haproxy' | ||
block: | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Install haproxy" | ||
ansible.builtin.package: | ||
name: haproxy | ||
state: present | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Check if haproxy service template exists" | ||
ansible.builtin.stat: | ||
path: /etc/systemd/system/[email protected] | ||
register: __sap_ha_pacemaker_cluster_register_haproxy_template | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy service template" | ||
ansible.builtin.copy: | ||
dest: /etc/systemd/system/[email protected] | ||
remote_src: true | ||
src: /usr/lib/systemd/system/haproxy.service | ||
mode: '0644' | ||
when: | ||
- not __sap_ha_pacemaker_cluster_register_haproxy_template.stat.exists | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Update haproxy service template description" | ||
ansible.builtin.lineinfile: | ||
backup: true | ||
path: /etc/systemd/system/[email protected] | ||
regexp: '^Description=' | ||
line: 'Description=HAProxy Load Balancer %i' | ||
state: present | ||
insertafter: '^[Unit]$' | ||
notify: "systemd daemon-reload" | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Update haproxy service template environment" | ||
ansible.builtin.lineinfile: | ||
backup: true | ||
path: /etc/systemd/system/[email protected] | ||
regexp: '^Environment=' | ||
line: 'Environment="CONFIG=/etc/haproxy/haproxy-%i.cfg" "PIDFILE=/run/haproxy-%i.pid"' | ||
state: present | ||
insertafter: '^[Service]$' | ||
notify: "systemd daemon-reload" | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Define healthcheck details for HANA" | ||
ansible.builtin.set_fact: | ||
__sap_ha_pacemaker_cluster_healthcheck_list_hana: | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_primary_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_primary_port }}" | ||
# If no custom port is defined, calculate the port for the secondary | ||
# by adding 10, to avoid a conflict with the port for the primary hc port. | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_hana_secondary_id }}" | ||
port: >- | ||
{% if sap_ha_pacemaker_cluster_vip_hana_secondary_ip_address | length > 0 -%} | ||
{{ sap_ha_pacemaker_cluster_healthcheck_hana_secondary_port }} | ||
{%- else %}0{%- endif %} | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 | ||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Define healthcheck details for NW ASCS/ERS" | ||
ansible.builtin.set_fact: | ||
__sap_ha_pacemaker_cluster_healthcheck_list_ascs: | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ascs_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ascs_port }}" | ||
- name: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ers_id }}" | ||
port: "{{ sap_ha_pacemaker_cluster_healthcheck_nwas_abap_ers_port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs') | length > 0 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy config for HANA instances" | ||
ansible.builtin.blockinfile: | ||
backup: false | ||
create: true | ||
path: "/etc/haproxy/haproxy-{{ haproxy_item.name }}.cfg" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
marker: "# {mark} Created by Ansible role sap_ha_pacemaker_cluster" | ||
block: | | ||
global | ||
chroot /var/lib/haproxy | ||
pidfile /var/run/haproxy-%i.pid | ||
user haproxy | ||
group haproxy | ||
daemon | ||
defaults | ||
mode tcp | ||
log global | ||
option dontlognull | ||
option redispatch | ||
retries 3 | ||
timeout queue 1m | ||
timeout connect 10s | ||
timeout client 1m | ||
timeout server 1m | ||
timeout check 10s | ||
maxconn 3000 | ||
# Listener for SAP healthcheck | ||
listen healthcheck | ||
bind *:{{ haproxy_item.port }} | ||
loop: "{{ __sap_ha_pacemaker_cluster_healthcheck_list_hana }}" | ||
loop_control: | ||
loop_var: haproxy_item | ||
label: "{{ haproxy_item.name }}: {{ haproxy_item.port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0 | ||
- haproxy_item.port | length > 4 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Create haproxy config for NWAS ASCS/ERS instances" | ||
ansible.builtin.blockinfile: | ||
create: true | ||
path: "/etc/haproxy/haproxy-{{ haproxy_item.name }}.cfg" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
marker: "# {mark} Created by Ansible role sap_ha_pacemaker_cluster" | ||
block: | | ||
global | ||
chroot /var/lib/haproxy | ||
pidfile /var/run/haproxy-%i.pid | ||
user haproxy | ||
group haproxy | ||
daemon | ||
defaults | ||
mode tcp | ||
log global | ||
option dontlognull | ||
option redispatch | ||
retries 3 | ||
timeout queue 1m | ||
timeout connect 10s | ||
timeout client 1m | ||
timeout server 1m | ||
timeout check 10s | ||
maxconn 3000 | ||
# Listener for SAP healthcheck | ||
listen healthcheck | ||
bind *:{{ haproxy_item.port }} | ||
loop: "{{ __sap_ha_pacemaker_cluster_healthcheck_list_ascs }}" | ||
loop_control: | ||
loop_var: haproxy_item | ||
label: "{{ haproxy_item.name }}: {{ haproxy_item.port }}" | ||
when: | ||
- sap_ha_pacemaker_cluster_host_type | select('search', 'nwas_abap_ascs') | length > 0 | ||
|
||
|
||
- name: "SAP HA Install Pacemaker - GCP CE VM - Ensure that haproxy service is running" | ||
ansible.builtin.service: | ||
name: haproxy | ||
enabled: false | ||
state: started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters