Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch 'private-preview' of https://github.com/Azure/sap-automation into private-preview #1

Merged
merged 20 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ed536c2
added azure devopos pipelines
mimergel Nov 24, 2021
458737f
Merge branch 'private-preview' of https://github.com/Azure/sap-automa…
mimergel Nov 24, 2021
74661ff
Update deploy/pipelines/03-sap-system-deployment.yaml
mimergel Nov 25, 2021
b5b590b
Update deploy/pipelines/03-sap-system-deployment.yaml
mimergel Nov 25, 2021
b23e222
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
9effb16
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
e6c94ab
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
20297a0
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
8edf0d5
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
dc89898
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
98e9bd9
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
b69f43a
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
83c1382
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
6a68b00
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
4d14a58
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
20177ab
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
984b9dc
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
5d7daf1
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
b5aab62
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
6fdb595
Update deploy/pipelines/05-DB-and-SAP-install.yaml
mimergel Nov 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions deploy/pipelines/01-prepare-region.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

parameters:

- name: deployer_parameter
displayName: ENV-LOCA-VNET-INFRASTRUCTURE
type: string
default: MGMT-WEEU-DEP00-INFRASTRUCTURE

- name: library_parameter
displayName: ENV-LOCA-SAP_LIBRARY
type: string
default: MGMT-WEEU-SAP_LIBRARY

- name: cleanup
displayName: Remove the relevant Resource Groups instead of deploying
type: boolean
default: False

trigger:
none

pool:
vmImage: ubuntu-latest

variables:
deployerfolder: ${{ parameters.deployer_parameter }}
deployerconfig: ${{ parameters.deployer_parameter }}.tfvars
libraryfolder: ${{ parameters.library_parameter }}
libraryconfig: ${{ parameters.library_parameter }}.tfvars
log: logfile_$(Build.BuildId)

name: $(deployerfolder)_$(libraryfolder)__Cleanup_${{ parameters.cleanup }}_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

stages:
- stage: Prepare_the_Region_with_Deployer_and_SAP_Library
condition: eq(${{ parameters.cleanup }}, false)
jobs:
- job: Prepare_the_Region_with_Deployer_and_SAP_Library
steps:
- script: |
#!/bin/bash
green="\e[1;32m"
reset="\e[0m"
echo -e "$green--- Install Terraform ---$reset"
wget -q https://releases.hashicorp.com/terraform/1.0.8/terraform_1.0.8_linux_amd64.zip
unzip -qq terraform_1.0.8_linux_amd64.zip
sudo mv terraform /bin/ ; rm terraform_1.0.8_linux_amd64.zip
echo -e "$green--- Clone the $(Branch) branch of repository $(Repository) ---$reset"
git clone --quiet --single-branch --branch $(Branch) $(Repository)
echo -e "$green--- Update .sap_deployment_automation/config as DEPLOYMENT_REPO_PATH can change on devops agent ---$reset"
export DEPLOYMENT_REPO_PATH=$(Build.Repository.LocalPath)/sap-automation
mkdir -p .sap_deployment_automation
echo DEPLOYMENT_REPO_PATH=$DEPLOYMENT_REPO_PATH > .sap_deployment_automation/config
export HOME=$(Build.Repository.LocalPath)
az login --service-principal --username $(ARM_CLIENT_ID) --password $(ARM_CLIENT_SECRET) --tenant $(ARM_TENANT_ID)
az account set --subscription $(ARM_SUBSCRIPTION_ID)
echo -e "$green--- Prepare the exchange of information from devops agent back to the repository ---$reset"
organization=$(echo $(System.CollectionUri) | cut -d'/' -f4)
git config http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader "AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN"
echo -e "$green--- Convert config files to UX format ---$reset"
sudo apt-get -qq install dos2unix
dos2unix -q DEPLOYER/$(deployerfolder)/$(deployerconfig)
dos2unix -q LIBRARY/$(libraryfolder)/$(libraryconfig)
echo -e "$green--- Running the prepare region script that deploys the subscription hub with the Deployer VM and SAP Library ---$reset"
$DEPLOYMENT_REPO_PATH/deploy/scripts/prepare_region.sh --deployer_parameter_file DEPLOYER/$(deployerfolder)/$(deployerconfig) --library_parameter_file LIBRARY/$(libraryfolder)/$(libraryconfig) --subscription $(ARM_SUBSCRIPTION_ID) --spn_id $(ARM_CLIENT_ID) --spn_secret $(ARM_CLIENT_SECRET) --tenant_id $(ARM_TENANT_ID) --auto-approve &>> /tmp/$(log)1
cat /tmp/$(log)1
# currently error log piped to file to avoid pipeline failure due to bash error messages
echo -e "$green--- Adding deployment automation configuration to devops repository ---$reset"
git config --global user.email "$(Build.RequestedForEmail)"
git config --global user.name "$(Build.RequestedFor)"
git add .sap_deployment_automation &>> /tmp/$(log)2
git add DEPLOYER/$(deployerfolder)/.terraform &>> /tmp/$(log)2
git add LIBRARY/$(libraryfolder)/.terraform &>> /tmp/$(log)2
git add LIBRARY/$(libraryfolder)/backend-config.tfvars &>> /tmp/$(log)2
git commit -m "Added updates from devops deployment $(Build.DefinitionName) [skip ci]" &>> /tmp/$(log)2
git push -f origin HEAD:main &>> /tmp/$(log)2
cat /tmp/$(log)2
git config --unset-all http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader
displayName: Prepare_the_Region_with_Deployer_and_SAP_Library
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
failOnStderr: true

