How to add a windows machine to juju - development and testing windows units
Using an OpenStack cloud
These instructions have been confirmed with trial and error. They are focused on juju 2.9+ due to agent tarball naming and how the simplestreams are created.
Get a Windows Image and add to your OpenStack project.
You need a windows image with cloud init capabilities. I used the Windows 2012 R2 evaluation image from CloudBase. Download KVM version here.
-
Source your novarc file.
-
Add the windows image to your OpenStack project:
gunzip -cd windows_server_2012_r2_standard_eval_kvm_20170321.qcow2.gz | openstack image create --project $OS_PROJECT_ID --property hypervisor_type=QEMU --container-format bare --disk-format qcow2 --property os_type=windows windows2012r2
-
Save the ID of the image created.
If the OpenStack is using ceph the above method can produce an image which is slow for juju to use, requiring a couple of attempts within juju retries to create the machine. Alternative it’s been suggested to try:
qemu-img convert -f qcow2 -O raw windows_image.qcow2 windows_image.raw
openstack image create --project $OS_PROJECT_ID --property hypervisor_type=QEMU --container-format bare --disk-format raw --property os_type=windows --file ./windows_image.raw windows2012r2
Prepare juju agent tarballs, during development.
-
Create a folder for the metadata command to find the agent tar balls
mkdir ~/simplestreams/tools/released.
-
Compile juju for ubuntu and again for windows
make install GOOS=windows make install
-
cd to your bin dir and create tar balls, replace with 2.9.2 or whatever version you’ve compiled. To ensure that the correct binaries are used, I’ve edited version/version.go to change the juju version to a number not in the streams.
cd bin tar cvzf ~/simplestreams/tools/released/juju-<juju-version>-ubuntu-amd64.tgz containeragent juju jujuc jujud juju-metadata juju-wait-for pebble cd windows_amd64 tar cvzf ~/simplestreams/tools/released/juju-<juju-version>-amd64.tgz *.exe
-
Create the metadata, for juju 2.9+
juju metadata generate-agents -d $HOME/simplestreams --clean --prevent-fallback
Bootstrap juju
juju bootstrap --metadata-source $HOME/simplestreams <openstack-cloud>
Add a windows machine
-
Sync the agents, so the controller can find the windows agent you built.
juju sync-agent-binaries --source $HOME/simplestreams/tools
-
Tell juju which image is the windows one.
juju metadata add-image --series win2012r2 <saved-image-id>
-
Add the machine
juju add-machine --series win2012r2
If you’re using a released version of juju, you may still need to run juju sync-agent-binaries
by itself to pull down the windows binary from the streams.
Unconfirmed workflows
Using a vSphere cloud
Install a Windows VM manually in the vSphere. Install KVM tools and cloudinit. Create a template of the VM. Then provide the template for use by juju. New functionality in juju 2.9.0
Using a MAAS cloud
MAAS image builder is available to create a Windows image that juju can use. It’ll need KVM tools and cloudinit, maybe different drivers as well.