Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GCP native fencing #271

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion ansible/playbooks/tasks/cluster-bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@
params tag={{ aws_stonith_tag}} pcmk_delay_max=15
when: cloud_platform_is_aws

- name: Set primary and secondary hostnames
ansible.builtin.set_fact:
primary_hostname: "{{ groups['hana'][0] }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use similar query to calculate is_primary. Differences are:

  • all of them calculate it ad playbook level and not at task level
  • other places are using group.hana[0]
  • other places are using a combination like:
hosts: hana
vars:
        is_primary: "{{ ansible_play_hosts[0] == inventory_hostname }}"

Let's keep it like this here but revisit it everywhere in all files.

secondary_hostname: "{{ groups['hana'][1] }}"
when:
- cloud_platform_is_gcp
- not (use_sbd | bool)

- name: Enable SBD [sbd]
ansible.builtin.command:
cmd: crm configure primitive rsc_iscsi_sbd stonith:external/sbd
Expand All @@ -252,7 +260,6 @@
failed_when: >
stonith_config_result.stderr_lines | select("match", "ERROR") | reject("match", "ERROR: warning") | list | length > 0


- name: Configure AWS EC2 STONITH for sle 15
ansible.builtin.command: "{{ aws_stonith_cmd }}"
when:
Expand All @@ -263,6 +270,56 @@
register: stonith_config_result
failed_when: "'ERROR' in stonith_config_result.stderr"

# Thee following STONITH commands for GCP have been adapted from
# https://cloud.google.com/solutions/sap/docs/sap-hana-ha-config-sles
- name: Configure GCP Native Fencing STONITH for Primary
ansible.builtin.command: >
crm configure primitive rsc_gce_stonith_primary stonith:fence_gce
params
port="{{ primary_hostname }}"
zone="{{ primary_zone }}"
project="{{ project }}"
op monitor interval="300s" timeout="120s"
op start interval="0" timeout="60s"
meta target-role=Started
when:
- cloud_platform_is_gcp
- is_primary
- not (use_sbd | bool)

- name: Configure GCP Native Fencing STONITH for Secondary
ansible.builtin.command: >
crm configure primitive rsc_gce_stonith_secondary stonith:fence_gce
params
port="{{ secondary_hostname }}"
zone="{{ secondary_zone }}"
project="{{ project }}"
op monitor interval="300s" timeout="120s"
op start interval="0" timeout="60s"
meta target-role=Started
when:
- cloud_platform_is_gcp
- is_primary
- not (use_sbd | bool)

- name: Set Location of Primary Fencing Device (GCP)
ansible.builtin.command: >
crm configure location LOC_STONITH_{{ primary_hostname }} \
rsc_gce_stonith_primary -inf: "{{ primary_hostname }}"
when:
- cloud_platform_is_gcp
- is_primary
- not (use_sbd | bool)

- name: Set Location of Secondary Fencing Device (GCP)
ansible.builtin.command: >
crm configure location LOC_STONITH_{{ secondary_hostname }} \
rsc_gce_stonith_secondary -inf: "{{ secondary_hostname }}"
when:
- cloud_platform_is_gcp
- is_primary
- not (use_sbd | bool)

- name: Set stonith-timeout [sdb]
ansible.builtin.command:
cmd: crm configure property stonith-timeout=144
Expand Down
3 changes: 3 additions & 0 deletions terraform/gcp/inventory.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ all:
use_sbd: ${use_sbd}
gcp_cluster_ip: ${hana-vip}
prefix: ${name_prefix}
project: ${gcp_project}
primary_zone: ${gcp_primary_zone}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other comment, we can think about moving them to hosts>>hana section of the playbook

secondary_zone: ${gcp_secondary_zone}
children:
hana:
hosts:
Expand Down
5 changes: 4 additions & 1 deletion terraform/gcp/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ resource "local_file" "ansible_inventory" {
iscsi_name = module.iscsi_server.iscsisrv_name,
iscsi_pip = module.iscsi_server.iscsisrv_public_ip,
iscsi_enabled = local.iscsi_enabled,
iscsi_remote_python = var.iscsi_remote_python
iscsi_remote_python = var.iscsi_remote_python,
gcp_project = var.project,
gcp_primary_zone = element(local.compute_zones, 0),
gcp_secondary_zone = element(local.compute_zones, 1),
use_sbd = local.use_sbd
name_prefix = local.deployment_name,
})
Expand Down
Loading