Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #35 from berndfinger/master
Browse files Browse the repository at this point in the history
solve issues #22, #23, #36...#44
  • Loading branch information
rhmk authored Jul 27, 2023
2 parents 4308c24 + 188fee4 commit addee6e
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 138 deletions.
165 changes: 129 additions & 36 deletions README.md

Large diffs are not rendered by default.

72 changes: 60 additions & 12 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,69 @@
# Global Default variables
# Adapt to your default settings

# Target host path and file name for the bundle installation file
sap_hana_deployment_bundle_path:
sap_hana_deployment_bundle_sar_file_name:
# Directories and their permissions to set or verify
sap_hana_deployment_directories_permissions:
- { name: /hana/shared, mode: '0755' }
- { name: /hana/data, mode: '0755' }
- { name: /hana/log, mode: '0755' }
- { name: /usr/sap, mode: '0755' }

# Target host path and file name for the zip installation file
sap_hana_deployment_zip_path:
sap_hana_deployment_zip_file_name:
# If the following variable is set to 'yes', set permissions of
# the directories in sap_hana_deployment_directories_permissions to the specified values.
# If the variable is set to 'no', verify these permissions. This is the default.
sap_hana_deployment_set_permissions: no

# Target host path and file name for the sapcar installation file
sap_hana_deployment_sapcar_path:
# If the HANA installation files have already been extracted on the managed node, specify
# the name of the directory which contains hdblcm here.
# The role sap-hana-mediacheck can be used to define this variable
# Example: /hana_install
sap_hana_installdir:

# Directory of the SAP HANA bundle (.SAR or .ZIP) file on the managed node
# Example: /sap_download
sap_hana_deployment_bundle_path_mn:

# File name of the SAP HANA bundle (.SAR or .ZIP) file:
# Examples: SAP_HANA_DATABASE200_54_Linux_on_x86_64.SAR, 51055101.ZIP
sap_hana_deployment_bundle_file_name:

# File name of the SAPCAR executable (only needed in case of a SAP HANA bundle SAR file)
# Example: SAPCAR_1211-80000935.EXE
sap_hana_deployment_sapcar_file_name:

# if the previous variables are undefined because you do not want to provide a bundle
# you can define sap_hana_installdir variable, which points to the directory containing hdblcm
# the role sap-hana-mediacheck can be used to define this variable
sap_hana_installdir:
# Directory of the SAPCAR executable on the managed node (only needed in case of a SAP HANA bundle SAR file)
# Example: /usr/local/bin
sap_hana_deployment_sapcar_path_mn:

# Are the SAP HANA bundle file (and sapcar) already on the managed node?
sap_hana_deployment_bundle_is_on_managed_node: no

# Are the SAP HANA bundle file (and sapcar) on the control node?
sap_hana_deployment_bundle_is_on_control_node: no

# Directory of the SAP HANA bundle (.SAR or .ZIP) file on the control node
# (only needed in case of sap_hana_deployment_bundle_is_on_control_node)
# Example: /sap_download
sap_hana_deployment_bundle_path_cn:

# Directory of the SAPCAR executable on the control node
# (only needed in case of a SAP HANA bundle SAR file and
# only in case of sap_hana_deployment_bundle_is_on_control_node)
# Example: /sap_download
sap_hana_deployment_sapcar_path_cn:

# If the SAP HANA bundle file and sapcar are on another node, specify
# the login user, the host name, and the directory name to be used for the
# first argument to the scp command
# Example: root@host01:/sap_download
sap_hana_deployment_sap_software_remote_location:

# Directory where to extract the SAP HANA bundle (.SAR or .ZIP) file on the managed node
# Example: /sap_extract
sap_hana_deployment_hana_extraction_path:

# Apply a SAP HANA DB license only? Default is no.
sap_hana_deployment_apply_license_only: no

# Target host path and file name for the license file
sap_hana_deployment_license_path:
Expand Down Expand Up @@ -48,6 +95,7 @@ sap_hana_deployment_hana_db_system_password:
sap_hana_deployment_system_restart: 'n'
sap_hana_deployment_create_initial_tenant:
sap_hana_deployment_hostname:
sap_hana_deployment_addhosts:
sap_hana_deployment_xs_install: 'n'
sap_hana_deployment_xs_path:
sap_hana_deployment_xs_orgname: 'orgname'
Expand Down
11 changes: 11 additions & 0 deletions files/tmp/tail-f-hdblcm-install-trc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#/bin/bash

_HDBLCM_PID=$(ps -ef | awk '/hdblcm/&&/instlog_dir/&&!/awk/{print $2}')

if [[ ${_HDBLCM_PID}. != "." ]]; then
_HDBLCM_TRC_FILE=/var/tmp/hdblcm_$(ps -ef | grep hdblcm | awk 'BEGIN{RS=" "}/instlog_dir/{split ($0, a, "install_"); print a[2]}')*.trc
echo "hdblcm trace file: ${_HDBLCM_TRC_FILE}"
tail -100f ${_HDBLCM_TRC_FILE}
else
echo "No hdblcm process found."
fi
9 changes: 4 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
galaxy_info:
author: Red Hat SAP Community of Practice
description: Deploys `SAP HANA` on the given host(s)
description: Deploys SAP HANA
company: Red Hat, Inc.
license: Apache
min_ansible_version: 2.5
min_ansible_version: 2.7
platforms:
- name: EL
versions: [ 7, 8 ]

