From f4aaa734ed30e5371cbc3537e52c983686855d37 Mon Sep 17 00:00:00 2001 From: Diego Casati Date: Thu, 19 Apr 2018 18:45:29 -0700 Subject: [PATCH 1/2] Initial import for Azure. - Add instructions on how to build an image on Azure - Add a Packer template --- README.md | 25 ++++++++++++++++ packer/rubber-docker-azure.json | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 packer/rubber-docker-azure.json diff --git a/README.md b/README.md index 0b5efcd..4b7c078 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ We therefore wrote a python module called *linux* (take a look at [linux.c](linu Have a look at the [module documentation](https://rawgit.com/Fewbytes/rubber-docker/master/docs/linux/index.html) for more info. ## Quickstart +### On AWS There are currently 3 options to start the workshop by yourself: 1. We created a public AMI with the required configuration and utilities already installed: @@ -34,6 +35,30 @@ There are currently 3 options to start the workshop by yourself: 1. We have a [Vagrantfile](https://www.vagrantup.com/) for you to run using your favorite virtual machine hypervisor (NOTE: not yet fully tested). +### On Azure +We have a [packer template](https://www.packer.io/) so you can create your own +VM on Azure with the following procedure: + +1. Build the image with Packer: + ```bash + $ packer build packer/rubber-duck-azure.json + ``` +1. Create the VM based on the new image: + ```bash + az vm create \ + --resource-group PackerImages \ + --name rubber-duck \ + --location westus2 \ + --image rubberDuck \ + --admin-user ubuntu \ + --generate-ssh-keys + ``` +1. Once the VM is built, you can connect to it with SSH with the username `ubuntu` and + newly created private key: + + ```bash + $ ssh ubuntu@ -i ~/.ssh/ubuntu + ``` The workshop material is checked out at `/workshop` on the instance: - `/workshop/rubber-docker` - this repository, where you do all the work - `/workshop/images` - images for containers, already populated with ubuntu and busybox images diff --git a/packer/rubber-docker-azure.json b/packer/rubber-docker-azure.json new file mode 100644 index 0000000..8660134 --- /dev/null +++ b/packer/rubber-docker-azure.json @@ -0,0 +1,52 @@ +{ + "variables": { + "client_id": "{{env `ARM_CLIENT_ID`}}", + "client_secret": "{{env `ARM_CLIENT_SECRET`}}", + "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}" + }, + "builders": [{ + "type": "azure-arm", + + "client_id": "{{user `client_id`}}", + "client_secret": "{{user `client_secret`}}", + "subscription_id": "{{user `subscription_id`}}", + + "os_type": "Linux", + "image_publisher": "Canonical", + "image_offer": "UbuntuServer", + "image_sku": "16.04-LTS", + + "managed_image_resource_group_name": "PackerImages", + "managed_image_name": "rubberDuck", + + "location": "West US 2", + "vm_size": "Standard_DS2_v2" + }], + "provisioners": [{ + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'", + "inline": [ + "adduser --disabled-password --gecos \"\" ubuntu" + ], + "inline_shebang": "/bin/sh -x", + "type": "shell" + }, + { + "type": "file", + "source": "vimrc", + "destination": "/tmp/vimrc" + }, + { + "type": "shell", + "script": "bootstrap.sh" + }, + { + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'", + "inline": [ + "apt-get update", + "apt-get upgrade -y", + "/usr/sbin/waagent -force -deprovision && export HISTSIZE=0 && sync" + ], + "inline_shebang": "/bin/sh -x", + "type": "shell" + }] +} From c87b4aec651582f473f1e149d65fbc177980e535 Mon Sep 17 00:00:00 2001 From: Diego Casati Date: Mon, 23 Apr 2018 18:36:00 -0700 Subject: [PATCH 2/2] Update README.md s/duck/docker - typo on my side --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4b7c078..fc1a8b8 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,15 @@ VM on Azure with the following procedure: 1. Build the image with Packer: ```bash - $ packer build packer/rubber-duck-azure.json + $ packer build packer/rubber-docker-azure.json ``` 1. Create the VM based on the new image: ```bash az vm create \ --resource-group PackerImages \ - --name rubber-duck \ + --name rubber-docker \ --location westus2 \ - --image rubberDuck \ + --image rubberDocker \ --admin-user ubuntu \ --generate-ssh-keys ```