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
64 changes: 25 additions & 39 deletions roles/sap_hana_install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,59 +377,45 @@ Installs SAP HANA on `host1` and `host2`, while running on host `host0` where ex

<!-- BEGIN Role Tags -->
### Role Tags
Note: When using tags, only one tag at a time is possible.

With the following tags, the role can be called to perform certain activities only:
- tag `sap_hana_install_check_installation`: Perform an installation check, using `hdbcheck` or
`hdblcm --action=check_installation`.
- tag `sap_hana_install_chown_hana_directories`: Only perform the chown of the SAP HANA directories
`/hana`, `/hana/shared`, `/hana/log`, and `/hana/data`. The main purpose of this tag is to use it
with `--skip-tags`, to skip modifying these directories. This can be useful when using tag
`sap_hana_install_preinstall`.
- tag `sap_hana_install_configure_firewall`: Use this flag to only configure the firewall ports for
SAP HANA. Note: The role variable `sap_hana_install_update_firewall` has to be set to `true` as
well.
- tag `sap_hana_install_extract_sarfiles`: Use this flag with `--skip-tags` to run the SAR file
preparation steps of tag `sap_hana_install_prepare_sarfiles` without extracting the SAR files.
- tag `sap_hana_install_generate_input_file`: Only generate the input file for SAP Application
deployment
- tag `sap_hana_install_hdblcm_commandline`: Only show the hdblcm command line, without processing
the hdblcm template. This can be useful for checking the hdblcm command line options, especially
when using the `addhosts` function.
- tag `sap_hana_install_preinstall`: Only perform pre-install activities. This includes selecting
the SAPCAR EXE file, extracting the SAR files if necessary, searching for hdblcm, and creating
the hdblcm configfile.
- tag `sap_hana_install_prepare_sapcar`: Only copy the SAPCAR EXE files for the current architecture
to the extraction directory, verify the checksums of these files, and select the latest
version. Or copy the SAPCAR EXE file if given by role variable `sap_hana_install_sapcar_filename`
and then verify the checksum.
- tag `sap_hana_install_prepare_sarfiles`: Run the steps of tag `sap_hana_install_prepare_sapcar`
to select the correct SAPCAR file, then copy the selected or provided SAR files to the
extraction directory (if requested), then verify the checksums of each SAR file. Lastly, extract
these SAR files to the extraction directory.
- tag `sap_hana_install_set_log_mode`: Only set the log mode of an existing HANA installation to
`overwrite`.
- tag `sap_hana_install_store_connection_information`: Only run the `hdbuserstore` command
- tag `sap_hana_install_create_configfile`: Only generate the hdblcm configfile.
- tag `sap_hana_install_check_hana_exists`: Only check if there is already HANA installed with the
desired SID and instance number.

The following tags have been removed in this release:
- tag `sap_hana_install_preinstall`
- tag `sap_hana_install_chown_hana_directories`
- tag `sap_hana_install_prepare_sapcar`
- tag `sap_hana_install_prepare_sarfiles`
- tag `sap_hana_install_extract_sarfiles`
- tag `sap_hana_install_configure_firewall`
- tag `sap_hana_install_configure_fapolicyd`
- tag `sap_hana_install_generate_input_file`
- tag `sap_hana_install_store_connection_information`
- tag `sap_hana_install_set_log_mode`
- tag `sap_hana_install_check_installation`

<details>
<summary><b>How to run sap_hana_install with tags</b></summary>

#### Process SAPCAR and SAR files and create the hdblcm configfile:
```console
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_preinstall --skip-tags=sap_hana_install_chown_hana_directories
#### Display SAP HANA hdblcm command line without performing an installation:
```

#### Process only SAPCAR files:
```console
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_prepare_sapcar
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_hdblcm_commandline
```

#### Process SAPCAR and SAR files without extracting SAR files:
#### Only create the hdblcm configfile:
```console
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_prepare_sarfiles --skip-tags=sap_hana_install_extract_sarfiles
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_create_configfile
```

