Last active
July 28, 2022 17:37
-
-
Save weinong/e658c2ef731b2a8a30424f376947cd2b to your computer and use it in GitHub Desktop.
azure vm with tailscale
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
| #cloud-config | |
| package_update: true | |
| runcmd: | |
| - curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.gpg | apt-key add - | |
| - curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.list | tee /etc/apt/sources.list.d/tailscale.list | |
| - apt-get update | |
| - apt-get install -y tailscale | |
| - tailscale up --authkey AUTH_KEY |
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
| #!/bin/bash | |
| set -e | |
| az_subscription="" | |
| az_region="westus2" | |
| az_resource_group=weinongw-${az_region} | |
| az_vm_name=myvm | |
| #az_image_name=Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest # 20.04 | |
| az_image_name=UbuntuLTS # 18.04 | |
| az_vnet_name=vnet | |
| az_vnet_address_space=10.0.0.0/16 | |
| az_subnet_name=devbox | |
| az_subnet_address_prefix=10.0.10.0/24 | |
| ssh_key=$(ssh-add -L) | |
| tailscale_auth_key="" # get one off key from https://tailscale.com/kb/1085/auth-keys/ | |
| az account set --subscription "${az_subscription}" | |
| az group create -n "${az_resource_group}" -l "${az_region}" | |
| az network nsg create -n "${az_subnet_name}" -g "${az_resource_group}" | |
| az network vnet create -n "${az_vnet_name}" -g "${az_resource_group}" \ | |
| --location "${az_region}" --address-prefixes "${az_vnet_address_space}" \ | |
| --subnet-name "${az_subnet_name}" --subnet-prefixes "${az_subnet_address_prefix}" | |
| az network vnet subnet update -g "${az_resource_group}" -n "${az_subnet_name}" \ | |
| --vnet-name "${az_vnet_name}" --nsg "${az_subnet_name}" | |
| az vm create -n "${az_vm_name}" -g "${az_resource_group}" \ | |
| --size Standard_D4s_v3 \ | |
| --image "${az_image_name}" --admin-username weinongw --ssh-key-values "${ssh_key}" \ | |
| --vnet-name "${az_vnet_name}" --subnet "${az_subnet_name}" \ | |
| --public-ip-address "" --nsg-rule NONE \ | |
| --custom-data "$(sed "s/AUTH_KEY/${tailscale_auth_key}/" cloud-init.yaml)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment