Skip to content

Commit 9b338bc

Browse files
author
Steven Stringer
authored
Merge pull request #75 from SUSE/gcp-terraform-multiple-iscsi
Gcp terraform multiple iscsi
2 parents e6ca669 + 4043d4d commit 9b338bc

29 files changed

Lines changed: 920 additions & 115 deletions

ansible/playbooks/cluster_sbd_prep.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
ansible.builtin.include_vars: ./vars/sbd-parameters.yaml
1515
vars:
1616
iscsi_prefix: /dev/disk/by-id/scsi-
17+
is_primary: "{{ groups.hana[0] == inventory_hostname }}"
1718

1819
handlers:
1920
- name: Restart iscsi

ansible/playbooks/sap-hana-cluster.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
vars:
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 }}"
9+
primary_hostname: "{{ ansible_play_hosts[0] }}"
910
use_sbd: yes
1011
#Azure fencing specific vars
1112
subscription_id:
@@ -40,7 +41,10 @@
4041
- name: Include AWS variables
4142
ansible.builtin.include_vars: ../../terraform/aws/aws_cluster_data.yaml
4243
when: cloud_platform_is_aws
43-
44+
45+
- name: Include GCP variables
46+
ansible.builtin.include_vars: ../../terraform/gcp/gcp_cluster_data.yaml
47+
when: cloud_platform_is_gcp
4448

4549
- name: Base Cluster Configuration [azure]
4650
ansible.builtin.include_tasks: ./tasks/azure-cluster-bootstrap.yaml
@@ -51,6 +55,11 @@
5155
ansible.builtin.include_tasks: ./tasks/aws-cluster-bootstrap.yaml
5256
when: cloud_platform_is_aws
5357
tags: bootstrap
58+
59+
- name: Base Cluster Configuration [gcp]
60+
ansible.builtin.include_tasks: ./tasks/cluster-bootstrap.yaml
61+
when: cloud_platform_is_gcp
62+
tags: bootstrap
5463

5564

5665
#TODO: Get rid of hardcoded hostnames!!!
@@ -67,3 +76,9 @@
6776
- cloud_platform_is_aws
6877
- is_primary
6978

79+
- name: Add HANA to cluster [gcp]
80+
ansible.builtin.include_tasks: ./tasks/cluster-hana.yaml
81+
when:
82+
- cloud_platform_is_gcp
83+
- is_primary
84+

ansible/playbooks/sap-hana-storage.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
ansible.builtin.include_vars: ./vars/azure_hana_storage_profile.yaml
2222
when: cloud_platform_is_azure
2323

24+
- name: Load Azure disk configuration
25+
ansible.builtin.include_vars: ./vars/gcp_hana_storage_profile.yaml
26+
when: cloud_platform_is_gcp
27+
2428
- name: HANA storage preparation
2529
vars:
2630
sap_storage_cloud_type: 'generic'

ansible/playbooks/sap-hana-system-replication-hooks.yaml

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@
77
- name: Source hana install variables
88
include_vars: ./vars/sap-hana-install_vars.yaml
99
vars:
10+
is_primary: "{{ ansible_play_hosts[0] == inventory_hostname }}"
1011
hooks_dir: myHooks
1112
site_a: node01
1213
site_b: node02
1314
sap_hana_install_sid: HDB
1415
sap_hana_install_instance_number: 00
16+
hana_status: unknown
17+
18+
handlers:
19+
- name: Stop HANA
20+
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StopWait 600 10" # Stopwait will timeout after 600 seconds.
21+
22+
- name: Start HANA Primary
23+
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StartWait 600 10" # Stopwait will timeout after 600 seconds.
24+
when: is_primary
25+
26+
- name: Start HANA Secondary
27+
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StartWait 600 10" # Stopwait will timeout after 600 seconds.
28+
when: not is_primary
1529

1630
tasks:
1731

@@ -31,53 +45,40 @@
3145
owner: "{{ sap_hana_install_sid | lower }}adm"
3246
group: sapsys
3347
mode: '660'
34-
register: copy_result
35-
36-
- name: Stop HANA
37-
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StopWait 600 10" # Stopwait will timeout after 600 seconds.
38-
when: copy_result.changed # only stop HANA if the copy file did something, otherwise we'll stop it for no reason
39-
40-
- name: Ensure ha_dr_provider_SAPHanaSR section exists in global.ini
41-
community.general.ini_file:
42-
path: /usr/sap/HDB/SYS/global/hdb/custom/config/global.ini
43-
section: "{{ item.section }}"
44-
option: "{{ item.key }}"
45-
value: "{{ item.value }}"
46-
mode: '0644'
47-
backup: yes
48-
49-
with_items:
50-
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'provider', 'value': 'SAPHanaSR'}
51-
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'path', 'value': '/hana/shared/{{ hooks_dir }}'}
52-
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'execution_order', 'value': '1'}
53-
- { 'section': 'trace', 'key': 'ha_dr_saphanasr', 'value': 'info'}
54-
when: copy_result.changed
48+
49+
- name: Ensure System Replication hooks are installed and configured
50+
block:
51+
- name: Ensure ha_dr_provider_SAPHanaSR section exists in global.ini
52+
community.general.ini_file:
53+
path: /usr/sap/HDB/SYS/global/hdb/custom/config/global.ini
54+
section: "{{ item.section }}"
55+
option: "{{ item.key }}"
56+
value: "{{ item.value }}"
57+
mode: '0644'
58+
backup: yes
59+
loop:
60+
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'provider', 'value': 'SAPHanaSR'}
61+
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'path', 'value': '/hana/shared/{{ hooks_dir }}'}
62+
- { 'section': 'ha_dr_provider_SAPHanaSR', 'key': 'execution_order', 'value': '1'}
63+
- { 'section': 'trace', 'key': 'ha_dr_saphanasr', 'value': 'info'}
5564