galaxy_tags: [ 'hana', 'rhel', 'sap' ]

galaxy_tags: [ 'sap', 'hana', 'rhel' ]
dependencies: []
4 changes: 2 additions & 2 deletions tasks/license.yml → tasks/apply_hana_license.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

- name: Apply HANA license to the new deployed instance
- name: Apply HANA DB license to the newly deployed instance
shell: |
/usr/sap/{{ sap_hana_deployment_hana_sid | upper }}/HDB{{ sap_hana_deployment_hana_instance_number }}/exe/hdbsql \
-i {{ sap_hana_deployment_hana_instance_number }} -u SYSTEM -p {{ sap_hana_deployment_hana_db_system_password }} -m <<EOF
SET SYSTEM LICENSE '$(cat {{ sap_hana_deployment_license_path }}/{{ sap_hana_deployment_license_file_name }})';
EOF
args:
executable: /bin/bash
executable: /bin/bash
become: yes
become_user: "{{ sap_hana_deployment_hana_sid | lower }}adm"
register: addlicense
Expand Down
15 changes: 15 additions & 0 deletions tasks/directories-permissions-assert-loop-block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

# loop block for hana_deploy.yml

- name: Get permissions of {{ line_item.name }}
stat:
path: "{{ line_item.name }}"
register: __sap_hana_deployment_register_stat

- name: Assert that permissions of {{ line_item.name }} are '{{ line_item.mode }}'
assert:
that: "__sap_hana_deployment_register_stat.stat.mode == '{{ line_item.mode }}'"
fail_msg: "FAIL: Directory {{ line_item.name }} has permissions '{{ __sap_hana_deployment_register_stat.stat.mode }}'
but needs to have '{{ line_item.mode }}'!"
success_msg: "PASS: Directory {{ line_item.name }} has correct permissions '{{ __sap_hana_deployment_register_stat.stat.mode }}'."
20 changes: 10 additions & 10 deletions tasks/ev_group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
- name: Evaluate if 'sapsys' group already exists
shell: >
set -o pipefail && grep sapsys /etc/group | cut -d ":" -f 3
register: checkgroup
register: __sap_hana_deployment_register_checkgroup
changed_when: false
failed_when: checkgroup.rc != 0
ignore_errors: true

- name: Get next available group ID in the 1000-1100 range
shell: >
awk -F: '{ uid[$3]=1 }END{ for(x=1000; x<=1100; x++) { if(uid[x] != ""){}else{print x; exit; }}}' /etc/group
register: nextgroupid
when: checkgroup.stdout | length = 0
register: __sap_hana_deployment_register_nextgroupid
when: __sap_hana_deployment_register_checkgroup.stdout | length == 0

- name: Set fact for Group ID when 'sapsys' group does not exist
- name: Set fact for group ID if 'sapsys' group does not exist
set_fact:
sap_hana_deployment_hana_groupid: "{{ nextgroupid.stdout }}"
when: checkgroup.stdout | length = 0
sap_hana_deployment_hana_groupid: "{{ __sap_hana_deployment_register_nextgroupid.stdout }}"
when: __sap_hana_deployment_register_checkgroup.stdout | length == 0

- name: Set fact for Group ID when 'sapsys' group does exist
- name: Set fact for group ID if 'sapsys' group exists
set_fact:
sap_hana_deployment_hana_groupid: "{{ checkgroup.stdout }}"
when: checkgroup.stdout | length > 0
sap_hana_deployment_hana_groupid: "{{ __sap_hana_deployment_register_checkgroup.stdout }}"
when: __sap_hana_deployment_register_checkgroup.stdout | length > 0
8 changes: 4 additions & 4 deletions tasks/ev_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
- name: Get next available user ID in the 1000-1100 range
shell: >
awk -F: '{ uid[$3]=1 }END{ for(x=1000; x<=1100; x++) { if(uid[x] != ""){}else{ print x; exit; }}}' /etc/passwd
register: nextuserid
register: __sap_hana_deployment_register_nextuserid
changed_when: false
failed_when: nextuserid.rc != 0
failed_when: __sap_hana_deployment_register_nextuserid is failed

- name: Set fact for User ID
- name: Set fact for user ID
set_fact:
sap_hana_deployment_hana_userid: "{{ nextuserid.stdout }}"
sap_hana_deployment_hana_userid: "{{ __sap_hana_deployment_register_nextuserid.stdout }}"
60 changes: 0 additions & 60 deletions tasks/hana_deploy.yml

This file was deleted.

70 changes: 70 additions & 0 deletions tasks/install_hana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---

- name: Check if file 'hdblcm' is in the SAP HANA installation directory
stat:
path: "{{ sap_hana_installdir + '/hdblcm' }}"
register: __sap_hana_deployment_register_hdblcm_stat
failed_when: not __sap_hana_deployment_register_hdblcm_stat.stat.exists
when: sap_hana_deployment_install_primary|d(true)

