-
-
Save mkol5222/0909bab28a902aa94a4187b4d12f7339 to your computer and use it in GitHub Desktop.
ARO - Terraform main file
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
#!/bin/bash | |
######################################################## | |
#Enable the account subscription | |
SUBSCRIPTION_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
az account set --subscription $SUBSCRIPTION_ID | |
if [ $? -eq 0 ]; then | |
echo "Account set to subscription: " $SUBSCRIPTION_ID | |
fi | |
######################################################## | |
#Enable features/providers | |
az feature register --namespace Microsoft.ContainerService -n AROGA | |
az provider register -n Microsoft.Storage --wait | |
az provider register -n Microsoft.Compute --wait | |
az provider register -n Microsoft.Solutions --wait | |
az provider register -n Microsoft.Network --wait | |
az provider register -n Microsoft.KeyVault --wait | |
az provider register -n Microsoft.ContainerService --wait | |
######################################################## | |
echo "Setting up the Environment Variables" | |
LOCATION=westeurope | |
TENANT_ID=$(az account show --query tenantId -o tsv) | |
CLUSTER_NAME=EUR1-CP1-ARO-DT-OS | |
CLUSTER_RESOURCEGROUP_NAME=EUR1-CP1-ARO-DT-RG | |
ARO_VNET_PREFIX='10.16.8.0/24' | |
ARO_SUBNET_PREFIX=$ARO_VNET_PREFIX | |
SECGROUP_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | |
APP_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | |
APP_NAME=$(az ad sp show --id $APP_ID --query appDisplayName) | |
SECRET='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
RESOURCEGROUP_NAME=EU01-CP01-PSD-RG | |
PUB_VNET_NAME=EU01-CP01-PSD-VNET | |
PUB_VNET_PREFIX='172.168.4.0/23' | |
######################################################## | |
echo "Create the Resource Group for the Peering VNET" | |
if [ "$(az group exists --resource-group $RESOURCEGROUP_NAME)" == "false" ] | |
then | |
az group create --name $RESOURCEGROUP_NAME --location $LOCATION | |
echo "Resource Group $RESOURCEGROUP_NAME created" | |
fi | |
RESOURCEGROUP_ID=$(az group show --name $RESOURCEGROUP_NAME --query id -o tsv) | |
echo "Create the Peering VNET" | |
if [ "$(az network vnet show -n $PUB_VNET_NAME -g $RESOURCEGROUP_NAME --query id -o tsv)" == "[]" ] | |
then | |
az network vnet create --name $PUB_VNET_NAME --address-prefixes $PUB_VNET_PREFIX \ | |
--location $LOCATION --resource-group $RESOURCEGROUP_NAME | |
echo "Peering Virtual Network $PUB_VNET_NAME created " | |
fi | |
VNET_ID=$(az network vnet show -n $PUB_VNET_NAME -g $RESOURCEGROUP_NAME --query id -o tsv) | |
######################################################## | |
echo "Start the Cluster provisioning !" | |
echo "Create the resource group for ARO " | |
if [ "$(az group exists --resource-group $CLUSTER_RESOURCEGROUP_NAME)" == "false" ] | |
then | |
az group create --name $CLUSTER_RESOURCEGROUP_NAME --location $LOCATION | |
echo "Resource Group $CLUSTER_RESOURCEGROUP_NAME created" | |
fi | |
######################################################## | |
#Create ARO Cluster, linked to a VNET, AzureAD | |
echo "Creating Azure Red Hat OpenShift Cluster:" | |
az openshift create --resource-group $CLUSTER_RESOURCEGROUP_NAME --name $CLUSTER_NAME \ | |
--aad-client-app-id $APP_ID --aad-client-app-secret $SECRET --aad-tenant-id $TENANT_ID \ | |
--customer-admin-group-id $SECGROUP_ID --vnet-peer $VNET_ID --location $LOCATION --vnet-prefix $ARO_VNET_PREFIX \ | |
--subnet-prefix $ARO_SUBNET_PREFIX --compute-vm-size Standard_E4s_v3 | |
######################################################## | |
#Extract the PUBLIC HOSTNAME | |
#if [ $? -eq 0 ]; then | |
if [ "$(az openshift show -n $CLUSTER_NAME -g $CLUSTER_RESOURCEGROUP_NAME --query publicHostname -o tsv)" != "[]" ] | |
then | |
PUBLIC_HOSTNAME=$(az openshift show -n $CLUSTER_NAME -g $CLUSTER_RESOURCEGROUP_NAME --query publicHostname -o tsv) | |
echo "Setting up the App-Registration's Reply URL:" | |
echo '>> az ad app update --id $APP_ID --reply-urls "https://$PUBLIC_HOSTNAME/oauth2callback/Azure%20AD"' | |
az ad app update --id $APP_ID --reply-urls "https://$PUBLIC_HOSTNAME/oauth2callback/Azure%20AD" | |
echo "========================================================" | |
echo "ARO Cluster Name: " $CLUSTER_NAME | |
echo "ARO Resource Group Name: " $CLUSTER_RESOURCEGROUP_NAME | |
echo "ARO Public Hostname: https://$PUBLIC_HOSTNAME" | |
echo "========================================================" | |
fi | |
echo "OpenShift Cluster deployment is finalized" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment