Skip to content

Commit 9f37727

Browse files
AchimHaaser1stafaniasajusurajsbharadwajterraform-ibm-modules-ops
authored
feat: support SAP monitoring on IBM Cloud Monitoring using prometheus hana db exporter (#752)
--------- Co-authored-by: stafaniasaju <stafania.saju@ibm.com> Co-authored-by: surajsbharadwaj <suraj.bharadwaj@ibm.com> Co-authored-by: surajsbharadwaj <101711050+surajsbharadwaj@users.noreply.github.com> Co-authored-by: Terraform IBM Modules Operations <106112202+terraform-ibm-modules-ops@users.noreply.github.com>
1 parent 6b08994 commit 9f37727

19 files changed

+312
-51
lines changed

.secrets.baseline

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-12-06T13:41:59Z",
6+
"generated_at": "2024-12-17T18:27:59Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -77,6 +77,26 @@
7777
}
7878
],
7979
"results": {
80+
"modules/ansible/templates-ansible/configure-monitoring-sap/ansible_configure_monitoring.sh.tftpl": [
81+
{
82+
"hashed_secret": "3e4bdbe0b80e63c22b178576e906810777387b50",
83+
"is_secret": false,
84+
"is_verified": false,
85+
"line_number": 10,
86+
"type": "Secret Keyword",
87+
"verified_result": null
88+
}
89+
],
90+
"modules/ansible/templates-ansible/configure-monitoring-sap/playbook-configure-monitoring-sap.yml.tftpl": [
91+
{
92+
"hashed_secret": "d2e2ab0f407e4ee3cf2ab87d61c31b25a74085e5",
93+
"is_secret": false,
94+
"is_verified": false,
95+
"line_number": 53,
96+
"type": "Secret Keyword",
97+
"verified_result": null
98+
}
99+
],
80100
"modules/pi-sap-system-type1/README.md": [
81101
{
82102
"hashed_secret": "2254481e1661d8f017a712b0d1ad9a14fd9460a3",

ibm_catalog.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
{
353353
"diagram": {
354354
"caption": "Full SAP environment provisioned on a 'Power Virtual Server with VPC landing zone'",
355-
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-powervs-sap/main/reference-architectures/sap-ready-to-go/deploy-arch-ibm-pvs-sap-ready-to-go.svg",
355+
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-powervs-sap/refs/tags/v3.4.0/reference-architectures/sap-ready-to-go/deploy-arch-ibm-pvs-sap-ready-to-go.svg",
356356
"type": "image/svg+xml"
357357
},
358358
"description": "'SAP ready PowerVS' variation of 'Power Virtual Server for SAP HANA' creates a basic and expandable SAP system landscape builds on the foundation of the 'Power Virtual Server with VPC landing zone'. PowerVS instances for SAP HANA, SAP NetWeaver and optionally for shared SAP files are deployed and preconfigured for SAP installation.\n\nServices such as DNS, NTP and NFS running in VPC and provided by 'Power Virtual Server with VPC landing zone' are leveraged.\n\nThe resulting SAP landscape leverages the services such as Activity Tracker, Cloud Object Storage, Key Management and the network connectivity configuration provided by 'Power Virtual Server with VPC landing zone'."
@@ -599,6 +599,15 @@
599599
"type": "json_editor"
600600
}
601601
},
602+
{
603+
"key": "sap_monitoring_vars",
604+
"required": true,
605+
"custom_config": {
606+
"grouping": "deployment",
607+
"original_grouping": "deployment",
608+
"type": "json_editor"
609+
}
610+
},
602611
{
603612
"key": "sap_domain",
604613
"required": true
@@ -692,6 +701,9 @@
692701
},
693702
{
694703
"key": "sap_solution_vars"
704+
},
705+
{
706+
"key": "sap_monitoring_vars"
695707
}
696708
],
697709
"iam_permissions": [
@@ -739,7 +751,7 @@
739751
{
740752
"diagram": {
741753
"caption": "Full SAP S/4HANA or BW/4HANA environment provisioned on a 'Power Virtual Server with VPC landing zone'",
742-
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-powervs-sap/main/reference-architectures/sap-s4hana-bw4hana/deploy-arch-ibm-pvs-sap-s4hana-bw4hana.svg",
754+
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-powervs-sap/refs/tags/v3.4.0/reference-architectures/sap-s4hana-bw4hana/deploy-arch-ibm-pvs-sap-s4hana-bw4hana.svg",
743755
"type": "image/svg+xml"
744756
},
745757
"description": "'SAP S/4HANA or BW/4HANA' variation of 'Power Virtual Server for SAP HANA' creates a basic and expandable SAP system landscape builds on the foundation of 'Power Virtual Server with VPC landing zone'. PowerVS instances for SAP HANA, SAP NetWeaver and optionally for shared SAP files are deployed and preconfigured for SAP installation. S/4HANA or BW/4HANA solution is installed based on selected version. \n\nServices such as DNS, NTP and NFS running in VPC and provided by 'Power Virtual Server with VPC landing zone' are leveraged.\n\nThe resulting SAP landscape leverages the services such as Activity Tracker, Cloud Object Storage, Key Management and the network connectivity configuration provided by the 'Power Virtual Server with VPC landing zone'."

modules/ansible/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ locals {
99
dst_playbook_file_path = "${local.dst_files_dir}/${var.dst_playbook_file_name}"
1010
src_inventory_tftpl_path = "${local.src_ansible_templates_dir}/${var.src_inventory_template_name}"
1111
dst_inventory_file_path = "${local.dst_files_dir}/${var.dst_inventory_file_name}"
12+
ibmcloud_api_key = var.ibmcloud_api_key == null ? "" : nonsensitive(var.ibmcloud_api_key)
1213

1314
}
1415

@@ -202,7 +203,7 @@ resource "terraform_data" "execute_playbooks_with_vault" {
202203
provisioner "remote-exec" {
203204
inline = [
204205
"chmod +x ${local.dst_script_file_path}",
205-
local.dst_script_file_path,
206+
"export IBMCLOUD_API_KEY=${local.ibmcloud_api_key} && ${local.dst_script_file_path}",
206207
]
207208
}
208209

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
### Using input variables from terraform
4+
ansible_playbook=${ansible_playbook_file}
5+
ansible_log_path=${ansible_log_path}
6+
ansible_inventory=${ansible_inventory}
7+
ansible_private_key_file=${ansible_private_key_file}
8+
9+
# shell to get the ibmcloud api token
10+
ibmcloud_auth_response=$(curl -X POST 'https://iam.cloud.ibm.com/identity/token' -H 'Content-Type: application/x-www-form-urlencoded' -d "apikey=$IBMCLOUD_API_KEY&grant_type=urn:ibm:params:oauth:grant-type:apikey")
11+
ibmcloud_iam_token=$(echo "$ibmcloud_auth_response" | jq -r '.access_token')
12+
13+
# Create ansible.cfg file
14+
ansible_playbook_name=$(basename $${ansible_playbook})
15+
echo -e "[defaults]\nhost_key_checking=False" >ansible.cfg
16+
export ANSIBLE_LOG_PATH=$${ansible_log_path}/$${ansible_playbook_name}.$(date "+%Y.%m.%d-%H.%M.%S").log
17+
export ANSIBLE_PRIVATE_KEY_FILE=$${ansible_private_key_file}
18+
19+
#Execute ansible playbook
20+
unbuffer ansible-playbook -i $${ansible_inventory} $${ansible_playbook} --extra-vars ibmcloud_iam_token=$${ibmcloud_iam_token} --vault-password-file password_file
21+
if [ $? -ne 0 ]; then
22+
rm -rf $${ansible_private_key_file}
23+
exit 1
24+
fi
25+
echo \"Playbook command successful\"
26+
rm -rf $${ansible_private_key_file}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# ------------------------------------------------------------------------
2+
# This playbook uses the ibm.power_linux_sap collection. This collection is
3+
# available on ansible galaxy
4+
# https://galaxy.ansible.com/ui/repo/published/ibm/power_linux_sap/ and can
5+
# be installed using 'ansible-galaxy collection install ibm.power_linux_sap'
6+
# ------------------------------------------------------------------------
7+
8+
---
9+
- name: SAP monitoring configuration
10+
hosts: all
11+
become: true
12+
vars:
13+
14+
## variable group: monitoring meta parameters
15+
sap_monitoring_action: '${sap_monitoring_action}'
16+
config_override: '${config_override}'
17+
sap_monitoring_nr: '${sap_monitoring_nr}'
18+
sap_monitoring_solution_name: '${sap_monitoring_solution_name}'
19+
sap_tools_directory: '${sap_tools_directory}'
20+
21+
## variable group: hana parameters
22+
sap_hana_ip: '${sap_hana_ip}'
23+
sap_hana_http_port: '${sap_hana_http_port}'
24+
sap_hana_sql_systemdb_port: '${sap_hana_sql_systemdb_port}'
25+
sap_hana_sql_systemdb_user: '${sap_hana_sql_systemdb_user}'
26+
sap_hana_sql_systemdb_password: '${sap_hana_sql_systemdb_password}'
27+
28+
## variable group: application server parameters
29+
sap_ascs_ip: '${sap_ascs_ip}'
30+
sap_ascs_http_port: '${sap_ascs_http_port}'
31+
sap_app_server: ${sap_app_server}
32+
33+
## variable group: IBM cloud parameters
34+
ibmcloud_monitoring_instance_url: '${ibmcloud_monitoring_instance_url}'
35+
ibmcloud_monitoring_request_credential_url: '${ibmcloud_monitoring_request_credential_url}'
36+
ibmcloud_monitoring_instance_guid: '${ibmcloud_monitoring_instance_guid}'
37+
38+
tasks:
39+
# use token to get the monitoring auth cred
40+
- name: Obtain IBM Cloud IAM token
41+
ansible.builtin.uri:
42+
url: "{{ ibmcloud_monitoring_request_credential_url }}"
43+
method: GET
44+
headers:
45+
Content-Type: application/json
46+
IBMInstanceID: "{{ ibmcloud_monitoring_instance_guid }}"
47+
Authorization: "Bearer {{ ibmcloud_iam_token }}"
48+
return_content: yes
49+
register: response
50+
51+
- name: Set fact for IBM Cloud Monitoring authorization credentials
52+
ansible.builtin.set_fact:
53+
ibmcloud_monitoring_authorization_credentials: "{{ response.json.token.key }}"
54+
55+
- name: Execute monitoring role for SAP
56+
ansible.builtin.include_role:
57+
name: ibm.power_linux_sap.monitoring_sap
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${monitoring_host_ip}

modules/ansible/templates-ansible/s4hanab4hana-solution/playbook-sap-swpm-install.yml.tftpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,20 @@
7878

7979
- name: SAP SWPM Post Install - Enforce Connection Info in hdbuserstore
8080
ansible.builtin.shell: "runuser -l {{sap_swpm_sid|lower}}adm -c 'hdbuserstore SET DEFAULT {{ sap_swpm_db_host }}:3{{ sap_swpm_db_instance_nr }}15 {{ sap_swpm_db_schema_abap }} '{{ sap_swpm_db_system_password }}"
81+
82+
- name: Update the service/protectedwebmethods line in the file DEFAULT.PFL profile
83+
ansible.builtin.lineinfile:
84+
path: /usr/sap/{{ sap_swpm_sid }}/SYS/profile/DEFAULT.PFL
85+
regexp: '^service/protectedwebmethods ='
86+
line: 'service/protectedwebmethods = ${sap_swpm_service_protectedwebmethods}'
87+
backup: yes
88+
89+
- name: Restart ASCS instance for service/protectedwebmethods to take effect
90+
ansible.builtin.shell: "runuser -l {{sap_swpm_sid|lower}}adm -c 'sapcontrol -nr {{ sap_swpm_ascs_instance_nr }} -function RestartService'"
91+
92+
- name: Pause for 30 seconds
93+
ansible.builtin.pause:
94+
seconds: 30
95+
96+
- name: Restart PAS instance for service/protectedwebmethods to take effect
97+
ansible.builtin.shell: "runuser -l {{sap_swpm_sid|lower}}adm -c 'sapcontrol -nr {{ sap_swpm_pas_instance_nr }} -function RestartService'"

modules/ansible/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ variable "ansible_vault_password" {
6565
sensitive = true
6666
default = null
6767
}
68+
69+
variable "ibmcloud_api_key" {
70+
description = "IBM Cloud platform API key needed to deploy IAM enabled resources."
71+
type = string
72+
sensitive = true
73+
default = null
74+
}

reference-architectures/sap-ready-to-go/deploy-arch-ibm-pvs-sap-ready-to-go.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
copyright:
44
years: 2024
5-
lastupdated: "2024-12-13"
5+
lastupdated: "2025-01-14"
66
keywords:
77
subcollection: deployable-reference-architectures
88
authors:
@@ -16,7 +16,7 @@ use-case: ITServiceManagement
1616
industry: Technology
1717
compliance: SAPCertified
1818
content-type: reference-architecture
19-
version: v3.3.0
19+
version: v3.4.0
2020
related_links:
2121
- title: 'SAP in IBM Cloud documentation'
2222
url: 'https://cloud.ibm.com/docs/sap'
@@ -38,7 +38,7 @@ related_links:
3838
{: toc-industry="Technology"}
3939
{: toc-use-case="ITServiceManagement"}
4040
{: toc-compliance="SAPCertified"}
41-
{: toc-version="3.3.0"}
41+
{: toc-version="3.4.0"}
4242

4343
The SAP-ready PowerVS variation of the Power Virtual Server for SAP HANA creates a basic and expandable SAP system landscape. The variation builds on the foundation of the VPC landing zone and Power Virtual Server with VPC landing zone. PowerVS instances for SAP HANA, SAP NetWeaver, and optionally for shared SAP files are deployed and preconfigured for SAP installation.
4444

reference-architectures/sap-s4hana-bw4hana/deploy-arch-ibm-pvs-sap-s4hana-bw4hana.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
copyright:
44
years: 2024
5-
lastupdated: "2024-12-13"
5+
lastupdated: "2025-01-14"
66
keywords:
77
subcollection: deployable-reference-architectures
88
authors:
@@ -16,7 +16,7 @@ use-case: ITServiceManagement
1616
industry: Technology
1717
compliance: SAPCertified
1818
content-type: reference-architecture
19-
version: v3.3.0
19+
version: v3.4.0
2020
related_links:
2121
- title: 'SAP in IBM Cloud documentation'
2222
url: 'https://cloud.ibm.com/docs/sap'
@@ -38,7 +38,7 @@ related_links:
3838
{: toc-industry="Technology"}
3939
{: toc-use-case="ITServiceManagement"}
4040
{: toc-compliance="SAPCertified"}
41-
{: toc-version="3.3.0"}
41+
{: toc-version="3.4.0"}
4242

4343
'SAP S/4HANA or BW/4HANA' variation of 'Power Virtual Server for SAP HANA' creates a basic and expandable SAP system landscape built on the foundation of 'Power Virtual Server with VPC landing zone'. PowerVS instances for SAP HANA, SAP NetWeaver, and optionally for shared SAP files are deployed and preconfigured for SAP installation. The S/4HANA or BW/4HANA solution is installed based on the selected version.
4444

0 commit comments

Comments
 (0)