56-
- name: Add hooks into sudoers
57-
ansible.builtin.lineinfile:
58-
path: /etc/sudoers.d/HanaSystemReplication
59-
state: present
60-
regexp: "{{ item.regexp }}"
61-
line: "{{ item.line }}"
62-
validate: /usr/sbin/visudo -cf %s
63-
create: yes
64-
mode: '0440'
65-
with_items:
66-
- { 'regexp': '^#ANSIBLE MANAGED DOCUMENT', 'line': '#ANSIBLE MANAGED DOCUMENT - no manual edits!'}
67-
- { 'regexp': '^Cmnd_Alias SOK_SITEA', 'line': 'Cmnd_Alias SOK_SITEA = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_a }} -v SOK -t crm_config -s SAPHanaSR'}
68-
- { 'regexp': '^Cmnd_Alias SFAIL_SITEA ', 'line': 'Cmnd_Alias SFAIL_SITEA = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_a }} -v SFAIL -t crm_config -s SAPHanaSR'}
69-
- { 'regexp': '^Cmnd_Alias SOK_SITEB', 'line': 'Cmnd_Alias SOK_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_b }} -v SOK -t crm_config -s SAPHanaSR'}
70-
- { 'regexp': '^Cmnd_Alias SFAIL_SITEB', 'line': 'Cmnd_Alias SFAIL_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_b }} -v SFAIL -t crm_config -s SAPHanaSR'}
71-
- { 'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: SOK_SITEA, SFAIL_SITEA, SOK_SITEB, SFAIL_SITEB'}
72-
73-
- name: Start HANA primary
74-
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StartWait 600 10"
75-
when:
76-
- copy_result.changed # only start HANA if we stopped it
77-
- ansible_hostname == 'vmahana01'
78-
79-
- name: Start HANA secondary
80-
ansible.builtin.command: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ sap_hana_install_instance_number }} -function StartWait 600 10"
81-
when:
82-
- copy_result.changed # only start HANA if we stopped it
83-
- ansible_hostname == 'vmahana02'
65+
- name: Add hooks into sudoers
66+
ansible.builtin.lineinfile:
67+
path: /etc/sudoers.d/HanaSystemReplication
68+
state: present
69+
regexp: "{{ item.regexp }}"
70+
line: "{{ item.line }}"
71+
validate: /usr/sbin/visudo -cf %s
72+
create: yes
73+
mode: '0440'
74+
loop:
75+
- { 'regexp': '^#ANSIBLE MANAGED DOCUMENT', 'line': '#ANSIBLE MANAGED DOCUMENT - no manual edits!'}
76+
- { 'regexp': '^Cmnd_Alias SOK_SITEA', 'line': 'Cmnd_Alias SOK_SITEA = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_a }} -v SOK -t crm_config -s SAPHanaSR'}
77+
- { 'regexp': '^Cmnd_Alias SFAIL_SITEA ', 'line': 'Cmnd_Alias SFAIL_SITEA = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_a }} -v SFAIL -t crm_config -s SAPHanaSR'}
78+
- { 'regexp': '^Cmnd_Alias SOK_SITEB', 'line': 'Cmnd_Alias SOK_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_b }} -v SOK -t crm_config -s SAPHanaSR'}
79+
- { 'regexp': '^Cmnd_Alias SFAIL_SITEB', 'line': 'Cmnd_Alias SFAIL_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ site_b }} -v SFAIL -t crm_config -s SAPHanaSR'}
80+
- { 'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: SOK_SITEA, SFAIL_SITEA, SOK_SITEB, SFAIL_SITEB'}
81+
notify:
82+
- Stop HANA
83+
- Start HANA Primary
84+
- Start HANA Secondary

ansible/playbooks/sap-hana-system-replication.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
include_vars: ./vars/azure_hana_hsr_parameters.yaml
2727
when: cloud_platform_is_azure
2828

29+
- name: Load GCP system replication vars
30+
include_vars: ./vars/gcp_hana_hsr_parameters.yaml
31+
when: cloud_platform_is_gcp
32+
2933
- name: Check for previous HSR configuration
3034
ansible.builtin.file:
3135
path: "{{ hsr_cnf_file }}"
File renamed without changes.

ansible/playbooks/tasks/client-sbd-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@
3333
- name: Check that the sbd is not already initialised
3434
ansible.builtin.command: sbd -d {{ item }} dump
3535
loop: "{{ sbd_list }}"
36-
delegate_to: vmhana01
3736
changed_when: false
3837
failed_when: false
3938
register: sdb_safe
39+
when: is_primary
4040

4141
# Only create an sbd device when we didn't get a clean return code from the dump command
4242
- name: Create sdb devices
4343
ansible.builtin.command: sbd -d {{ item.item }} -1 60 -4 120 create
44-
when: item.rc != 0
44+
when:
45+
- is_primary
46+
- item.rc != 0
4547
loop: "{{ sdb_safe.results }}"
46-
delegate_to: vmhana01
47-
48+
4849
- name: Ensure that sbd configuration file exits
4950
ansible.builtin.file:
5051
path: /etc/sysconfig/sbd

0 commit comments

Comments
 (0)