#### Display SAP HANA hdblcm command without using it
```
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_hdblcm_commandline
#### Perform a SAP HANA existence check:
```console
ansible-playbook sap-hana-install.yml --tags=sap_hana_install_check_hana_exists
```
</details>

Expand Down
5 changes: 3 additions & 2 deletions roles/sap_hana_install/tasks/hana_addhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
ansible.builtin.set_fact:
__sap_hana_install_fact_addhosts: "{{ __sap_hana_install_fact_addhosts | d([]) + [item] }}"
loop: "{{ sap_hana_install_addhosts.split(',') | map('trim') | reject('equalto', '') | list }}"
when:
- item.split(':')[0] in __sap_hana_install_fact_addhosts_hosts_new
when: item.split(':')[0] in __sap_hana_install_fact_addhosts_hosts_new
tags: sap_hana_install_create_configfile

- name: SAP HANA - Addhosts - Update configfile with new addhosts string
ansible.builtin.lineinfile:
path: "{{ __sap_hana_install_register_tmpdir.path }}/configfile.cfg"
regexp: '^addhosts\s*=\s*.*$'
line: "addhosts = {{ __sap_hana_install_fact_addhosts | join(',') }}"
tags: sap_hana_install_create_configfile


- name: SAP HANA - Addhosts - Set fact for hdblcm command line
Expand Down
63 changes: 42 additions & 21 deletions roles/sap_hana_install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# SPDX-License-Identifier: Apache-2.0
---

# Fail when more than one tag is used
- name: SAP HANA - Main - Fail if more than one tag is used
ansible.builtin.fail:
msg: "This role supports only one tag at a time."
when: ansible_run_tags | d([]) | count > 1
tags: always

# SAP HANA
- name: SAP HANA - Main - Prepare some variables
ansible.builtin.include_tasks:
file: pre_tasks/prepare_variables.yml
tags:
- sap_hana_install_check_hana_exists
- sap_hana_install_check_installation
- sap_hana_install_preinstall
- sap_hana_install_set_log_mode
- sap_hana_install_configure_firewall
apply:
tags: always
tags: always

# SAP HANA presence has to be validated for both new system and adding new hosts.
- name: SAP HANA - Main - Validate presence of existing SAP HANA database
ansible.builtin.include_tasks:
file: pre_tasks/hana_exists.yml
apply:
tags:
- sap_hana_install_check_hana_exists
when:
- (sap_hana_install_new_system and not sap_hana_install_force)
or not sap_hana_install_new_system
tags:
- sap_hana_install_check_hana_exists
- sap_hana_install_preinstall


- name: SAP HANA - Main - Identify hosts in play based on addhosts
Expand All @@ -42,45 +48,60 @@
# - Configuration - Run always to ensure idempotent outcome.

- name: Block for Installation tasks
when:
- sap_hana_install_new_system
when: sap_hana_install_new_system or
('sap_hana_install_create_configfile' in ansible_run_tags | d([])) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([]))
block:
- name: SAP HANA - Install - Pre-Tasks
ansible.builtin.include_tasks:
file: pre_install.yml
tags:
- sap_hana_install_create_configfile
- sap_hana_install_hdblcm_commandline

- name: SAP HANA - Install
ansible.builtin.include_tasks:
file: hana_install.yml
when:
- not __sap_hana_install_fact_is_installed
- __sap_hana_install_fact_is_main_host
when: >
(not __sap_hana_install_fact_is_installed and __sap_hana_install_fact_is_main_host) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([]))
tags: sap_hana_install_hdblcm_commandline

- name: SAP HANA - Install - Post-tasks
ansible.builtin.include_tasks:
file: post_install.yml
when: __sap_hana_install_fact_is_installed


- name: Block for Addhosts tasks
when:
- not sap_hana_install_new_system
- __sap_hana_install_fact_is_scaleout
- __sap_hana_install_fact_is_installed
when: >
not sap_hana_install_new_system and
((__sap_hana_install_fact_is_scaleout and __sap_hana_install_fact_is_installed) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or
('sap_hana_install_create_configfile' in ansible_run_tags | d([])))
block:
# Execute only if new hosts are to be added.
- name: SAP HANA - Addhosts - Pre-Tasks
ansible.builtin.include_tasks:
file: pre_addhosts.yml
when:
- __sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0
tags: sap_hana_install_preinstall
when: >
(__sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or
('sap_hana_install_create_configfile' in ansible_run_tags | d([]))
tags:
- sap_hana_install_hdblcm_commandline
- sap_hana_install_create_configfile

- name: SAP HANA - Addhosts
ansible.builtin.include_tasks:
file: hana_addhosts.yml
when:
- __sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0
- __sap_hana_install_fact_is_main_host
(__sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0 and __sap_hana_install_fact_is_main_host) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or
('sap_hana_install_create_configfile' in ansible_run_tags | d([]))
tags:
- sap_hana_install_hdblcm_commandline
- sap_hana_install_create_configfile

- name: SAP HANA - Addhosts - Post-tasks
ansible.builtin.include_tasks:
Expand Down
3 changes: 0 additions & 3 deletions roles/sap_hana_install/tasks/post_addhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
- name: SAP HANA - Addhosts - Post-Tasks - Update hdbuserstore connection details
ansible.builtin.include_tasks:
file: post_tasks/hdbuserstore.yml
tags: sap_hana_install_store_connection_information

- name: SAP HANA - Addhosts - Post-Tasks - Firewall
ansible.builtin.include_tasks:
file: post_tasks/firewall.yml
when: sap_hana_install_update_firewall
tags: sap_hana_install_configure_firewall

- name: SAP HANA - Addhosts - Post-Tasks - SELinux
ansible.builtin.include_tasks:
Expand All @@ -34,4 +32,3 @@
# Ensure fapolicyd is checked only on supported systems.
- ansible_os_family == "RedHat"
- __sap_hana_install_configure_fapolicyd
tags: sap_hana_install_configure_fapolicyd
6 changes: 0 additions & 6 deletions roles/sap_hana_install/tasks/post_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- name: SAP HANA - Install - Post-Tasks - Set log_mode
ansible.builtin.include_tasks:
file: post_tasks/log_mode.yml
tags: sap_hana_install_set_log_mode

- name: SAP HANA - Install - Post-Tasks - Apply license
ansible.builtin.include_tasks:
Expand All @@ -27,7 +26,6 @@
ansible.builtin.include_tasks:
file: post_tasks/check_installation.yml
when: sap_hana_install_check_installation | d(false)
tags: sap_hana_install_check_installation

- name: SAP HANA - Install - Post-Tasks - Generate Input File for SAP Application Deployment
'{{ sap_hana_install_nw_input_location }}/{{ sap_hana_install_sid }}.info.nw.install'
Expand All @@ -39,7 +37,6 @@
delegate_to: localhost
vars:
ansible_become: false
tags: sap_hana_install_generate_input_file

# Cleanup extracted software
- name: SAP HANA - Install - Post-Tasks - Deleting software extract directory '{{ sap_hana_install_software_extract_directory }}'
Expand All @@ -65,13 +62,11 @@
- name: SAP HANA - Install - Post-Tasks - Update hdbuserstore connection details
ansible.builtin.include_tasks:
file: post_tasks/hdbuserstore.yml
tags: sap_hana_install_store_connection_information

- name: SAP HANA - Install - Post-Tasks - Firewall
ansible.builtin.include_tasks:
file: post_tasks/firewall.yml
when: sap_hana_install_update_firewall
tags: sap_hana_install_configure_firewall

- name: SAP HANA - Install - Post-Tasks - SELinux
ansible.builtin.include_tasks:
Expand All @@ -85,4 +80,3 @@
# Ensure fapolicyd is checked only on supported systems.
- ansible_os_family == "RedHat"
- __sap_hana_install_configure_fapolicyd
tags: sap_hana_install_configure_fapolicyd
4 changes: 0 additions & 4 deletions roles/sap_hana_install/tasks/post_tasks/log_mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
- sap_hana_install_log_mode | d('') == 'overwrite'
changed_when: false
register: __sap_hana_install_register_hdbsql_logmode_no_initial_tenant
tags: sap_hana_install_set_log_mode

- name: SAP HANA - Post-Tasks - Display the output of hdbsql, no initial tenant
ansible.builtin.debug:
msg: "{{ __sap_hana_install_register_hdbsql_logmode_no_initial_tenant.stdout_lines }}"
tags: sap_hana_install_set_log_mode
when:
- not ansible_check_mode
- sap_hana_install_create_initial_tenant == 'n'
Expand Down Expand Up @@ -60,12 +58,10 @@
- sap_hana_install_log_mode | d('') == 'overwrite'
changed_when: false
register: __sap_hana_install_register_hdbsql_logmode_with_initial_tenant
tags: sap_hana_install_set_log_mode

- name: SAP HANA - Post-Tasks - Display the output of hdbsql, with initial tenant
ansible.builtin.debug:
msg: "{{ __sap_hana_install_register_hdbsql_logmode_with_initial_tenant.stdout_lines }}"
tags: sap_hana_install_set_log_mode
when:
- not ansible_check_mode
- sap_hana_install_create_initial_tenant == 'y'
Expand Down
15 changes: 11 additions & 4 deletions roles/sap_hana_install/tasks/pre_addhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
# Ensure fapolicyd is checked only on supported systems.
- ansible_os_family == "RedHat"
- __sap_hana_install_fact_is_new_addhost_host
tags: sap_hana_install_configure_fapolicyd


- name: SAP HANA - Addhosts - Pre-Tasks - Configure SELinux file contexts for {{ sap_hana_install_root_path }}
Expand All @@ -65,7 +64,13 @@
- name: SAP HANA - Addhosts - Pre-Tasks - Validate and prepare software directory
ansible.builtin.include_tasks:
file: pre_tasks/prepare_software_addhosts.yml
when: __sap_hana_install_fact_is_main_host
when: >
__sap_hana_install_fact_is_main_host or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or
('sap_hana_install_create_configfile' in ansible_run_tags | d([]))
tags:
- sap_hana_install_hdblcm_commandline
- sap_hana_install_create_configfile


# Proper idempotency needs to check existing version, not just existence.
Expand All @@ -85,9 +90,11 @@
file: pre_tasks/hana_directory_permissions.yml
# Execute only once for Scale-Out to avoid conflicts when updating shared file systems.
when: __sap_hana_install_fact_is_main_host
tags: sap_hana_install_chown_hana_directories

- name: SAP HANA - Addhosts - Pre-Tasks - Process the hdblcm configfile
ansible.builtin.include_tasks:
file: pre_tasks/hdblcm_configfile.yml
when: __sap_hana_install_fact_is_main_host
apply:
tags: sap_hana_install_create_configfile
when: __sap_hana_install_fact_is_main_host or ('sap_hana_install_create_configfile' in ansible_run_tags | d([]))
tags: sap_hana_install_create_configfile
21 changes: 15 additions & 6 deletions roles/sap_hana_install/tasks/pre_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Ensure fapolicyd is checked only on supported systems.
- ansible_os_family == "RedHat"
- not __sap_hana_install_fact_is_installed
tags: sap_hana_install_configure_fapolicyd


- name: SAP HANA - Install - Pre-Tasks - Configure SELinux file contexts for {{ sap_hana_install_root_path }}
Expand All @@ -23,7 +22,15 @@
- name: SAP HANA - Install - Pre-Tasks - Validate and prepare software directory
ansible.builtin.include_tasks:
file: pre_tasks/prepare_software_install.yml
when: __sap_hana_install_fact_is_main_host
apply:
tags: sap_hana_install_create_configfile
when: >
__sap_hana_install_fact_is_main_host or
('sap_hana_install_create_configfile' in ansible_run_tags | d([])) or
('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([]))
tags:
- sap_hana_install_create_configfile
- sap_hana_install_hdblcm_commandline


# Proper idempotency needs to check existing version, not just existence.
Expand All @@ -45,11 +52,13 @@
# Execute only once for Scale-Out to avoid conflicts when updating shared file systems.
run_once: "{{ __sap_hana_install_fact_is_scaleout }}"
when: not __sap_hana_install_fact_is_installed
tags: sap_hana_install_chown_hana_directories

- name: SAP HANA - Install - Pre-Tasks - Process the hdblcm configfile
ansible.builtin.include_tasks:
file: pre_tasks/hdblcm_configfile.yml
when:
- __sap_hana_install_fact_is_main_host
- not __sap_hana_install_fact_is_installed
apply:
tags: sap_hana_install_create_configfile
when: >
(not __sap_hana_install_fact_is_installed and __sap_hana_install_fact_is_main_host) or
('sap_hana_install_create_configfile' in ansible_run_tags | d([]))
tags: sap_hana_install_create_configfile
Loading