-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
313 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
--- | ||
|
||
- name: "SAP CAL HA Integration" | ||
hosts: "{{ sap_sid | upper }}_DB : | ||
{{ sap_sid | upper }}_SCS : | ||
{{ sap_sid | upper }}_ERS : | ||
{{ sap_sid | upper }}_PAS : | ||
{{ sap_sid | upper }}_APP" | ||
become: true | ||
gather_facts: true | ||
vars_files: vars/ansible-input-api.yaml | ||
tasks: | ||
- name: "SAP-CAL Integration" | ||
become: true | ||
when: | ||
- ansible_os_family | upper == "SUSE" or ansible_os_family | upper == "REDHAT" | ||
- enable_sap_cal is defined and enable_sap_cal | ||
- scs_high_availability and db_high_availability | ||
|
||
block: | ||
- name: "6.0.0-sapcal-HA-install - Extend logical volumes" | ||
when: ansible_os_family | upper == "REDHAT" | ||
ansible.builtin.include_role: | ||
name: roles-os/1.5.3-disk-setup-sapcal | ||
|
||
- name: "Initialize facts" | ||
ansible.builtin.set_fact: | ||
primary_db_instance: "{{ ansible_play_hosts_all[0] }}" # Setting up Primary Instance Name | ||
secondary_db_instance: "{{ ansible_play_hosts_all[1] }}" # Setting up Secondary Instance Name | ||
when: | ||
- "'hana' in supported_tiers" | ||
|
||
- name: "Retrieve Resource Group Name and ResourceID" | ||
ansible.builtin.uri: | ||
url: http://169.254.169.254/metadata/instance?api-version=2021-02-01 | ||
use_proxy: false | ||
headers: | ||
Metadata: true | ||
register: azure_metadata | ||
|
||
- name: "Set ResourceID for SCS" | ||
ansible.builtin.set_fact: | ||
subscription_id: "{{ azure_metadata.json.compute.subscriptionId }}" | ||
resource_group_name: "{{ azure_metadata.json.compute.resourceGroupName }}" | ||
scs_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
scs_physical_hostname: "{{ ansible_hostname }}" | ||
scs_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'scs' in supported_tiers" | ||
- scs_high_availability | ||
|
||
- name: "Set ResourceID for ERS" | ||
ansible.builtin.set_fact: | ||
ers_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
ers_physical_hostname: "{{ ansible_hostname }}" | ||
ers_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'ers' in supported_tiers" | ||
- scs_high_availability | ||
|
||
# todo, differentiate between primary and secondary | ||
- name: "Set ResourceID for primary DB" | ||
ansible.builtin.set_fact: | ||
db_primary_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
db_primary_physical_hostname: "{{ ansible_hostname }}" | ||
db_primary_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'hana' in supported_tiers" | ||
- db_high_availability | ||
- inventory_hostname == primary_db_instance | ||
|
||
- name: "Set ResourceID for secondary DB" | ||
ansible.builtin.set_fact: | ||
db_secondary_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
db_secondary_physical_hostname: "{{ ansible_hostname }}" | ||
db_secondary_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'hana' in supported_tiers" | ||
- db_high_availability | ||
- inventory_hostname == secondary_db_instance | ||
|
||
- name: "Set ResourceID for PAS" | ||
ansible.builtin.set_fact: | ||
pas_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
pas_physical_hostname: "{{ ansible_hostname }}" | ||
pas_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'pas' in supported_tiers" | ||
|
||
- name: "Set ResourceID for APP" | ||
ansible.builtin.set_fact: | ||
app_resource_id: "{{ azure_metadata.json.compute.resourceId }}" | ||
app_physical_hostname: "{{ ansible_hostname }}" | ||
app_virtual_hostname: "{{ virtual_host }}" | ||
when: | ||
- "'app' in supported_tiers" | ||
|
||
- name: "Provision a new SAP environment" | ||
hosts: localhost | ||
connection: local | ||
gather_facts: true | ||
vars_files: vars/ansible-input-api.yaml | ||
tasks: | ||
|
||
- name: "Check if Enable SAP CAL is true" | ||
ansible.builtin.assert: | ||
that: | ||
- enable_sap_cal is defined | ||
- enable_sap_cal | bool | ||
fail_msg: "Please set enable_sap_cal to true in the sap-parameters.yaml file to enable SAP CAL integration" | ||
|
||
- name: Run the keyvault role | ||
ansible.builtin.include_role: | ||
name: roles-misc/0.2-kv-secrets | ||
vars: | ||
operation: sapcal | ||
tags: | ||
- kv-secrets | ||
|
||
# Once the Ansible Module is updated, this task will be moved to OS configuration playbook | ||
- name: "SAP-CAL Integration: - Ensure azure-keyvault is installed" | ||
become: true | ||
when: enable_sap_cal is defined and enable_sap_cal | ||
block: | ||
- name: "SAP-CAL Integration: - Ensure azure-keyvault is installed" | ||
ansible.builtin.pip: | ||
name: | ||
- azure-keyvault==1.1.0 | ||
- azure-keyvault-secrets | ||
state: present | ||
tags: | ||
- always | ||
|
||
- name: "Set facts from other hosts" | ||
ansible.builtin.set_fact: | ||
"{{ item.key }}": "{{ hostvars[groups[sap_sid | upper + '_' + item.value][item.index]][item.key] }}" | ||
loop: | ||
- { key: 'subscription_id', value: 'SCS', index: 0 } | ||
- { key: 'resource_group_name', value: 'SCS', index: 0 } | ||
- { key: 'scs_resource_id', value: 'SCS', index: 0 } | ||
- { key: 'scs_physical_hostname', value: 'SCS', index: 0 } | ||
- { key: 'scs_virtual_hostname', value: 'SCS', index: 0 } | ||
- { key: 'ers_resource_id', value: 'ERS', index: 0 } | ||
- { key: 'ers_physical_hostname', value: 'ERS', index: 0 } | ||
- { key: 'ers_virtual_hostname', value: 'ERS', index: 0 } | ||
- { key: 'db_primary_resource_id', value: 'DB' , index: 0 } | ||
- { key: 'db_primary_physical_hostname', value: 'DB' , index: 0 } | ||
- { key: 'db_primary_virtual_hostname', value: 'DB' , index: 0 } | ||
- { key: 'db_secondary_resource_id', value: 'DB' , index: 1 } | ||
- { key: 'db_secondary_physical_hostname', value: 'DB' , index: 1 } | ||
- { key: 'db_secondary_virtual_hostname', value: 'DB' , index: 1 } | ||
- { key: 'pas_resource_id', value: 'PAS', index: 0 } | ||
- { key: 'pas_physical_hostname', value: 'PAS', index: 0 } | ||
- { key: 'pas_virtual_hostname', value: 'PAS', index: 0 } | ||
- { key: 'app_resource_id', value: 'APP', index: 0 } | ||
- { key: 'app_physical_hostname', value: 'APP', index: 0 } | ||
- { key: 'app_virtual_hostname', value: 'APP', index: 0 } | ||
|
||
- name: "6.0.1-sapcal-ha-install - CALL SAP CAL API" | ||
when: enable_sap_cal is defined and enable_sap_cal | ||
block: | ||
- name: "Import the 6.0.1-sapcal-ha-install role" | ||
ansible.builtin.import_role: | ||
name: "roles-sap/6.0.1-sapcal-ha-install" |
11 changes: 11 additions & 0 deletions
11
deploy/ansible/roles-sap/6.0.1-sapcal-ha-install/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# defaults file for 6.0.1-sapcal-ha-install | ||
|
||
db_sid_admin_user_id: "1050" | ||
sap_sysadmin_user_id: "1079" | ||
sap_sysadmin_group_id: "79" | ||
sap_gui_default_language: "en" | ||
sap_additional_languages: "" | ||
number_of_dialog_work_processes: "10" | ||
number_of_batch_work_processes: "7" | ||
abap_message_server_port: "3600" |
98 changes: 98 additions & 0 deletions
98
deploy/ansible/roles-sap/6.0.1-sapcal-ha-install/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
# tasks file for 6.0.1-sapcal-ha-install | ||
|
||
- name: "Retrieve SAP-CAL Product Id" | ||
ansible.builtin.set_fact: | ||
product_id: "{{ sap_cal_product | selectattr('name', 'equalto', sap_cal_product_name) | map(attribute='id') | first }}" | ||
|
||
# ------------------<DEBUGGING>------------------- | ||
- name: "Print SAP-CAL Parameters" | ||
ansible.builtin.debug: | ||
msg: | ||
- "SAP SID : {{ sap_sid | upper }}" | ||
- "DB SID : {{ db_sid | upper }}" | ||
- "SAP-CAL Product Name : {{ sap_cal_product_name }}" | ||
- "SAP-CAL Product Id : {{ product_id }}" | ||
- "Domain Name : {{ sap_fqdn }}" | ||
- "subscription_id : {{ subscription_id }}" | ||
- "resource_group_name : {{ resource_group_name }}" | ||
- "scs_resource_id : {{ scs_resource_id }}" | ||
- "ers_resource_id : {{ ers_resource_id }}" | ||
- "db_primary_resource_id : {{ db_primary_resource_id }}" | ||
- "db_secondary_resource_id : {{ db_secondary_resource_id }}" | ||
- "pas_resource_id : {{ pas_resource_id }}" | ||
- "app_resource_id : {{ app_resource_id }}" | ||
verbosity: 2 | ||
# ------------------</DEBUGGING>------------------ | ||
|
||
- name: Call provisioning API endpoint | ||
public_api: | ||
method: "software_provisioning" | ||
calKeyvaultId: "https://{{ calapi_kv }}.vault.azure.net/" | ||
outputDirectoryPath: "{{ _workspace_directory }}" | ||
clientId: "" | ||
clientSecret: "" | ||
tenantId: "" | ||
outputFile: "sapcal_provisioning.json" | ||
productId: "{{ product_id }}" | ||
availabilityScenario: "clustering" | ||
infrastructureParameterSet: | ||
domainName: "{{ sap_fqdn }}" | ||
remoteOsUser: "{{ orchestration_ansible_user }}" | ||
secretStoreId: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ secret_prefix }}-INFRASTRUCTURE/providers/Microsoft.KeyVault/vaults/{{ kv_name }}" | ||
sshPublicKeySecretName: "{{ secret_prefix }}-sid-sshkey-pub" | ||
sshPrivateKeySecretName: "{{ secret_prefix }}-sid-sshkey" | ||
deploymentServerResourceGroup: "{{ resource_group_name }}-SAPCAL-HA-DS" | ||
technicalCommunicationUser: "{{ s_user }}" | ||
techUserPassword: "{{ s_password }}" | ||
installationParameterSets: | ||
hanaDeployment: | ||
primaryVmResourceId: "{{ db_primary_resource_id }}" | ||
secondaryVmResourceId: "{{ db_secondary_resource_id }}" | ||
loadBalancerResourceId: "{{ db_lb_resource_id }}" | ||
frontEndIp: "{{ db_alb_feip_id }}" | ||
DBSID: "{{ db_sid | upper }}" | ||
DBSIDAdminUserId: "{{ db_sid_admin_user_id }}" | ||
instanceNumber: "{{ db_instance_number }}" | ||
primaryPhysicalHostname: "{{ db_primary_physical_hostname }}" | ||
primaryVirtualHostname: "{{ db_primary_virtual_hostname }}" | ||
secondaryPhysicalHostname: "{{ db_secondary_physical_hostname }}" | ||
secondaryVirtualHostname: "{{ db_secondary_virtual_hostname }}" | ||
s4hanaDeployment: | ||
SID: "{{ sap_sid | upper }}" | ||
SAPSysAdminUserId: "{{ sap_sysadmin_user_id }}" | ||
SAPSysAdminGroupId: "{{ sap_sysadmin_group_id }}" | ||
sapGuiDefaultLanguage: "{{ sap_gui_default_language }}" | ||
SAPSystemAdditionalLanguages: "{{ sap_additional_languages }}" | ||
numberOfDialogWorkProcesses: "{{ number_of_dialog_work_processes }}" | ||
numberOfBatchWorkProcesses: "{{ number_of_batch_work_processes }}" | ||
centralServicesDeployment: | ||
vmResourceId: "{{ scs_resource_id}}" | ||
loadBalancerResourceId: "{{ scs_lb_resource_id }}" | ||
frontEndIp: "{{ scs_alb_feip_id }}" | ||
instanceNumber: "{{ scs_instance_number }}" | ||
ABAPMessageServerPort: "{{ abap_message_server_port }}" | ||
physicalHostname: "{{ scs_physical_hostname }}" | ||
virtualHostname: "{{ scs_virtual_hostname }}" | ||
loadBalancerHostname: "{{ sap_sid | lower }}scs{{ scs_instance_number }}cl1" | ||
enqueueReplicationServerDeployment: | ||
vmResourceId: "{{ ers_resource_id }}" | ||
frontEndIp: "{{ ers_alb_feip_id }}" | ||
instanceNumber: "{{ ers_instance_number }}" | ||
physicalHostname: "{{ ers_physical_hostname }}" | ||
virtualHostname: "{{ ers_virtual_hostname }}" | ||
loadBalancerHostname: "{{ sap_sid | lower }}ers{{ ers_instance_number }}cl2" | ||
applicationServersDeployment: | ||
- vmResourceId: "{{ pas_resource_id }}" | ||
instanceNumber: "{{ pas_instance_number }}" | ||
physicalHostname: "{{ pas_physical_hostname }}" | ||
virtualHostname: "{{ pas_virtual_hostname }}" | ||
- vmResourceId: "{{ app_resource_id }}" | ||
instanceNumber: "{{ app_instance_number }}" | ||
physicalHostname: "{{ app_physical_hostname }}" | ||
virtualHostname: "{{ app_virtual_hostname }}" | ||
register: sapcal_provisioning | ||
|
||
- name: "Print SAP-CAL provisioning response" | ||
ansible.builtin.debug: | ||
var: sapcal_provisioning |
15 changes: 15 additions & 0 deletions
15
deploy/ansible/roles-sap/6.0.1-sapcal-ha-install/vars/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# vars file for 6.0.1-sapcal-ha-install | ||
|
||
sap_cal_product: | ||
- { name: "S/4HANA_2023-Initial_Shipment_Stack", id: "88f59e31-d776-45ea-811c-1da6577e4d25" } | ||
- { name: "S/4HANA_2022-Initial_Shipment_Stack", id: "3b1dc287-c865-4f79-b9ed-d5ec2dc755e9" } | ||
- { name: "S/4HANA_2021-Initial_Shipment_Stack", id: "108febf9-5e7b-4e47-a64d-231b6c4c821d" } | ||
- { name: "S/4HANA_2023-FPS_01_02_2024", id: "4ae16a47-7f62-495c-9e45-f1a536f107dc" } | ||
- { name: "S/4HANA_2022-FPS_02_05_2023", id: "c86d7a56-4130-4459-8060-ffad1a1118ce" } | ||
- { name: "S/4HANA_2022-FPS_01_02_2023", id: "1294f31c-2697-443c-bacc-117d5924fcb2" } | ||
- { name: "S/4HANA_2021-FPS_02_05_2022", id: "4d5f19a7-d3cb-4d47-9f44-0a9e133b11de" } | ||
- { name: "S/4HANA_2021-FPS_01_02_2022", id: "1c796928-0617-490b-a87d-478568a49628" } | ||
- { name: "S/4HANA_2021-04_05_2023", id: "29403c63-6504-4919-b5dd-319d7a99804e" } | ||
- { name: "S/4HANA_2021-03_11_2022", id: "6921f2f8-169b-45bb-9e0b-d89b4abee1f3" } | ||
- { name: "S/4HANA 2020-04_05_2022", id: "615c5c18-5226-4dcb-b0ab-19d0141baf9b" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters