Skip to content

Commit

Permalink
Merge pull request #51 from Simranpal/feature/extract-nw-archives
Browse files Browse the repository at this point in the history
Add support to extract nw media archives
  • Loading branch information
Simranpal authored Jul 6, 2020
2 parents 611687e + da99d01 commit 82f1049
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ services:
addons:
apt:
sources:
- sourceline: 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main'
key_url: 'https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub'
- sourceline: 'deb http://repo.saltstack.com/apt/ubuntu/18.04/amd64/2019.2/ bionic main'
key_url: 'http://repo.saltstack.com/apt/ubuntu/18.04/amd64/2019.2/SALTSTACK-GPG-KEY.pub'
packages:
- salt-common

Expand Down
2 changes: 1 addition & 1 deletion netweaver/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ netweaver:
install_packages: true
clean_nfs: True
installation_folder: /tmp/swpm_unattended
swpm_extract_dir: /sapmedia/NW/SWPM
nw_extract_dir: /sapmedia/NW
additional_dvds: []
ha_enabled: True
nfs_version: nfs4 # Used to connect to the nfs share
Expand Down
12 changes: 0 additions & 12 deletions netweaver/extract_installer.sls

This file was deleted.

76 changes: 76 additions & 0 deletions netweaver/extract_nw_archives.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{% set nw_extract_dir = netweaver.nw_extract_dir %}
{% set swpm_extract_dir = nw_extract_dir| path_join('SWPM') %}
setup_nw_extract_directory:
file.directory:
- name: {{ nw_extract_dir }}
- mode: 755
- makedirs: True
{# Install unrar tool needed for extracting multipart archives, based on SLES version #}
{% set unrar_package = 'unrar_wrapper' if grains['osrelease_info'][0] == 15 else 'unrar' %}
install_unrar_package:
pkg.installed:
- name: {{ unrar_package }}
{% if netweaver.sapcar_exe_file is defined and netweaver.swpm_sar_file is defined %}
extract_installer_file:
sapcar.extracted:
- name: {{ netweaver.swpm_sar_file }}
- sapcar_exe: {{ netweaver.sapcar_exe_file }}
- output_dir: {{ swpm_extract_dir }}
- options: "-manifest SIGNATURE.SMF"
{% endif %}
{% set additional_dvd_folders = [] %}
{% for dvd_entry in netweaver.additional_dvds %}
{# Set the extraction path for various archives in dvds list based on the dvd extension name #}
{% set dvd = dvd_entry | string %}
{% set dvd_folder_name = salt['file.basename'](dvd.split('.')[0]) %}
{% set dvd_extract_dir = nw_extract_dir | path_join(dvd_folder_name) %}
{# Conditions to extract archives based on extension name #}
{%- if dvd.endswith((".ZIP", ".zip", ".RAR", ".rar")) %}
extract_nw_archive_{{ dvd }}:
archive.extracted:
- name: {{ dvd_extract_dir }}
- enforce_toplevel: False
- source: {{ dvd }}
{% do additional_dvd_folders.append(dvd_extract_dir) %}
{%- elif dvd.endswith((".exe", ".EXE")) %}
extract_nw_multipart_archive_{{ dvd }}:
cmd.run:
- name: unrar x {{ dvd }}
- cwd: {{ nw_extract_dir }}
- require:
- install_unrar_package
{# As temporary workaround, the extraction path for multpart archive is calculated from archive name #}
{# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive #}
{% set exe_dvd_extract_dir = nw_extract_dir | path_join(dvd_folder_name.split('_')[0]) %}
{% do additional_dvd_folders.append(exe_dvd_extract_dir) %}
{%- elif dvd.endswith((".sar", ".SAR")) and netweaver.sapcar_exe_file is defined %}
extract_sar_archive_{{ dvd }}:
sapcar.extracted:
- name: {{ dvd }}
- sapcar_exe: {{ netweaver.sapcar_exe_file }}
- output_dir: {{ dvd_extract_dir }}
- options: "-manifest SIGNATURE.SMF"
{% do additional_dvd_folders.append(dvd_extract_dir) %}
{%- else %}
{% do additional_dvd_folders.append(dvd) %}
{%- endif %}
{%- endfor %}
3 changes: 2 additions & 1 deletion netweaver/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
include:
- netweaver.setup
- netweaver.saptune
- netweaver.extract_installer
- netweaver.extract_nw_archives
- netweaver.install_pydbapi
- netweaver.install_ascs
- netweaver.install_ers
- netweaver.ha_cluster
Expand Down
6 changes: 4 additions & 2 deletions netweaver/install_aas.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{%- from "netweaver/extract_nw_archives.sls" import swpm_extract_dir with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance == 'aas' %}
Expand Down Expand Up @@ -63,7 +65,7 @@ netweaver_install_{{ instance_name }}:
- name: {{ node.sid.lower() }}
- inst: {{ instance }}
- password: {{ netweaver.sid_adm_password|default(netweaver.master_password) }}
- software_path: {{ netweaver.swpm_folder|default(netweaver.swpm_extract_dir) }}
- software_path: {{ netweaver.swpm_folder|default(swpm_extract_dir) }}
- root_user: {{ node.root_user }}
- root_password: {{ node.root_password }}
- config_file: {{ inifile }}
Expand All @@ -72,7 +74,7 @@ netweaver_install_{{ instance_name }}:
- virtual_host_mask: {{ node.virtual_host_mask|default(24) }}
- product_id: {{ product_id }}
- cwd: {{ netweaver.installation_folder }}
- additional_dvds: {{ netweaver.additional_dvds }}
- additional_dvds: {{ additional_dvd_folders }}
- require:
- create_aas_inifile_{{ instance_name }}
- wait_for_db_{{ instance_name }}
Expand Down
7 changes: 5 additions & 2 deletions netweaver/install_ascs.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{%- from "netweaver/extract_nw_archives.sls" import swpm_extract_dir with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance == 'ascs' %}
Expand Down Expand Up @@ -39,7 +42,7 @@ netweaver_install_{{ instance_name }}:
- name: {{ node.sid.lower() }}
- inst: {{ instance }}
- password: {{ netweaver.sid_adm_password|default(netweaver.master_password) }}
- software_path: {{ netweaver.swpm_folder|default(netweaver.swpm_extract_dir) }}
- software_path: {{ netweaver.swpm_folder|default(swpm_extract_dir) }}
- root_user: {{ node.root_user }}
- root_password: {{ node.root_password }}
- config_file: {{ inifile }}
Expand All @@ -48,7 +51,7 @@ netweaver_install_{{ instance_name }}:
- virtual_host_mask: {{ node.virtual_host_mask|default(24) }}
- product_id: {{ product_id }}
- cwd: {{ netweaver.installation_folder }}
- additional_dvds: {{ netweaver.additional_dvds }}
- additional_dvds: {{ additional_dvd_folders }}
- require:
- create_ascs_inifile_{{ instance_name }}
Expand Down
7 changes: 5 additions & 2 deletions netweaver/install_db.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{%- from "netweaver/extract_nw_archives.sls" import swpm_extract_dir with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance == 'db' %}
Expand Down Expand Up @@ -64,7 +67,7 @@ netweaver_install_{{ instance_name }}:
- port: 3{{ hana_instance }}15
- schema_name: {{ netweaver.schema.name|default('SAPABAP1') }}
- schema_password: {{ netweaver.schema.password }}
- software_path: {{ netweaver.swpm_folder|default(netweaver.swpm_extract_dir) }}
- software_path: {{ netweaver.swpm_folder|default(swpm_extract_dir) }}
- root_user: {{ node.root_user }}
- root_password: {{ node.root_password }}
- config_file: {{ inifile }}
Expand All @@ -73,7 +76,7 @@ netweaver_install_{{ instance_name }}:
- virtual_host_mask: {{ node.virtual_host_mask|default(24) }}
- product_id: {{ product_id }}
- cwd: {{ netweaver.installation_folder }}
- additional_dvds: {{ netweaver.additional_dvds }}
- additional_dvds: {{ additional_dvd_folders }}
- require:
- create_db_inifile_{{ instance_name }}
- wait_for_hana_{{ instance_name }}
Expand Down
7 changes: 5 additions & 2 deletions netweaver/install_ers.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{%- from "netweaver/extract_nw_archives.sls" import swpm_extract_dir with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance == 'ers' %}
Expand Down Expand Up @@ -46,7 +49,7 @@ netweaver_install_{{ instance_name }}:
- name: {{ node.sid.lower() }}
- inst: {{ instance }}
- password: {{ netweaver.sid_adm_password|default(netweaver.master_password) }}
- software_path: {{ netweaver.swpm_folder|default(netweaver.swpm_extract_dir) }}
- software_path: {{ netweaver.swpm_folder|default(swpm_extract_dir) }}
- root_user: {{ node.root_user }}
- root_password: {{ node.root_password }}
- config_file: {{ inifile }}
Expand All @@ -55,7 +58,7 @@ netweaver_install_{{ instance_name }}:
- virtual_host_mask: {{ node.virtual_host_mask|default(24) }}
- product_id: {{ product_id }}
- cwd: {{ netweaver.installation_folder }}
- additional_dvds: {{ netweaver.additional_dvds }}
- additional_dvds: {{ additional_dvd_folders }}
- ascs_password: {{ netweaver.sid_adm_password|default(netweaver.master_password) }}
- timeout: 1500
- interval: {{ node.interval|default(30) }}
Expand Down
7 changes: 5 additions & 2 deletions netweaver/install_pas.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{%- from "netweaver/extract_nw_archives.sls" import swpm_extract_dir with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance == 'pas' %}
Expand Down Expand Up @@ -64,7 +67,7 @@ netweaver_install_{{ instance_name }}:
- name: {{ node.sid.lower() }}
- inst: {{ instance }}
- password: {{ netweaver.sid_adm_password|default(netweaver.master_password) }}
- software_path: {{ netweaver.swpm_folder|default(netweaver.swpm_extract_dir) }}
- software_path: {{ netweaver.swpm_folder|default(swpm_extract_dir) }}
- root_user: {{ node.root_user }}
- root_password: {{ node.root_password }}
- config_file: {{ inifile }}
Expand All @@ -73,7 +76,7 @@ netweaver_install_{{ instance_name }}:
- virtual_host_mask: {{ node.virtual_host_mask|default(24) }}
- product_id: {{ product_id }}
- cwd: {{ netweaver.installation_folder }}
- additional_dvds: {{ netweaver.additional_dvds }}
- additional_dvds: {{ additional_dvd_folders }}
- require:
- create_pas_inifile_{{ instance_name }}
- wait_for_db_{{ instance_name }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{%- from "netweaver/map.jinja" import netweaver with context -%}
{%- from "netweaver/extract_nw_archives.sls" import additional_dvd_folders with context -%}
{% set host = grains['host'] %}
{% for node in netweaver.nodes if node.host == host and node.sap_instance in ['db', 'pas', 'aas'] %}
Expand All @@ -19,7 +21,7 @@ nw_install_python_pip:
nw_extract_pydbapi_client:
hana.pydbapi_extracted:
- name: PYDBAPI.TGZ
- software_folders: {{ netweaver.additional_dvds }}
- software_folders: {{ additional_dvd_folders }}
- output_dir: {{ pydbapi_output_dir }}
- hana_version: '20'
- force: true
Expand Down
1 change: 0 additions & 1 deletion netweaver/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

{% import_yaml "netweaver/defaults.yaml" as defaults %}
{% set netweaver = salt['pillar.get']('netweaver', default=defaults.netweaver, merge=True) %}
{% do netweaver.update({'additional_dvds': netweaver.additional_dvds|json}) %}
1 change: 0 additions & 1 deletion netweaver/setup/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include:
{% if netweaver.install_packages is sameas true %}
- netweaver.setup.packages
{% endif %}
- netweaver.setup.install_pydbapi
- netweaver.setup.shared_disk
- netweaver.setup.virtual_addresses
- netweaver.setup.sap_nfs
Expand Down
13 changes: 8 additions & 5 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@ netweaver:
# Specify the path to already extracted SWPM installer folder
swpm_folder: your_swpm_folder_absolute_path
# Or specify the path to the sapcar executable & SWPM installer sar archive, to extract the installer
# The sar archive will be extracted to path specified at swpm_extract_dir (optional, by default /sapmedia/NW/SWPM)
# The sar archive will be extracted to a subfolder SWPM, under nw_extract_dir (optional, by default /sapmedia/NW/SWPM)
# Make sure to use the latest/compatible version of sapcar executable, and that it has correct execute permissions
sapcar_exe_file: your_sapcar_exe_file_absolute_path
swpm_sar_file: your_swpm_sar_file_absolute_path
swpm_extract_dir: location_to_extract_swpm_sar_absolute_path
nw_extract_dir: location_to_extract_nw_media_absolute_path
sapexe_folder: your_sapexe_sar_folder_absolute_path
# Folder where the installation files are stored. /tmp/swpm_unattended by default. Set None to use
# SAP default folders (it will only work with ASCS and ERS).
# This folder content will be removed before the installation so be extra careful!
installation_folder: /tmp/swpm_unattended
# DB/PAS/AAS instances require additional DVD folders like NW Export or HDB Client folder
additional_dvd:
- required_dvd1_folder_absolute_path
- required_dvd2_folder_absolute_path
# Provide the absolute path to software folder or archives with additional SAP software needed to install netweaver
additional_dvds:
- /sapmedia/HANA/51053492
- /sapmedia/NW/51050829_3.ZIP
- /tmp/sap_media/51050818_part1.EXE
- /tmp/sapmedia/IMDB_SERVER.SAR
# Enable operations in ASCS and ERS to set HA environment correctly (HA cluster is not installed)
ha_enabled: True

Expand Down
8 changes: 8 additions & 0 deletions sapnwbootstrap-formula.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu May 28 22:00:38 UTC 2020 - Simranpal Singh <simranpal.singh@suse.com>

- Version 0.5.0
* Add support to extract nw media archives
* This change brings non backward compatible changes. Remove default swpm installer extract directory and
add nw_extract_dir variable to store all extracted NW media

-------------------------------------------------------------------
Mon May 18 15:02:26 UTC 2020 - Xabier Arbulu <xarbulu@suse.com>

Expand Down

0 comments on commit 82f1049

Please sign in to comment.