- name: Create temporary directory to store the processed template
tempfile:
state: directory
suffix: hanaconfig
register: __sap_hana_deployment_register_tmpdir

- name: Process HANA configfile template
template:
src: "{{ role_path }}/templates/configfile.j2"
dest: "{{ __sap_hana_deployment_register_tmpdir.path }}/configfile.cfg"
mode: '0644'
register: __sap_hana_deployment_register_cftemplate

- name: Install SAP HANA
block:

- name: Copy file tail-f-hdblcm-install-trc.sh to '{{ __sap_hana_deployment_register_tmpdir.path }}'
copy:
src: tmp/tail-f-hdblcm-install-trc.sh
dest: "{{ __sap_hana_deployment_register_tmpdir.path }}/tail-f-hdblcm-install-trc.sh"
owner: root
group: root
mode: '0755'

- name: Show how to watch the install process in real time
debug:
msg:
- 'Once the task "Perform the SAP HANA installation" has started, you can use the following command'
- 'in a terminal session on the managed node to watch the install progress in real time:'
- "{{ __sap_hana_deployment_register_tmpdir.path }}/tail-f-hdblcm-install-trc.sh"
- 'Alternatively, you can run the following command on the control node:'
- "ssh {{ inventory_hostname }} {{ __sap_hana_deployment_register_tmpdir.path }}/tail-f-hdblcm-install-trc.sh"

- name: Perform the SAP HANA installation
command: "./hdblcm {{ sap_hana_deployment_hdblcm_extraargs }}
--configfile={{ __sap_hana_deployment_register_tmpdir.path }}/configfile.cfg
-b"
register: __sap_hana_deployment_register_hdblcm_install
args:
chdir: "{{ sap_hana_installdir }}"
changed_when: "'SAP HANA Lifecycle Management' in __sap_hana_deployment_register_hdblcm_install.stdout"

when: sap_hana_deployment_install_primary|d(true)

- name: Add hosts to the existing SAP HANA installation
command: "./hdblcm {{ sap_hana_deployment_hdblcm_extraargs }}
--action=add_hosts
--addhosts={{ sap_hana_deployment_addhosts }}
--password={{ sap_hana_deployment_sidadm_password }}
--configfile={{ __sap_hana_deployment_register_tmpdir.path }}/configfile.cfg
-b"
register: __sap_hana_deployment_register_hdblcm_add_hosts
args:
chdir: "{{ sap_hana_deployment_hana_install_path }}/{{ sap_hana_deployment_hana_sid }}/hdblcm"
changed_when: "'SAP HANA Lifecycle Management' in __sap_hana_deployment_register_hdblcm_add_hosts.stdout"
when: not sap_hana_deployment_install_primary|d(true)

- name: Show the result of hdblcm add_hosts
debug:
var: __sap_hana_deployment_register_hdblcm_add_hosts.stdout
when: not sap_hana_deployment_install_primary|d(true)
45 changes: 37 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
---

- name: show sap_hana_deployment_hana_userid
debug:
var: sap_hana_deployment_hana_userid

- name: show sap_hana_deployment_hana_groupid
debug:
var: sap_hana_deployment_hana_groupid

- import_tasks: ev_user.yml
when:
- sap_hana_deployment_hana_userid == ''
- not sap_hana_deployment_apply_license
- ((sap_hana_deployment_hana_userid is undefined) or
(sap_hana_deployment_hana_userid is none) or
(sap_hana_deployment_hana_userid | trim == '')
)
- not sap_hana_deployment_apply_license_only
- sap_hana_deployment_install_primary|d(true)

- import_tasks: ev_group.yml
when:
- sap_hana_deployment_hana_groupid == ''
- not sap_hana_deployment_apply_license
- ((sap_hana_deployment_hana_groupid is undefined) or
(sap_hana_deployment_hana_groupid is none) or
(sap_hana_deployment_hana_groupid | trim == '')
)
- not sap_hana_deployment_apply_license_only
- sap_hana_deployment_install_primary|d(true)

- import_tasks: password_facts.yml
when: sap_hana_deployment_use_master_password == 'y'

- import_tasks: hana_deploy.yml
when: not sap_hana_deployment_apply_license
- import_tasks: set_or_verify_permissions.yml
when:
- not sap_hana_deployment_apply_license_only
- sap_hana_deployment_install_primary|d(true)

- import_tasks: license.yml
when: sap_hana_deployment_apply_license
- import_tasks: provide_hana_installation_bundle.yml
when:
- (( sap_hana_installdir is none ) or ( sap_hana_installdir | trim == ''))
- not sap_hana_deployment_apply_license_only
- sap_hana_deployment_install_primary|d(true)

- import_tasks: install_hana.yml
when: not sap_hana_deployment_apply_license_only

- import_tasks: apply_hana_license.yml
when:
- (sap_hana_deployment_apply_license_only or sap_hana_deployment_apply_license)
- sap_hana_deployment_install_primary|d(true)
Loading

0 comments on commit addee6e

Please sign in to comment.