Azure + Packer

Yes, it works. How cool is that?
The hardest part is to set up your environment and even that is easy. Kudos to MS.

What you’ll need: a linux machine, golang, packer, Azure plugin for packer, nodejs, Azure cli tools and an Azure subscription.

I’ll start with a clean Ubuntu 14.04 machine.
Let’s start by installing node, npm, git and mercurial (which you’ll need to install the Azure packer plugin).

sudo apt-get install node npm git mercurial  

In Ubuntu node binary is called nodejs because there’s another package called node. One quick fix is to symlink nodejs to node.

sudo ln -s /usr/bin/nodejs /usr/bin/node  

Then we need to install Azure CLI tools. For this we use npm:

sudo npm -g install azure-cli  

And packer. But in order to use Packer and the Azure plugin for Packer you first have to have a recent version of Go (>=1.4).

wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz  

Unpack it somewhere. I use ~/opt/go
Now we set it up

export PATH=$HOME/opt/go/bin:$PATH  
export GOROOT=$HOME/opt/go  
export GOPATH=$HOME/go  

You might want to add these to your shell settings (like .bashrc).
Test by running go version. You should see something like:

fx@azure-playground:~$ go version  
go version go1.5.1 linux/amd64  

Download packer from packer.io and unpack it:

wget https://dl.bintray.com/mitchellh/packer/packer_0.8.6_linux_amd64.zip  
unzip packer_0.8.6_linux_amd64.zip -d packer  

Now, install the Azure plugin for Packer

cd packer  
# the built plugin will be placed in current directory
export GOBIN=$PWD  
go get github.com/MSOpenTech/packer-azure/packer/plugin/...  

Now, set up Azure CLI if you haven’t done so already.
This is as easy as

azure account download  

This will give you a link to download your settings file. This will have to be done using a real browser. Once you have it, set it up:

azure account import ~/azuresubscription.publishsettings  

In order to use packer, you need a storage account:

azure storage account create packer -l "North Europe" -d "My Packer images" --type GRS  

Now is the moment of truth, if everything went well up to now then you should be able to create a packer image.
Let’s create a very minimal packer json file:

{
  "variables": {
    "sn": "Windows Azure MSDN - Visual Studio Ultimate",
    "ps": "/home/fx/azuresubscription.publishsettings",
    "sa": "packer"
  },
  "builders": [
    {
      "type": "azure",
      "publish_settings_path": "{{user `ps`}}",
      "subscription_name": "{{user `sn`}}",
      "storage_account": "{{user `sa`}}",
      "storage_account_container": "images",
      "os_type": "Linux",
      "os_image_label": "Ubuntu Server 14.04 LTS",
      "location": "North Europe",
      "instance_size": "Small",
      "user_image_label": "Ubuntu1404LTS"
    }
  ],
  "provisioners": [
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "inline": [
        "sudo apt-get update",
        "sudo apt-get -y upgrade"
      ],
      "inline_shebang": "/bin/sh -x",
      "type": "shell"
    }
  ]
}

You can see more examples on github.
Save it as ubuntu.json and check for errors:

./packer validate ubuntu.json

If no errors were reported, go ahead and build it:

./packer build ubuntu.json

Once the build is done you’ll see something like

...
==> Builds finished. The artifacts of successful builds are:
--> azure: {imageLabel: 'Ubuntu1404LTS',imageName: 'Ubuntu1404LTS_2015-09-27_13-55',mediaLocation: 'https://packer.blob.core.windows.net/images/Ubuntu1404LTS_2015-09-27_13-55-os-2015-09-27.vhd'}

Confirm by running:

azure vm image show Ubuntu1404LTS_2015-09-27_13-55  

Congrats, you have your first Packer image on Azure

Battlefield 4 campaign sucks and games in general

Yes, this is probably common knowledge in the gamer community, but it was a bit surprising to me since I’m no gamer.
Imagine, you are shooting your way through the mission and you have couple of good guys with you, yet they can’t seem to shoot anyone and they also never die. They are worse than worthless as they create the illusion of you having some assistance which is not true.
Next example, you need to fetch a missile launcher but one of your guys is standing in front of stairs that you need to take in order to get that said launcher. And the only solution is to shoot your own guy. It’s even on reddit.

Guess I should have read the reviews. But i’s ok as I only spent 10 euros on the game as it is quite old and the multiplayer is quite OK.

Why am I writing all this? Well, I have an old (by todays standard) PS3 console. It usually just sits and collects dust but from time to time I do get the urge to play something, so I buy some older game, play for a week or two and move on. This is actually quite interesting, new games cost 40 – 60 euros. In a year they cost only 20-30 and in 2 years you can get them for a price of a movie ticket. It’s not that I’m cheap, but somehow I can’t bring myself to pay 60 euros for a game that I might get bored with in a week.