forked from sap-linuxlab/community.sap_install
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure_hsr.yml
More file actions
67 lines (64 loc) · 3.29 KB
/
configure_hsr.yml
File metadata and controls
67 lines (64 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-License-Identifier: Apache-2.0
---
- name: "SAP HSR - Check System Replication Status"
ansible.builtin.shell: |
source /usr/sap/{{ sap_ha_install_hana_hsr_sid }}/home/.sapenv.sh && \
/usr/sap/{{ sap_ha_install_hana_hsr_sid | upper }}/HDB{{ sap_ha_install_hana_hsr_instance_number }}/exe/hdbnsutil \
-sr_state
become: true
become_user: "{{ sap_ha_install_hana_hsr_sid | lower }}adm"
register: __sap_ha_install_hana_hsr_srstate
changed_when: false
failed_when: false
# looping through cluster definition to run on defined primary
# and apply the respective 'site' value
- name: "SAP HSR - Enable HANA System Replication on primary node"
ansible.builtin.shell: |
source /usr/sap/{{ sap_ha_install_hana_hsr_sid }}/home/.sapenv.sh && \
/usr/sap/{{ sap_ha_install_hana_hsr_sid | upper }}/HDB{{ sap_ha_install_hana_hsr_instance_number }}/exe/hdbnsutil \
-sr_enable --name="{{ item.hana_site }}"
become: true
become_user: "{{ sap_ha_install_hana_hsr_sid | lower }}adm"
register: enablesr
changed_when: "'successfully enabled system as system replication source site' in enablesr.stdout"
when:
- __sap_ha_install_hana_hsr_node_name == item.node_name.split('.')[0]
- item.node_role is defined and item.node_role == 'primary'
- "'is source system' not in __sap_ha_install_hana_hsr_srstate.stdout"
loop: "{{ sap_ha_install_hana_hsr_cluster_nodes }}"
loop_control:
label: "{{ item.node_name }}"
# looping through cluster definition to run on secondary node
# and apply the respective 'site' value
# - 'throttle' to avoid simultaneous run for multiple secondaries as this confuses the primary
- name: "SAP HSR - Register secondary node to HANA System Replication"
ansible.builtin.shell: |
source /usr/sap/{{ sap_ha_install_hana_hsr_sid }}/home/.sapenv.sh && \
/usr/sap/{{ sap_ha_install_hana_hsr_sid | upper }}/HDB{{ sap_ha_install_hana_hsr_instance_number }}/exe/hdbnsutil \
-sr_register --name={{ item.hana_site }} \
--remoteHost={{ __sap_ha_install_hana_hsr_primary_node_name }} --remoteInstance={{ sap_ha_install_hana_hsr_instance_number }} \
--replicationMode={{ sap_ha_install_hana_hsr_rep_mode }} --operationMode={{ sap_ha_install_hana_hsr_oper_mode }} \
--online
become: true
become_user: "{{ sap_ha_install_hana_hsr_sid | lower }}adm"
register: registersr
when:
- __sap_ha_install_hana_hsr_node_name == item.node_name.split('.')[0]
- item.node_role is not defined or item.node_role == 'secondary'
- __sap_ha_install_hana_hsr_node_name not in __sap_ha_install_hana_hsr_srstate.stdout
loop: "{{ sap_ha_install_hana_hsr_cluster_nodes }}"
loop_control:
label: "{{ item.node_name }}"
changed_when: true
throttle: 1
- name: "SAP HSR - Start HANA instance on secondary"
ansible.builtin.shell: |
/usr/sap/{{ sap_ha_install_hana_hsr_sid | upper }}/HDB{{ sap_ha_install_hana_hsr_instance_number }}/exe/sapcontrol \
-nr {{ sap_ha_install_hana_hsr_instance_number }} -function StartSystem
become: true
become_user: "{{ sap_ha_install_hana_hsr_sid | lower }}adm"
register: startinstance
changed_when: "'StartSystem' in startinstance.stdout"
when:
- __sap_ha_install_hana_hsr_node_name != __sap_ha_install_hana_hsr_primary_node_name
- __sap_ha_install_hana_hsr_node_name not in __sap_ha_install_hana_hsr_srstate.stdout