Skip to content

Commit

Permalink
Merge pull request #37 from sap-linuxlab/swpm
Browse files Browse the repository at this point in the history
Swpm
  • Loading branch information
Steven Stringer authored Jul 11, 2023
2 parents ca38a84 + f32b9b7 commit 00c5182
Show file tree
Hide file tree
Showing 17 changed files with 512 additions and 4 deletions.
28 changes: 28 additions & 0 deletions playbooks/swpm_single.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- name: Use SWPM role
hosts: app
any_errors_fatal: true
remote_user: my_ansible_user
become: true
vars:
sapcar_exe: '/media/sapcar'
sapinst_sar: '/media/SWPM20SP14_2-80003424.SAR'
install_mode: 'guided'
guided_product_id: 'NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP'
guided_s4_sid: 'S41'
guided_master_password: 'DontUseThisPassw0rd'
guided_ascs_instance_number: '00'
guided_ci_instance_number: '01'
guided_hana_hostname: 'hanasrv01'
guided_hana_sid: 'HN1'
guided_hana_instance: '00'
guided_hana_systemdb_system_password: 'DontUseThisPassw0rd'
guided_sapexe_sar_path: '/media/SAPEXE_100-70006642.SAR'
guided_igs_sar_path: '/media/igsexe_2-70005417.sar'
guided_igs_helper_sar_path: '/media/igshelper_17-10010245.sar'
guided_sapexedb_sar_path: '/media/SAPEXEDB_100-70006641.SAR'
guided_media_path: '/media'
guided_hana_admin_user_password: 'DontUseThisPassw0rd'

roles:
- { role: swpm_single }
2 changes: 1 addition & 1 deletion roles/cluster/tasks/tasks_corosync_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
# to the others
when: int_var_node_is_primary

- name: Copy cluster secret to other hosts
- name: Copy cluster secret
ansible.posix.synchronize:
src: /etc/corosync/authkey
dest: /etc/corosync/authkey
Expand Down
2 changes: 1 addition & 1 deletion roles/cluster/vars/aws_native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cluster_config:
name: 'op start'
interval: '0'
timeout: '180'
_:
op_stop:
name: 'op stop'
interval: '0'
timeout: '180'
Expand Down
7 changes: 7 additions & 0 deletions roles/hana_install/tasks/pre-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@
- hana_master_password is ansible.builtin.regex('[a-z]+')
- hana_master_password is ansible.builtin.regex('[A-Z]+')
- hana_master_password is ansible.builtin.regex('[0-9]+')
fail_msg: >-
The value of the variable 'hana_master_password' does not meet the minimum
criteria. HANA passwords must be at least 8 characters long and contain
1 uppercase character, 1 lowercase character and a number. Correct the
password before re-running the role.
success_msg: >-
The supplied hana master password meets the requirement.
- name: Determine installation status
ansible.builtin.stat:
Expand Down
1 change: 1 addition & 0 deletions roles/hana_system_replication/tasks/post-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
check_mode: false
no_log: true


- name: Read SAP HANA System Replication configuration
community.general.read_csv:
path: "{{ int_fact_post_sys_rep_general_result_file }}"
Expand Down
1 change: 1 addition & 0 deletions roles/hana_system_replication/tasks/pre-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
check_mode: false
no_log: true


- name: Read tenant information
community.general.read_csv:
path: "{{ int_fact_sys_rep_tier_count_result_file }}"
Expand Down
1 change: 1 addition & 0 deletions roles/hana_system_replication_hooks/tasks/pre-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
check_mode: false
no_log: true


- name: Read SAP HANA System Replication configuration
community.general.read_csv:
path: "{{ int_fact_pre_sys_rep_general_result_file }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/sles_register/tasks/post-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
that: int_fact_post_registration_status == 'Registered'
success_msg: "The system is registered"
fail_msg: >
Registration appears to have been unsuccessful, check the output of the
registration command and ensure the registration code is correct.
SUSEConnect reports that the host is not registered. This could be a
problem with your registration code or the registration process.
when: not ansible_check_mode
63 changes: 63 additions & 0 deletions roles/swpm_single/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# swpm_single

The SWPM role will eventually offer two ways of provisioning SAP software,
Guided and passthrough. Guided mode allows users to provide variables to ansible
in order to install a relatively small number of SAP products in a 'standalone'
scenario (no high availability).

