<\/a>
\nThis will generate a MAAS compatible image starting from a Windows ISO, it requires Hyper-V:<\/p>\ncd $HOME\\hyper-c\\windows-imaging-tools\r\n\r\n# Mount Windows Server 2016 TP4 ISO\r\n# Change path to actual ISO\r\n$isoPath = $HOME\\Downloads\\WindowsServer2016TP4.iso\r\n\r\n# Mount the ISO\r\n$driveLetter = (Mount-DiskImage $isoPath -PassThru | Get-Volume).DriveLetter \r\n$wimFilePath = \"${driveLetter}:\\sources\\install.wim\"\r\n \r\nImport-Module .\\WinImageBuilder.psm1 \r\n \r\n# Check what images are supported in this Windows ISO\r\n$images = Get-WimFileImagesInfo -WimFilePath $wimFilePath\r\n \r\n# Get the Windows images available in the ISO \r\n$images | select ImageName \r\n \r\n# Select the first one. Note: this will generate an image of Server Core.\r\n# If you want a full GUI, or another image, choose from the list above\r\n$image = $images[0]\r\n \r\n$targetPath = \"$HOME\\DiskImages\\Win2016.raw.tgz\" \r\n \r\n# Generate a Windows Server 2016 image, this will take some time!\r\n# This requires Hyper-V for running the instance and installing Windows updates\r\n# If your hardware needs extra drivers for NIC or storage, you can add it by\r\n# passing the -ExtraDriversPath option to the script.\r\n# You also have the option to install Windows Updates by passing in the -InstallUpdates option\r\nNew-MAASImage -WimFilePath $wimFilePath -ImageName $image.ImageName `\r\n-MAASImagePath $targetPath -SizeBytes 20GB -Memory 2GB `\r\n-CpuCores 2\r\n\r\ncd ..\r\n\r\n# Copy the Nano image to the MAAS host\r\n.\\pscp.exe \"$targetPath\" \"cloudbase@${MAAS_HOST}:\"<\/pre>\nUpload the image to MAAS:<\/p>\n
# upload image to MAAS\r\n# At the time of this writing, MAAS was version 1.8 in the stable ppa\r\n# Windows Server 2016 and Windows Nano support has been added in the next stable release.\r\n# as such, the images we are uploading, will be \"custom\" images in MAAS. With version >= 1.9\r\n# of MAAS, the name of the image will change from win2016 to windows\/win2016\r\n# and the title will no longer be necessary\r\nmaas root boot-resources create name=win2016 title=\"Windows 2016 server\" architecture=amd64\/generic filetype=ddtgz content@=$HOME\/Win2016.raw.tgz\r\n<\/pre>\nAs with the Nano image, the name is important. It must<\/strong> be win2016.<\/p>\n <\/p>\n
Setting up Juju<\/h2>\n
Now the fun stuff begins. We need to fetch the OpenStack Juju charms and juju-core binaries, and bootstrap the juju state machine. This process is a bit more involved, because it requires that you copy the agent tools on a web server (any will do). A simple solution is to just copy the tools to “`\/var\/www\/html“` on your MAAS node, but you can use any web server at your disposal .<\/p>\n
For the juju deployment you will need to use an Ubuntu machine. We generally use the MAAS node directly in our demo setup, but if you are running Ubuntu already, you can use your local machine.<\/p>\n
<\/p>\n
Fetch the charms and tools<\/h3>\n
For your convenience we have compiled a modified version of the agent tools and client binaries that you need to run on Nano Server. This is currently necessary as we’re still submitting upstream the patches for Nano Server support, so this step won’t be needed by the time Windows Server 2016 is released.<\/p>\n
From your Ubuntu machine:<\/p>\n
# install some dependencies\r\n# add the juju stable ppa. We need this to get juju-deployer\r\nsudo apt-add-repository -y ppa:juju\/stable\r\n# install packages\r\nsudo apt-get update\r\nsudo apt-get -y install unzip git juju-deployer\r\n\r\nmkdir -p $HOME\/hyper-c\r\ncd $HOME\/hyper-c\r\n\r\n# Download juju-core with Nano support and the Hyper-C charms\r\ngit clone https:\/\/github.com\/cloudbase\/hyper-c.git hyper-c-master\r\nwget \"https:\/\/github.com\/cloudbase\/hyper-c\/releases\/download\/hyper-c\/juju-core.zip\"\r\nunzip juju-core.zip\r\n\r\n# Add the client folder to the $PATH. You can make this change permanend\r\n# for the current user by adding:\r\n# export PATH=\"$HOME\/hyper-c\/juju-core\/client:$PATH\"\r\n# to $HOME\/.bashrc\r\nexport PATH=\"$HOME\/hyper-c\/juju-core\/client:$PATH\"\r\n# test that the juju client is in your path\r\njuju version\r\n<\/pre>\nIf everything worked as expected, the last command should give you the Juju version.<\/p>\n
<\/p>\n
Configuring the Juju environment<\/h3>\n
If you look inside “`$HOME\/hyper-c\/juju-core“` you will see a folder called “`tools“`. You need to copy that folder to the web server of your choice. It will be used to bootstrap the state machine. Lets copy it to the MAAS node:<\/p>\n
# NOTE: If you are following this article directly on your MAAS node,\r\n# you can skip these steps\r\ncd $HOME\/hyper-c\r\nscp -r $HOME\/hyper-c\/juju-core\/tools cloudbase@$MAAS_HOST:~\/<\/pre>\nNow, ssh into your MAAS node and copy these files in a web accessible location:<\/p>\n
sudo cp -a $HOME\/hyper-c\/juju-core\/tools \/var\/www\/html\/\r\nsudo chmod 755 -R \/var\/www\/html\/tools<\/pre>\nBack on your client machine, create the juju environments boilerplate:<\/p>\n
juju init<\/pre>\nThis will create a folder “`$HOME\/.juju“`. Inside it you will have a file called “`environments.yaml“` that we need to edit.<\/p>\n
Edit the environments file:<\/p>\n
nano $HOME\/.juju\/environments.yaml<\/pre>\nWe only care about the MAAS provider. You will need to navigate over to your MAAS server under “`http:\/\/${MAAS_HOST}\/MAAS\/account\/prefs\/<\/strong>“` and retrieve the MAAS API key like you did before.<\/p>\nReplace your “`environments.yaml“` to make it look like the following:<\/p>\n
default: maas\r\n\r\nenvironments:\r\n maas:\r\n type: maas\r\n # this is your MAAS node. Replace \"MAAS_IP\" with the actual hostname or IP\r\n maas-server: 'http:\/\/MAAS_IP\/MAAS\/'\r\n # This is where you uploaded the tools in the previous step. Replace \"MAAS_IP\" with actual hostname or IP\r\n agent-metadata-url: \"http:\/\/MAAS_IP\/tools\"\r\n agent-stream: \"released\"\r\n maas-oauth: 'maas_API_key'\r\n # This will become you juju administrative user password\r\n # you may use this password to log into the juju GUI\r\n admin-secret: 'your_secret_here'\r\n disable-network-management: false\r\n bootstrap-timeout: 1800<\/pre>\nBefore you bootstrap the environment, it’s important to know if the newly bootstrapped state machine will be reachable from your client machine. For example, If you have a lab environment where all your nodes are in a private network behind MAAS, where MAAS is also the router for the network it manages, you will need to do two things:<\/p>\n
\n- enable NAT and ip_forward on your MAAS node<\/li>\n
- create a static route entry on your client machine that uses the MAAS node as a gateway for the network you configured in MAAS for your cluster<\/li>\n<\/ul>\n
Enable NAT on MAAS:<\/p>\n
# enable MASQUARADE\r\n# br0 publicly accessible interface\r\n# br1 MAAS management interface (PXE for nodes)\r\n\/sbin\/iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE\r\n\/sbin\/iptables -A FORWARD -i br0 -o br1 -m state --state RELATED,ESTABLISHED -j ACCEPT\r\n\/sbin\/iptables -A FORWARD -i br1 -o br0 -j ACCEPT\r\n\r\n# enable ip_forward\r\necho 'net.ipv4.ip_forward=1' >> \/etc\/sysctl.conf\r\nsysctl -p\r\n\r\n<\/pre>\nAdd a static route on your client:<\/p>\n
# $MAAS_HOST was defined above in the sections regarding image generation\r\n# NOTE: this is not needed if you are running the juju client directly on your MAAS node\r\nroute add -net 192.168.2.0 255.255.255.0 gw $MAAS_HOST<\/pre>\nYou are now ready to bootstrap your environment:<\/p>\n
# Adapt the tags constraint to your environment\r\njuju bootstrap --debug --show-log --constraints tags=state<\/pre>\n <\/p>\n
Deploy the charms<\/h3>\n
You should now have a fully functional juju environment with Windows Nano Server support. Time to deploy the charms!<\/p>\n
This is the last step in the deployment process. For your convenience, we have made a bundle file available inside the repository. You can find it in:<\/p>\n
$HOME\/hyper-c\/hyper-c-master\/openstack.yaml<\/pre>\nMake sure you edit the file and set whatever options applies to your environment. For example, the bundle file expects to find nodes with certain tags. Here is an example:<\/p>\n
s2d-proxy:\r\n num_units: 1\r\n charm: local:win2016\/s2d-proxy\r\n branch: lp:cloudbaseit\/s2d-proxy\r\n options:\r\n # Change this to an IP address that matches your environment.\r\n # This IP address should be in the same network as the IP addresses\r\n # you configured your MAAS cluster to assign to your nodes. Make sure\r\n # that this IP cannot be allocated to any other node. This can be done\r\n # by leaving a few IP addresses out of the static and dynamic ranges MAAS\r\n # allocates from.\r\n # For example: 192.168.2.10-192.168.2.100 where 192.168.2.0-192.168.2.9\r\n # are left for you to decide where to allocate them.\r\n static-address: 192.168.2.9\r\n # change this tag to match a node you want to target\r\n constraints: \"tags=s2d-proxy\"\r\nnova-hyperv:\r\n num_units: 4\r\n charm: local:win2016nano\/nova-hyperv\r\n branch: lp:cloudbaseit\/nova-hyperv\r\n options:\r\n use-bonding: false\r\n # These are all the MAC addresses from all the nodes that are supposed to be\r\n # used as data ports. You can find these ports in MAAS under node details\r\n # Make sure you change this to match your environment.\r\n data-port: \"3c:18:a0:05:cd:1c 3c:18:a0:05:cd:07 3c:18:a0:05:cd:22 3c:18:a0:05:cd:1e\"\r\n network-type: \"hyperv\"\r\n openstack-version: \"liberty\"\r\n constraints: \"tags=nano\"<\/pre>\nPay close attention to every definition in this file. It should precisely mirror your environment (tags, MAC addresses, IP addresses, etc). A misconfiguration will yield unpredictable results.<\/p>\n
Use “`juju-deployer“` to deploy everything with just one command:<\/p>\n
cd $HOME\/hyper-c\/hyper-c-master\r\njuju-deployer -L -S -c openstack.yaml<\/pre>\nIt will take a while for everything to run, so sit back and relax while your environment deploys. There is one more thing worth mentioning. Juju has a gorgeous web GUI. Its not resource intensive, so you can deploy it to your state machine. Simply:<\/p>\n
juju deploy juju-gui --to 0<\/pre>\nYou will be able to access it using the IP of the state machine. To get the ip simply do:<\/p>\n
juju status --format tabular<\/pre>\nThe user name will be “`admin“` and the password will be the value you set for “`admin-secret“`, set in\u00a0juju’s environments.yaml.<\/p>\n
At the end of this you will have the following setup:<\/p>\n