Skip to content
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
1 change: 1 addition & 0 deletions roles/sap_hana_install/.ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ skip_list:
- schema
# Allow templating inside name because it creates more detailed output:
- name[template]
- yaml[line-length]
28 changes: 16 additions & 12 deletions roles/sap_hana_install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,54 +257,58 @@ in a temporary directory for use by the hdblcm command in the next step.
```yaml
---
- name: Ansible Play for SAP HANA installation - One host
hosts: all
hosts: host0
become: true
tasks:
- name: Execute Ansible Role sap_hana_install
ansible.builtin.include_role:
name: community.sap_install.sap_hana_install
vars:
sap_hana_install_software_directory: /software/hana
sap_hana_install_common_master_password: 'NewPass$321'
sap_hana_install_common_master_password: 'My SAP HANA Master Password'
sap_hana_install_sid: 'H01'
sap_hana_install_instance_nr: '00'
```

#### Example playbook for installing a new scale-out SAP HANA system
Installs SAP HANA on `host0` and other hosts listed in `sap_hana_install_addhosts`: `host1` and `host2`.</br>
**NOTE:** Requires working SSH communication between hosts.
```yaml
---
- name: Ansible Play for SAP HANA installation - Scale-out
hosts: all
hosts: host0
become: true
tasks:
- name: Execute Ansible Role sap_hana_install
ansible.builtin.include_role:
name: community.sap_install.sap_hana_install
vars:
sap_hana_install_software_directory: /software/hana
sap_hana_install_common_master_password: 'NewPass$321'
sap_hana_install_root_password: 'NewPass$321'
sap_hana_install_addhosts: 'host2:role=worker,host3:role=worker:group=g02,host4:role=standby:group=g02'
sap_hana_install_common_master_password: 'My SAP HANA Master Password'
sap_hana_install_root_password: 'My root password'
sap_hana_install_addhosts: 'host0:role=worker,host1:role=worker:group=g02,host2:role=standby:group=g02'
sap_hana_install_sid: 'H01'
sap_hana_install_instance_nr: '00'
```

#### Example playbook for adding additional nodes to an existing SAP HANA installation
Installs SAP HANA on `host1` and `host2`, while running on host `host0` where existing SAP HANA is installed.</br>
**NOTE:** Requires working SSH communication between hosts.
```yaml
---
- name: Ansible Play for SAP HANA installation - Add host
hosts: all
- name: Ansible Play for SAP HANA installation - Add hosts
hosts: host0
become: true
tasks:
- name: Execute Ansible Role sap_hana_install
ansible.builtin.include_role:
name: community.sap_install.sap_hana_install
vars:
sap_hana_install_software_directory: /software/hana
sap_hana_install_new_system: no
sap_hana_install_addhosts: 'host2:role=worker,host3:role=worker:group=g02,host4:role=standby:group=g02'
sap_hana_install_common_master_password: 'NewPass$321'
sap_hana_install_root_password: 'NewPass$321'
sap_hana_install_new_system: false
sap_hana_install_addhosts: 'host0:role=worker,host1:role=worker:group=g02,host2:role=standby:group=g02'
sap_hana_install_common_master_password: 'My SAP HANA Master Password'
sap_hana_install_root_password: 'My root password'
sap_hana_install_sid: 'H01'
sap_hana_install_instance_nr: '00'
```
Expand Down
5 changes: 2 additions & 3 deletions roles/sap_hana_install/tasks/hana_exists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
loop_var: __sap_hana_install_loop_instance
label: "{{ __sap_hana_install_loop_instance.split('-')[0] | trim }}"

- name: SAP HANA Checks - Trying to install HANA with other SID and existing instance number
- name: SAP HANA Checks - Fail if existing HANA was detected with same instance number but different SID
ansible.builtin.fail:
msg: "The instance number {{ sap_hana_install_number }} is already used by
HANA system {{ __sap_hana_install_loop_instance.split('-')[0] | trim }}!"
Expand All @@ -46,7 +46,7 @@
loop_var: __sap_hana_install_loop_instance
label: "{{ __sap_hana_install_loop_instance.split('-')[0] | trim }}"

- name: SAP HANA Checks - Trying to install HANA with existing SID and other instance number
- name: SAP HANA Checks - Fail if existing HANA was detected with same SID but different instance number
ansible.builtin.fail:
msg: "HANA system {{ sap_hana_install_sid }} already exists with different instance number
{{ __sap_hana_install_loop_instance.split('-')[1] | trim }}!"
Expand All @@ -58,7 +58,6 @@
loop_var: __sap_hana_install_loop_instance
label: "{{ __sap_hana_install_loop_instance.split('-')[0] | trim }}"