The passthrough mode will allow users to provide their own configuration files
in the correct SWPM format and will allow for the installation of any SAP
software product that is supported by SWPM.

Currently, only the guided mode is supported and this currently only supports
S4 2022.

It is strongly recommended that users acquire SAP software using SAP's
Maintenance Planner tool. This tool will collate all of the required software
for a full S4 installation and add it to the user's software basket so that it
can be downloaded using SAP Download Manager. The process of using Maintenance
Planner and Download Manager is out of scope for this document.

## Variables

### Required variables

* install_mode - string - defines the install mode. Supported values, 'guided'.
* sapcar_exe - string - the location of the sapcar executable.
* sapinst_sar - string - the location of the SWPM sar archive.

### Guided variables

The following variables are required when `install_mode` is set to `guided`.

* guided_product - the product ID of the install. Currently supported product
IDs are:
* NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP

### NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP variables

When using the guided install of NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP, the
following variables must be set:

* guided_s4_sid - string - The SID of the S4 system to install
* guided_master_password - string - The master password to use for the s4
install
* guided_ascs_instance_number - string - the ASCS instance number, must be a two
digit number, for example '00'
* guided_ci_instance_number - string - the PAS instance number, must be a two
digit number and must not be the same as the ASCS instance.
* guided_hana_hostname - string - the hostname of the HANA server which must
already be installed.
* guided_hana_sid - string - The SID of the target HANA instance system.
* guided_hana_instance - string - The two digit instance number of the target
HANA system.
* guided_hana_systemdb_system_password - string - The SystemDB password of the
target HANA system.
* guided_hana_admin_user_password - string - The password of the HANA user
on the HANA server/cluster (\<sid\>adm).
* guided_sapexe_sar_path - string - The full path of the sapcar exe.
* guided_igs_sar_path - string - The full path of the IGS archive.
* guided_igs_helper_sar_path - The full path of the IGS Helper archive.
* guided_sapexedb_sar_path - The full path of the SAPEXEDB archive.
* guided_media_path - The full path of the directory containing the S4 database
archive.
6 changes: 6 additions & 0 deletions roles/swpm_single/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Guided defaults for onehost S4
guided_network_domain: "{{ ansible_facts['domain'] }}"
guided_ascs_virtual_hostname: "{{ ansible_facts['hostname'] }}"
guided_ci_virtual_hostname: "{{ ansible_facts['hostname'] }}"
guided_scs_virtual_hostname: "{{ ansible_facts['hostname'] }}"
guided_hana_tenant_sid: "{{ guided_hana_sid }}"
12 changes: 12 additions & 0 deletions roles/swpm_single/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Run Pre-Checks
ansible.builtin.include_tasks:
./pre-checks.yml

- name: Run Tasks
ansible.builtin.include_tasks:
./tasks.yml

- name: Run Post-Checks
ansible.builtin.include_tasks:
./post-checks.yml
1 change: 1 addition & 0 deletions roles/swpm_single/tasks/post-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
72 changes: 72 additions & 0 deletions roles/swpm_single/tasks/pre-checks-onehost-s4hana2022.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
- name: Assert that there is only one host in the play
ansible.builtin.assert:
that: "{{ ansible_play_hosts | length }} == 1"
fail_msg: >-
When running a guided install of a OneHost solution, only one play hosts
is expected. Ensure that only one host is selected in the play when
running this role.
success_msg: >-
The correct number of hosts are in the play (one).
- name: Ensure that required variables are defined for NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP
ansible.builtin.assert:
that: "{{ item }} is defined"
fail_msg: >-
The variable '{{ item }}' is requred when running a guided install of
NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP but it is not currently defined.
Ensure that this variable is defined before re-running the role.
success_msg: >-
The variable '{{ item }}' is defined.
loop: "{{ int_var_guided_s4hana2022_onehost_required_variables }}"
when:
- install_mode == 'guided'
- guided_product_id == 'NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP'

### Check the content of the variables

- name: Ensure provided SIDs are compliant
ansible.builtin.assert:
that:
"{{ item }} is ansible.builtin.regex('^[A-Z]{1}[A-Z0-9]{2}$')"
fail_msg: >-
The variable '{{ item }}' must consist of three characters. Characters
must be uppercase alphabetical characters or numbers only. The first
character may only be an alphabetical character. The current pattern
is not compliant.
success_msg: >-
'{{ item }}' matches the required pattern.
loop:
- guided_s4_sid
- guided_hana_sid
- guided_hana_tenant_sid

