First published on TechNet on Mar 21, 2016
Hi Matthew Walker here again. So in the course of learning the new features of Windows Server 2016 it is very useful to be to be able to have an environment built out quickly. There are multiple ways to address this. My co-worker Jaromir has his way which is built upon https://ws2016lab.codeplex.com/ I’m going to let Jaromir explain his environment and rules for using the scripts he created. First a little bit of legalese: Disclaimer The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. I would also like to point out that I am referencing scripts that are developed and made available under various OSS licenses, so please check and read them to ensure you are complying with the requirements they have. And now on to Jaromir -- Hey all! My name is Jaromir and I’m based in Czech republic – Prague. We Czechs are lazy people, so lazy that if something works somehow, but not perfectly, we spend weeks figuring out/working hard to make things better to save work in future. So if we have people in MSFT like Ben Armstrong (VirtualPCGuy) or John Marlin(Cluster Guy), I would be probably Jaromir Kaspar (LazyGuy). I also like things simple, so I’ll also consider SimpleGuy J. So when we started developing the new workshop, I just didn’t like the way the labs were prepared – usually all labs were huge (at least 50GB) as someone just configured some baseline and exported it. This might introduce a problem as we are moving to faster releases with Windows 10 and Windows Server could easily follow along in todays fast changing technological landscape. Also, when developing workshops before the launch of an OS we need to test features as it lands into the internal builds. So I decided to go with a different approach. I tried first to use some hydration scripts – either internal or projects like PDT. Neither fit my needs – either it was too complex or was not able to deploy Nano Servers. So I decided to write scripts by myself. Result: my labs are 18KB. Yes, 18KB. Just bunch of scripts that can hydrate everything we need in less than 30 minutes and hydrate a lab scenario in less than 5 minutes. You think it’s complex? Nope, as I said, I’m just lazy, simple guy – and this was my first PowerShell project. So you can do it also! This is only possible because we are using modern technologies such as Desired State Configuration for Domain Controller hydration and PowerShell direct for VM configuration. All those features come with Windows 10 and Windows Server 2016 TP4, so it is a requirement for Hyper-V host. So how do my scripts work? Magic. Actually it’s just PowerShell. And it’s really easy to use! Right-click and run with PowerShell these scripts: 1-Prereq -> 2-CreateParentDisks -> 3-Deploy -> Cleanup (if needed) -> modify variables.ps1 -> 3-Deploy again. If you need different configurations, you can create hash table like this (you can find it in variables.ps1 also with other examples and more explanation) Or the same result with different syntax. But if you replace 1..4 with let’s say 1..100 you can have 100VMs deployed That’s it! Let me know if this works for you. Or If you would like to see some features, feel free to contact me! Lazy/Simple Guy JaromirK@msft http://ws2016lab.codeplex.com/ Thanks Jaromir So, I took a different road and found https://github.com/PlagueHO/LabBuilder and I chose to use that as my base to build out things. Everyone has different goals so each of us have differing ways to get to the end. By using an XML file for the config I am able to define exactly what I want to use, I can create a domain, add the hosts and use DSC to configure each VM to have the pieces I need. This way I can also maintain a couple of different configurations in XMLs and simply point the build to whichever one I want to use, whether it be to build out a lab for a workshop, a demo for a customer or an environment to reproduce an issue I am troubleshooting. As a bonus during this journey to figure out the right way for me, I have gotten a lot better at PowerShell, learned how to effectively use Desired State Configuration (DSC), and also learned of the different ways people approach similar problems. So let’s dive in to how to use LabBuilder to setup a simple configuration I have been using to work with the new Hyper-V options in Windows 10 and Server 2016 Technical Preview 4. So first off you will need an editor for XML and PowerShell, you can use the built in PowerShell Integrated Scripting Environment (PowerShell ISE), but I chose to use Visual Studio Code since I can point it to a directory and easily jump between files and it has a wide variety of extensions available to customize for the functions you need. You can find Visual Studio Code here https://code.visualstudio.com/ . Let’s start out with a simple environment with a Domain Controller and a member server running Hyper-V (I love nested virtualization available in current previews of Windows Server 2016 or Windows 10). So first I am going to load up the XML for the environment. First steps you would want to take is to edit the XML file you will use to configure the environment, for example in the screenshot below we setup the lab name and source for the DSC files to be used to configure the various hosts, as well as the path to where the VMs will be built. As we progress the next step would be to configure which virtual switches you would need for Hyper-V. From there we need to build out our VM template VHDs and since we want to start as small as possible, we point to the ISOs that have the source for install, and where to put those files we create. For 2016 these template VHDs also can be used to create Nano images and pre-load the various packages needed, in the example below we are adding the Hyper-V guest components. Now that we have sysprepped VHD files we can define a template for the VMs themselves that we can use for default values which we can override for specific VMs. Now let’s define a VM, we can set its name, the template to use, which DSC file to use for further configuration, parameters to pass to that DSC file as well as create and configure various network adapters and their IP addresses. We could also add additional data VHDs if those were necessary. Specifying additional disks, one copying an existing disk and the other creates a new VHDX. Now if I want to do nested virtualization I need to add a few other items to the config of the VM as below, (Nested requires at least 4 GB of RAM and can’t use Dynamic Memory) Within the DSC module we can define what features to install as well other configuration options, first we will need to import the modules for the DSC resources if they aren’t default ones. Then we can configure which items to install as well as how to configure them depending on the options in the DSC Module, below we set the options to add the AD Role components And here we configure the new Domain name and default Admin password using the xActiveDirectory DSC module available in the PowerShell Gallery Once these pieces are setup, we only need to do an import-module for the labuilder functions and kick off the install be calling Install-Lab and providing the path to the base XML file with our configuration. If things don’t work out there is also uninstall-lab function to remove everything. There are several sample files with the LabBuilder scripts so you can build out as simple as a single standalone server, up to a complex domain with multiple servers with various roles. This just goes to show there are many ways available to us today to build out an environment, whether it is to test out new functionality, learn about new things, or setup a demo to show someone how to do something. The great thing about these options is we don’t have to have a complex pre-built environment anymore. We can start with a script that defines what we want and an ISO or two to build out what we need. In addition to the ways Jaromir and I have taken there are others that may be more suitable for particular needs. For example, there is Automated Lab available here http://automatedlab.codeplex.com/ that can be used to build out environments including SQL or Exchange, or the PowerShell Deployment Toolkit to build environments that need various System Center components and that can be found here https://gallery.technet.microsoft.com/PowerShell-Deployment-f20bb605 So take a look at what’s out there, find what works for you, and if you find that something does almost what you need, most of these examples are out there in the community and can be modified and with your feedback changes can be added to make it even better. Keep in mind all of these are works in progress, so the developers can and will update and change them over time, so be sure to check the latest documentation with each of them to get the most out of them. Lazy/Simple Guy Jaromir@msft And Matthew “But I like XML” Walker
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.