- stage: Cleanup_Deployer_Library
condition: eq(${{ parameters.cleanup }}, true)
jobs:
- job: Remove_Deployer
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Remove Resource Group $(deployerfolder)'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '$(AZURECONNECTIONNAME)'
subscriptionId: '$(ARM_SUBSCRIPTION_ID)'
action: 'DeleteRG'
resourceGroupName: '$(deployerfolder)'

- job: Remove_SAP_Library
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Remove Resource Group $(libraryfolder)'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '$(AZURECONNECTIONNAME)'
subscriptionId: '$(ARM_SUBSCRIPTION_ID)'
action: 'DeleteRG'
resourceGroupName: '$(libraryfolder)'
100 changes: 100 additions & 0 deletions deploy/pipelines/02-sap-workload-zone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

parameters:

- name: workloadzone
displayName: ENV-LOCA-VNET-INFRASTRUCTURE
type: string
default: DEV-WEEU-SAP01-INFRASTRUCTURE

- name: environment
displayName: Deployer Environment (MGMT, DEV, QUA, PRD, ...)
type: string
default: MGMT

- name: cleanup
displayName: Remove the relevant Resource Groups instead of deploying
type: boolean
default: False

trigger:
none

pool:
# name: MIMERGEL-Selfhosted
vmImage: ubuntu-latest

variables:
zonefolder: ${{ parameters.workloadzone }}
zoneconfig: ${{ parameters.workloadzone }}.tfvars
env: ${{ parameters.environment }}
log: logfile_$(Build.BuildId)

name: $(zonefolder)_Cleanup_${{ parameters.cleanup }}_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