## If saphostcontrol is not installed

- name: SAP HANA Checks - Check directories if no saphostctrl is found
when: not __sap_hana_install_register_stat_saphostctrl.stat.exists
Expand Down
40 changes: 40 additions & 0 deletions roles/sap_hana_install/tasks/hana_start.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Ensure SAP HANA is running - Set path to sapcontrol
ansible.builtin.set_fact:
__sap_hana_install_sapcontrol_path:
"/usr/sap/{{ sap_hana_install_sid | upper }}/HDB{{ sap_hana_install_number }}/exe/sapcontrol"

- name: Ensure SAP HANA is running - Check for sapcontrol executable
ansible.builtin.stat:
path: "{{ __sap_hana_install_sapcontrol_path }}"
register: __sap_hana_install_stat_sapcontrol

- name: Block to Ensure SAP HANA is running
when: __sap_hana_install_stat_sapcontrol.stat.exists
block:

- name: Ensure SAP HANA is running - Start instance
ansible.builtin.command:
cmd: "{{ __sap_hana_install_sapcontrol_path }} -nr {{ sap_hana_install_number }} -function StartSystem"
become: true
become_user: "{{ sap_hana_install_sid | lower }}adm"
register: __sap_hana_install_register_start_hana
changed_when: "'StartSystem OK' in __sap_hana_install_register_start_hana.stdout"

- name: Ensure SAP HANA is running - Wait for instance to be fully started
ansible.builtin.command:
cmd: "{{ __sap_hana_install_sapcontrol_path }} -nr {{ sap_hana_install_number }} -function GetProcessList"
become: true
become_user: "{{ sap_hana_install_sid | lower }}adm"
register: __sap_hana_install_register_sapcontrol_getprocesslist
# sapcontrol GetProcessList returns codes:
# 0 if some processes are starting or stopping (YELLOW)
# 3 if all processes are running (GREEN).
# 4 if all processes are stopped (GRAY).
until: __sap_hana_install_register_sapcontrol_getprocesslist.rc == 3
retries: 60 # wait for 10 minutes
delay: 10
changed_when: false
failed_when: false # command module will fail with non-zero return code
41 changes: 35 additions & 6 deletions roles/sap_hana_install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,58 @@


- name: SAP HANA existence checking
ansible.builtin.import_tasks: hana_exists.yml
ansible.builtin.include_tasks:
file: hana_exists.yml
when:
- sap_hana_install_new_system | d(true)
- not sap_hana_install_force | d(false)
tags:
- sap_hana_install_check_hana_exists
- sap_hana_install_preinstall

# SAP HANA has to be started when:
# 1. Existing SAP HANA was detected and '__sap_hana_install_fact_is_installed' is true.
# 2. Addhosts is executed when 'not sap_hana_install_new_system'
- name: Ensure SAP HANA is running for existing systems or addhosts operations
ansible.builtin.include_tasks:
file: hana_start.yml
when:
- __sap_hana_install_fact_is_installed | d(false)
or not sap_hana_install_new_system | d(true)

# SELinux is not currently supported by SAP using SLES4SAP
# This can still be overwritten by extra variables.
- name: SAP HANA Pre Install - Ensure SELinux does not execute for SLES
ansible.builtin.set_fact:
sap_hana_install_modify_selinux_labels: false
when: ansible_os_family == "Suse"


# This role consists of installation and configuration tasks.
# Installation tasks have to be run only for new installations.
# Configuration tasks have to be run always to ensure idempotency.
- name: Install SAP HANA
when: not __sap_hana_install_fact_is_installed | d(false)
block:

- name: SAP HANA pre-install steps
ansible.builtin.import_tasks: pre_install.yml
ansible.builtin.include_tasks:
file: pre_install.yml
tags: sap_hana_install_preinstall

- name: SAP HANA installation steps
ansible.builtin.import_tasks: hana_install.yml
ansible.builtin.include_tasks:
file: hana_install.yml
when: sap_hana_install_new_system | d(true)

# addhosts will be run only on new host, where SAP HANA is not installed
- name: SAP HANA addhosts steps
ansible.builtin.import_tasks: hana_addhosts.yml
ansible.builtin.include_tasks:
file: hana_addhosts.yml
when: not sap_hana_install_new_system | d(true)

- name: SAP HANA post-install steps
ansible.builtin.import_tasks: post_install.yml
# post_install is modular task file, that contains both installation and configuration tasks.
# This is executed for existing and new installations, further driven by '__sap_hana_install_fact_is_installed'.
- name: SAP HANA post-install steps
ansible.builtin.include_tasks:
file: post_install.yml
Loading