This repository was archived by the owner on Dec 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'azure-dev' into tm-azure-merge-and-update
- Loading branch information
Showing
5 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,77 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Options | ||
| BRANCH="${1:-azure-dev}" # checkout branch $1 | ||
|
|
||
| # Provider Config - update *-azure.sh files. | ||
| LOCATION=centralus | ||
|
|
||
| # Static Config - update *.sh files | ||
| NAME=learner | ||
| VM=essentials | ||
| PROJECT=CLASS-Essentials | ||
| GITHUB=github.internet2.edu | ||
| REPO="git@${GITHUB}:CLASS/${PROJECT}.git" | ||
|
|
||
| echo "=== azure-create.sh $PROJECT $BRANCH" | ||
| SUBSCRIPTION=$(az account show --query id -otsv) | ||
| RESOURCE_GROUP="rg-${VM}-dev" | ||
|
|
||
| echo "+++ creating resource group $RESOURCE_GROUP $SUBSCRIPTION" | ||
| az group create --resource-group $RESOURCE_GROUP --location $LOCATION | ||
|
|
||
| echo "+++ creating VM $VM" | ||
| # Ubuntu is "Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest" | ||
| # Debian is "Debian:debian-10:10:latest" | ||
| # Resource Group scope "subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP" | ||
| az vm create --resource-group $RESOURCE_GROUP --name $VM \ | ||
| --image Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest \ | ||
| --size Standard_D2_v4 \ | ||
| --storage-sku Standard_LRS \ | ||
| --public-ip-sku Standard \ | ||
| --assign-identity \ | ||
| --scope "subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP" \ | ||
| --admin-username $NAME | ||
|
|
||
| IP=$(az vm show --name $VM --resource-group $RESOURCE_GROUP -d --query publicIps -otsv) | ||
| IDENTITY=$(az vm show --name $VM --resource-group $RESOURCE_GROUP --query identity.principalId -otsv) | ||
|
|
||
| echo "+++ assign the VM the Contributor role to the subscription ($IDENTITY to $SUBSCRIPTION)" | ||
| az role assignment create --assignee $IDENTITY --scope /subscriptions/$SUBSCRIPTION --role Contributor | ||
|
|
||
| echo "+++ wait for boot and cloud-init ${VM} ${IP}" | ||
| ssh-keygen -R $IP | ||
| while ! ssh $NAME@$IP sudo cloud-init status --wait ; do | ||
| sleep 1 | ||
| done | ||
|
|
||
| echo "+++ configuring VM" | ||
| ssh -A $NAME@$IP <<EOF | ||
| echo '--- connected to $NAME@IP' | ||
| sudo apt-get update | ||
| sudo apt-get install --yes azure-cli | ||
| az login --identity | ||
| sudo apt-get install --yes git python3-pip python3-venv bash-completion | ||
| ssh-keyscan ${GITHUB} > .ssh/known_hosts | ||
| git config --global color.ui auto | ||
| git config --global push.default simple | ||
| git config --global pull.ff only | ||
| git config --global user.name "$(git config user.name)" | ||
| git config --global user.email "$(git config user.name)" | ||
| git clone --branch $BRANCH $REPO | ||
| EOF | ||
|
|
||
| echo "+++ configure ~/.ssh/$VM.config" | ||
| cat > ~/.ssh/$VM.config <<EOF | ||
| Host essentials | ||
| HostName $IP | ||
| CheckHostIP=no | ||
| ForwardAgent=yes | ||
| User=$NAME | ||
| EOF | ||
|
|
||
| echo "+++ starting Jypter" | ||
| ssh $NAME@$IP -t -L 8080:localhost:8080 -L 8081:localhost:8081 "cd $PROJECT ; ./scripts/jupyter-lab.sh" | ||
|
|
||
| echo "+++ ssh command" | ||
| echo "ssh $NAME@$IP" |
This file contains hidden or 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,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Provider Config - update *-azure.sh files. | ||
|
|
||
| # Static Config - update *.sh files | ||
| VM=essentials | ||
|
|
||
| echo "=== azure-delete.sh $PROJECT $BRANCH" | ||
| SUBSCRIPTION=$(az account show --query id -otsv) | ||
| RESOURCE_GROUP="rg-${VM}-dev" | ||
|
|
||
| az vm delete --resource-group $RESOURCE_GROUP --name $VM --yes | ||
| az group delete --resource-group $RESOURCE_GROUP --yes |
This file contains hidden or 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