stages:
- stage: Deploy_SAP_Workloadzone
condition: eq(${{ parameters.cleanup }}, false)
jobs:
- job: Deploy_SAP_Workloadzone
steps:
- script: |
#!/bin/bash
green="\e[1;32m"
reset="\e[0m"
echo -e "$green--- Install Terraform ---$reset"
wget -q https://releases.hashicorp.com/terraform/1.0.8/terraform_1.0.8_linux_amd64.zip
unzip -qq terraform_1.0.8_linux_amd64.zip
sudo mv terraform /bin/ ; rm terraform_1.0.8_linux_amd64.zip
echo -e "$green--- Clone the $(Branch) branch of repository $(Repository) ---$reset"
git clone --quiet --single-branch --branch $(Branch) $(Repository)
echo -e "$green--- Set DEPLOYMENT_REPO_PATH variable and ---$reset"
echo -e "$green--- Update .sap_deployment_automation/config as DEPLOYMENT_REPO_PATH can change on devops agent ---$reset"
export DEPLOYMENT_REPO_PATH=$(Build.Repository.LocalPath)/sap-automation
echo DEPLOYMENT_REPO_PATH=$DEPLOYMENT_REPO_PATH > .sap_deployment_automation/config
echo -e "$green--- Set local build repo path as new home ---$reset"
export HOME=$(Build.Repository.LocalPath)
echo -e "$green--- az login ---$reset"
az login --service-principal --username $(ARM_CLIENT_ID) --password $(ARM_CLIENT_SECRET) --tenant $(ARM_TENANT_ID)
az account set --subscription $(ARM_SUBSCRIPTION_ID)
echo -e "$green--- --- Convert config file to UX format ---$reset"
sudo apt-get -qq install dos2unix
dos2unix -q LANDSCAPE/$(zonefolder)/$(zoneconfig)
echo -e "$green--- Prepare the exchange of information from devops agent back to the repository ---$reset"
organization=$(echo $(System.CollectionUri) | cut -d'/' -f4)
git config http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader "AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN"
echo -e "$green--- Run the prepare region script that deploys the subscription hub with the Deployer VM and SAP Library ---$reset"
cd LANDSCAPE/$(zonefolder)
$DEPLOYMENT_REPO_PATH/deploy/scripts/install_workloadzone.sh --parameterfile $(zoneconfig) --deployer_environment $(env) --subscription $(ARM_SUBSCRIPTION_ID) --spn_id $(ARM_CLIENT_ID) --spn_secret $(ARM_CLIENT_SECRET) --tenant_id $(ARM_TENANT_ID) --auto-approve
cd $HOME
echo -e "$green--- Add & update files in the DevOps Repository ---$reset"
git config --global user.email "$(Build.RequestedForEmail)"
git config --global user.name "$(Build.RequestedFor)"
git add .sap_deployment_automation &>> /tmp/$(log)2
git add LANDSCAPE/$(zonefolder)/.terraform &>> /tmp/$(log)2
git commit -m "Added updates from devops deployment $(Build.DefinitionName) [skip ci]" &>> /tmp/$(log)2
git push -f origin HEAD:main &>> /tmp/$(log)2
echo "output the log ---$reset"
cat /tmp/$(log)2
git config --unset-all http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader
displayName: Deploy_SAP_Workloadzone
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
failOnStderr: true

- stage: Cleanup_Workload_Zone
condition: eq(${{ parameters.cleanup }}, true)
jobs:
- job: Remove_Workload_Zone
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Remove Resource Group $(zonefolder)'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '$(AZURECONNECTIONNAME)'
subscriptionId: '$(ARM_SUBSCRIPTION_ID)'
action: 'DeleteRG'
resourceGroupName: '$(zonefolder)'
101 changes: 101 additions & 0 deletions deploy/pipelines/03-sap-system-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Starter pipeline
mimergel marked this conversation as resolved.
Show resolved Hide resolved
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

parameters:

- name: sap_system
displayName: ENV-LOCA-VNET-SID
type: string
default: DEV-WEEU-SAP01-X01

- name: cleanup
displayName: Remove the relevant Resource Groups instead of deploying
type: boolean
default: False

trigger:
none

pool:
# name: MIMERGEL-Selfhosted
vmImage: ubuntu-latest

variables:
sapsystemfolder: ${{ parameters.sap_system }}
sapsystemconfig: ${{ parameters.sap_system }}.tfvars
log: logfile_$(Build.BuildId)

name: $(sapsystemfolder)_Cleanup_${{ parameters.cleanup }}_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

