diff --git a/azure/README.md b/azure/README.md index 3e4dc21..45e6370 100644 --- a/azure/README.md +++ b/azure/README.md @@ -1,48 +1,56 @@ SWH azure provisioning ------------------------- # Pre-requisite - az [1] - rights in the azure portal [2] [1] https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-apt?view=azure-cli-latest [2] https://portal.azure.com # Create vm ``` sh $ ./create-vm.sh # create a node with name `name` and `type` at `location` # ... $ ./create-vm.sh worker01 worker euwest # creates a node worker01.euwest.azure of type `worker` at location `euwest` (default) # ... -$ ./create-vm.sh webapp0 webapp -# creates a node webapp0 of type `something-different-than-worker-type` -# at location euwest +$ ./create-vm.sh dbreplica1 db +# creates a node webapp0 of type `db` at location euwest +# ... ``` -Example name: +Possible names: - worker01 - webapp0 - dbreplica0 + +Possible types: +- db (replica or otherwise) +- storage (stoarge service) +- worker (computing nodes) +- webapp + + This will: - create an azure vm node - running the latest debian stable (9 as of this writing) - with admin user zack (uid 1000) - with a local public key (so that we can connect later on) - and continue the provisioning steps # Provision ``` sh ADMIN_USER=zack scp ./provision-vm.sh $ADMIN_USER@:/tmp/ ssh $ADMIN_USER@ sudo /tmp/provision-vm.sh ``` # More documentation cf. [New machine setup](https://wiki.softwareheritage.org/index.php?title=New_machine_setup) diff --git a/azure/create-vm.sh b/azure/create-vm.sh index b1f0d2c..affa43c 100755 --- a/azure/create-vm.sh +++ b/azure/create-vm.sh @@ -1,60 +1,69 @@ #!/bin/sh # node's name defined by the user nodename=${1-"worker01"} # type of nodes: # - worker # - other things (dbreplica, webapp, etc...) type=${2-"worker"} # where to install this (not expected to change though) resource_prefix=${3-"euwest"} location=westeurope # Depending on the types, we compute the resource group +# worker, db, storage have dedicated shared resource group +# other can be specifically tailored for them if [ $type = 'worker' ]; then # for workers, it's a shared resource - resource_group="${resource_prefix}-workers" + resource_group="${resource_prefix}-${type}s" +elif [ $type = 'db' ]; then + # for dbs as well + resource_group="${resource_prefix}-${type}" +elif [ $type = 'storage' ]; then + resource_group="${resource_prefix}-server" else - # for other nodes, that is specifically tailored for + # for other node types (webapp), that is specifically tailored for resource_group="${resource_prefix}-${nodename}" - # create the resource group specific - az group create --name "${resource_group}" --location "${location}" fi +# create the resource group specific (idempotent, if already existing, +# do nothing) +az group create --name "${resource_group}" --location "${location}" + # Image we create the node from image=credativ:Debian:9:latest # Using the user's default public key for ssh connection pub_key=~/.ssh/id_rsa.pub # "default" subnet in the "swh-vnet" virtual network of the "swh-resource" resource group subnet=/subscriptions/49b7f681-8efc-4689-8524-870fc0c1db09/resourceGroups/swh-resource/providers/Microsoft.Network/virtualNetworks/swh-vnet/subnets/default # Change for virtual machine size. # - Standard_DS = SSD; # - Standard_S = Standard disk. # Use `az vm list-sizes -l westeurope -o table` to list allowed VM # types vm_type="Standard_DS2_v2" # vm_type=Standard_DS11_v2 # vm_type="Standard_B2ms" # boot diagnostic storage resource diagnostics_resource=swhresourcediag966 # zack is the uid 1000 in our manifest using it simplifies the # creation and removes the otherwise necessary steps to remove that # user admin_user=zack az vm create \ --name "${nodename}-${resource_prefix}" \ --resource-group "${resource_group}" \ --location "${location}" \ --image "${image}" \ --size "${vm_type}" \ --subnet "${subnet}" \ --admin-username "${admin_user}" \ --ssh-key-value "${pub_key}" \ --boot-diagnostics-storage "http://${diagnostics_resource}.blob.core.windows.net/"