Skip to content

Commit 40a7685

Browse files
authored
Add MSI based native fencing (#180)
1 parent 3fafc10 commit 40a7685

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ ansible:
158158
- deregister.yaml
159159
```
160160

161+
* In case of Azure deployment using native fencing, there are additional parameters to be added for `sap-hana-cluster.yaml` playbook.
162+
* For details please check ./docs/playbooks/README.md
163+
161164
#### Deploy
162165

163166
Terraform and Ansible deployment steps can be executed like:

ansible/playbooks/sap-hana-cluster.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
# is_primary is selected so that tasks that need to be issued one are honoured correctly
88
is_primary: "{{ ansible_play_hosts[0] == inventory_hostname }}"
99
primary_hostname: "{{ ansible_play_hosts[0] }}"
10-
use_sbd: yes
1110
# Azure fencing specific vars
12-
subscription_id:
13-
resource_group:
14-
tenant_id:
15-
application_id:
16-
app_password:
11+
azure_identity_management: # use 'spi' (service principal) or 'msi' (managed identity)
12+
# Azure fencing - SPN related variables
13+
spn_application_id:
14+
spn_application_password:
1715
# corosync variables
1816
crypto_hash: sha1
1917
crypto_cipher: aes256

ansible/playbooks/tasks/azure-cluster-bootstrap.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,19 @@
216216
- is_primary
217217
- crm_maintenance_mode is false or crm_maintenance_mode == 'unknown'
218218

219-
- name: Configure azure fencing
220-
ansible.builtin.command: "crm configure primitive rsc_stonith_azure stonith:fence_azure_arm params subscriptionId=\"{{ subscription_id }}\" resourceGroup=\"{{ resource_group }}\" tenantId=\"{{ tenant_id }}\" login=\"{{ application_id }}\" passwd=\"{{ app_password }}\" pcmk_monitor_retries=4 pcmk_action_limit=3 power_timeout=240 pcmk_reboot_timeout=900 op monitor interval=3600 timeout=120"
219+
- name: Configure azure fencing [MSI (Managed identity)]
220+
ansible.builtin.command: "crm configure primitive rsc_stonith_azure stonith:fence_azure_arm params msi=true subscriptionId=\"{{ subscription_id }}\" resourceGroup=\"{{ resource_group_name }}\" tenantId=\"{{ tenant_id }}\" pcmk_monitor_retries=4 pcmk_action_limit=3 power_timeout=240 pcmk_reboot_timeout=900 pcmk_delay_max=15 op monitor interval=3600 timeout=120"
221221
when:
222222
- is_primary
223223
- rsc_st_azure | length == 0
224-
- not use_sbd | bool
224+
- not use_sbd | bool and azure_identity_management == 'msi'
225+
226+
- name: Configure azure fencing [SPN (Service principal)]
227+
ansible.builtin.command: "crm configure primitive rsc_stonith_azure stonith:fence_azure_arm params subscriptionId=\"{{ subscription_id }}\" resourceGroup=\"{{ resource_group_name }}\" tenantId=\"{{ tenant_id }}\" login=\"{{ spn_application_id }}\" passwd=\"{{ spn_application_password }}\" pcmk_monitor_retries=4 pcmk_action_limit=3 power_timeout=240 pcmk_reboot_timeout=900 op monitor interval=3600 timeout=120"
228+
when:
229+
- is_primary
230+
- rsc_st_azure | length == 0
231+
- not use_sbd | bool and azure_identity_management == 'spn'
225232

226233
- name: Add Azure scheduled events to cluster
227234
ansible.builtin.command: crm configure primitive rsc_azure-events ocf:heartbeat:azure-events op monitor interval=10s

docs/playbooks/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,15 @@ an SBD based cluster will be created.
335335
To use Azure native fencing you must:
336336

337337
* Be using the azure provider in terraform
338-
* Set the variable `use_sbd` to 'no'
339-
* Provide the following variables:
340-
* subscription_id:
341-
* resource_group:
342-
* tenant_id:
343-
* application_id:
344-
* app_password:
338+
* **Provide the following variables:**
339+
* identity_management - 'msi' or 'spn'
340+
* spn_application_id - SPN fencing app id
341+
* spn_application_password - Password used for SPN based fencing
342+
* **Variables below are provided by terraform output:**
343+
* use_sbd - has to be set to 'no'
344+
* subscription_id
345+
* resource_group
346+
* tenant_id
345347

346348
The five additional variables all relate to the SAP fencing application
347349
that needs to be created. At this point, the creation of the fencing

terraform/azure/fence_data.tmpl

Lines changed: 0 additions & 5 deletions
This file was deleted.

terraform/azure/inventory.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
all:
22
vars:
3-
cluster_ip: ${cluster_ip}
43
use_sbd: ${use_sbd}
4+
resource_group_name: ${resource_group_name}
5+
subscription_id: ${subscription_id}
6+
tenant_id: ${tenant_id}
7+
cluster_ip: ${cluster_ip}
58
children:
69
hana:
710
hosts:

terraform/azure/outputs.tf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,9 @@ resource "local_file" "ansible_inventory" {
107107
iscsi_enabled = local.iscsi_enabled,
108108
iscsi_remote_python = var.iscsi_remote_python
109109
use_sbd = local.use_sbd
110-
})
111-
filename = "inventory.yaml"
112-
}
113-
114-
resource "local_file" "fence_data" {
115-
content = templatefile("fence_data.tmpl",
116-
{
117110
resource_group_name = local.resource_group_name
118111
subscription_id = data.azurerm_subscription.current.subscription_id
119112
tenant_id = data.azurerm_subscription.current.tenant_id
120113
})
121-
filename = "fence_data.json"
114+
filename = "inventory.yaml"
122115
}

0 commit comments

Comments
 (0)