Trying out Windows Nano with Vagrant and Packer on Ubuntu
This is mostly going to be informational/exploratory than anything you might actually do anything with, and Windows is, admittedly, something I know very little about. I’d be lying if I said PowerShell hadn’t fascinated me because I didn’t understand how useful it could be. With the forthcoming Nano changing how folks perceive and interact with Windows Server, I thought it was time to begin a critical reappraisal of how I think of it, too.
The short version of this story is that I wanted to see what all the hype was about, and given the sometimes-prohibitive cost of a Windows Server for something like testing and development made it inconvenient (even if cost were not a factor) to try out Windows Nano. To that end, I sought out and found a great Vagrant template for use with Packer:
In a past-life, I was a Windows Server administrator (albeit a reluctant, and not very good, one), so my interest was piqued by a Windows product with a smaller footprint, and indulge the part of myself that is interested by all things service-oriented (okay: I’ll admit, I read a thing about running Docker on it, and thought I’d give it a whirl, but also reminded me of the fun Powershell automation can be).
If you’re like me, and running a Linux desktop, all you should require is:
- The above repo
- Vagrant & Packer (if you plan to build the image manually)
in order to run the Nano server Vagrant box.
To prepare the environment, and start up the image, you can run the following:
apt-get update && \
wget https://releases.hashicorp.com/vagrant/1.8.5/vagrant_1.8.5_x86_64.deb && \
dpkg -i vagrant_1.8.5_x86_64.deb && \
wget https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip && \
apt-get install unzip virtualbox git-core -y && \
unzip packer_0.10.1_linux_amd64.zip && \
git clone https://github.com/mwrock/packer-templates.git && \
cd packer-templates && ../packer build -force -only virtualbox-iso ./vbox-nano.json
The above will install the required packages (`git-core`, `virtualbox`,`unzip`), download and install Packer and Vagrant, clone the templates repo (and related assets), and build and launch the VM.
You can pull a prebuilt box using:
vagrant box add https://atlas.hashicorp.com/mwrock/boxes/WindowsNano
vagrant init mwrock/WindowsNano mwrock/WindowsNano
Login with user name `vagrant`, password `vagrant`:
You’ll see the installation begin and run through the setup (the unattended installation manifests are included in the repo).
The two things that I found most appealing as starter projects would be:
- Installing Docker and running some containers:
This document will step through a very basic Nano Server deployment with the Windows container feature. This is an…msdn.microsoft.com
2. Creating some Powershell cmdlets:
Applies To: Windows Server Technical Preview Nano Server includes PowerShell Core by default in all Nano Server…technet.microsoft.com
But before that, running remote tasks on my Nano VM from Ubuntu typically requires PowerShell be installed on my client machine, however, this is not something that comes with a Linux distribution, so I found a Python implementation of a WinRM client:
sudo pip install pywinrm
which can be used like so to authenticate (if you’re running Nano locally):
>>> import winrm
>>> winrmsession = winrm.Session(“127.0.0.1:55985”, auth=(‘vagrant’,’vagrant’))
and then run commands or PowerShell functions:
>>> result = winrmsession.run_ps(…)
>>> result = wwinrmsession.run_cmd(...)
More on pywinrm can be found here.
The cool part about this is that, if you do not have myriad experience, you can come at this from the intended approach; viewing Windows Nano as an environment for this new task-based “unit of execution”. Perhaps a bit of a stretch, but by having apps invoke the Nano server on a task-by-task basis, creating and destroying processes as required, etc. there’s a case to be made for Nano as the backbone of a “serverless” (as it appears to the developer) architecture when managing Windows-based applications as we start to see cooler and cooler services emerge for Nano systems.
The takeway from this piece should be: I, for one, am expecting cool things from Microsoft down the road, if their recent moves alone were any indication, as a result of this product.