- name: Ensure provided SIDs are not restricted
ansible.builtin.assert:
that:
"{{ item }} not in int_var_reserved_sids"
fail_msg: >-
The variable '{{ item }}' is currently set to a reserved value that may
not be used. Change this to an allowed SID before re-running the role
success_msg: >-
'{{ item }}' is not a restricted SID.
loop:
- guided_s4_sid
- guided_hana_sid
- guided_hana_tenant_sid

- name: Check instance numbers are compliant
ansible.builtin.assert:
that:
- "{{ item }} is ansible.builtin.regex('^[0-9]{2}$')"
- "{{ item }} != '99'"
fail_msg: >-
The variable '{{ item }}' must be a string consisting of two numbers.
All combination apart from '99' are allowed. The current pattern
is not compliant.
success_msg: >-
'{{ item }}' matches the required pattern.
loop:
- guided_ascs_instance_number
- guided_ci_instance_number
- guided_hana_instance
89 changes: 89 additions & 0 deletions roles/swpm_single/tasks/pre-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
- name: Assert the required variables exists
ansible.builtin.assert:
that: "{{ item }} is defined"
fail_msg: >-
The variable {{ item }} must be defined. Ensure the variable is defined
before re-running the role.
success_msg: >-
The variable {{ item }} is defined
loop: "{{ int_var_required_variables }}"

- name: Check install mode is supported
ansible.builtin.assert:
that: "'{{ install_mode }}' in int_var_install_mode_support"
fail_msg: >-
The variable 'install_mode' is set to {{ install_mode }}. This is not a
supported value. Check the documentation and set the variable correctly
before re-running the role
success_msg: >-
The variable 'install_mode' is set to a supported value
({{ install_mode }}).
- name: Assert sapcar_exe is a full path
ansible.builtin.assert:
that: "'{{ sapcar_exe }}' is ansible.builtin.regex('^/')"
fail_msg: >-
The variable sapcar_exe must be a full path to the sapcar binary. The
value supplied is not a full path (it doesn't being with '/'). Ensure
a full path is supplied before re-running this role.
success_msg: >-
The variable sapcar_exe is a full path
- name: Get that sapcar binary stat data
ansible.builtin.stat:
path: ${sapcar_exe}

- name: Check HANA host for HANA SystemDB port
ansible.builtin.wait_for:
host: "{{ guided_hana_hostname }}"
port: "3{{ guided_hana_instance }}13"
state: 'started'
timeout: 5
register: int_reg_hana_port
changed_when: false
ignore_errors: true

- name: Assert that HANA port is open
ansible.builtin.assert:
that: not int_reg_hana_port.failed
fail_msg: >-
The SystemDB port '3{{ guided_hana_instance }}13' on the given hana host
'{{ guided_hana_hostname }}' does not appear to be up. Ensure that the
provided details are correct and that HANA instance is up. Ensure that
any firewalls between the hosts are permitting the required ports.
success_msg: >-
The SystemDB HANA port '3{{ guided_hana_instance }}13' on
'{{ guided_hana_hostname }}' could be reached.
# Checks for guided mode

- name: Assert that required guided mode variables are defined
ansible.builtin.assert:
that: "{{ item }} is defined"
fail_msg: >-
The variable '{{ item }}'' not defined. This variable is required when
'install_mode' is set to 'guided'. Ensure this variable is correctly set
before re-running the role.
success_msg: >-
The required variable '{{ item }} is defined'
loop: "{{ int_var_guided_required_variables }}"
when: install_mode == 'guided'

- name: Assert guided product is supported
ansible.builtin.assert:
that: "'{{ guided_product_id }}' in int_var_guided_product_support"
fail_msg: >-
The product ID specified in the variable '{{ guided_product_id }}' is not
supported. Check the role documentation for a list of supported product
IDs.
success_msg: >-
The supplied product_id ({{ guided_product_id }}) is supported by the
role.
when: install_mode == 'guided'

- name: Run NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP Pre-Checks
ansible.builtin.import_tasks: pre-checks-onehost-s4hana2022.yml
when:
- install_mode == 'guided'
- guided_product_id == 'NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP'
Loading

0 comments on commit 00c5182

Please sign in to comment.