stages:
- stage: Deploy_SAP_Infrastructure
condition: eq(${{ parameters.cleanup }}, false)
jobs:
- job: Deploy_SAP_Infrastructure
steps:
- script: |
#!/bin/bash
green="\e[1;32m"
reset="\e[0m"
SID=$(echo $(sapsystemfolder) | cut -d'-' -f4 | xargs)
echo -e "$green--- Install Terraform ---$reset"
wget -q https://releases.hashicorp.com/terraform/1.0.8/terraform_1.0.8_linux_amd64.zip
unzip -qq terraform_1.0.9_linux_amd64.zip
mimergel marked this conversation as resolved.
Show resolved Hide resolved
sudo mv terraform /bin/ ; rm terraform_1.0.8_linux_amd64.zip
echo -e "$green--- Clone the $(Branch) branch of repository $(Repository) ---$reset"
git clone --quiet --single-branch --branch $(Branch) $(Repository)
echo -e "$green--- Set DEPLOYMENT_REPO_PATH variable and ---$reset"
echo -e "$green--- Update .sap_deployment_automation/config as DEPLOYMENT_REPO_PATH can change on devops agent ---$reset"
export DEPLOYMENT_REPO_PATH=$(Build.Repository.LocalPath)/sap-automation
echo DEPLOYMENT_REPO_PATH=$DEPLOYMENT_REPO_PATH > .sap_deployment_automation/config
echo -e "$green--- Set local build repo path as new home ---$reset"
export HOME=$(Build.Repository.LocalPath)
echo -e "$green--- az login ---$reset"
az login --service-principal --username $(ARM_CLIENT_ID) --password $(ARM_CLIENT_SECRET) --tenant $(ARM_TENANT_ID)
az account set --subscription $(ARM_SUBSCRIPTION_ID)
export ARM_SUBSCRIPTION_ID=$(ARM_SUBSCRIPTION_ID)
export ARM_CLIENT_ID=$(ARM_CLIENT_ID)
export ARM_CLIENT_SECRET=$(ARM_CLIENT_SECRET)
export ARM_TENANT_ID=$(ARM_TENANT_ID)
echo -e "$green--- --- Convert config file to UX format ---$reset"
sudo apt-get -qq install dos2unix
dos2unix -q SYSTEM/$(sapsystemfolder)/$(sapsystemconfig)
echo -e "$green--- Prepare the exchange of information from devops agent back to the repository ---$reset"
organization=$(echo $(System.CollectionUri) | cut -d'/' -f4)
git config http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader "AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN"
echo -e "$green--- Run the installer script that deploys the SAP System ---$reset"
cd SYSTEM/$(sapsystemfolder)
${DEPLOYMENT_REPO_PATH}/deploy/scripts/installer.sh --parameterfile $(sapsystemconfig) --type sap_system --ado --auto-approve
cd $HOME
echo -e "$green--- Add & update files in the DevOps Repository ---$reset"
git config --global user.email "$(Build.RequestedForEmail)"
git config --global user.name "$(Build.RequestedFor)"
git add .sap_deployment_automation &>> /tmp/$(log)2
git add SYSTEM/$(sapsystemfolder)/.terraform/terraform.tfstate &>> /tmp/$(log)2
git add SYSTEM/$(sapsystemfolder)/sap-parameters.yaml &>> /tmp/$(log)2
git add SYSTEM/$(sapsystemfolder)/${SID}_hosts.yaml &>> /tmp/$(log)2
git commit -m "Added updates from devops deployment $(Build.DefinitionName) [skip ci]" &>> /tmp/$(log)2
git push -f origin HEAD:main &>> /tmp/$(log)2
echo "output the log ---$reset"
cat /tmp/$(log)2
git config --unset-all http.https://[email protected]/$organization/$(System.TeamProject)/_git/$(Build.Repository.Name).extraheader
displayName: Deploy_SAP_Infrastructure
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
failOnStderr: true

- stage: Cleanup
condition: eq(${{ parameters.cleanup }}, true)
jobs:
- job: Remove_Deployer
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Remove Resource Group $(sapsystemfolder)'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '$(AZURECONNECTIONNAME)'
subscriptionId: '$(ARM_SUBSCRIPTION_ID)'
action: 'DeleteRG'
resourceGroupName: '$(sapsystemfolder)'
Loading