Day 20: Enabling Highly Standardized Web Farm Configuration with PowerShell DSC (Part 1)

Welcome to Day 20 of the “100 Days of DevOps with PowerShell”! For background on our goals in this series, see Announcing the “100 Days of Devops with PowerShell” Series here at SCC. If this is the first time you are viewing an article of the series and you are new to DevOps and PowerShell DSC, I encourage you to read through the previous installments, particularly Day 1.

One of the core tenants of DevOps is highly standardized configuration. In the world of PowerShell DSC, the xWebAdministration module delivers on this goal in a big way. This module enables more than just enabling web-related features. With the xWebAdministration module, you can even configure the site itself, even distribute the site content.

Perhaps the best part of this module is that MS has embedded a gem in the form of a very robust sample web application configuration that makes it very simple for you to test an advanced scenario. You can then easily adapt this sample to your environment for maintaining application configurations hosted on your enterprise web farms.

In this example, I have two servers:

  • Server1.contoso.com – My DSC Pull Server
  • Server2.contoso.com – Managed Node

In this post, we’ll have a look at the how-to for deployment to one server, then in my next installment, we’ll build on this and apply the configuration to an entire web farm.

Download the xWebAdministration Module

Start by downloading the xWebAdministration DSC module from http://gallery.technet.microsoft.com/scriptcenter/xWebAdministration-Module-3c8bb6be.

TIP: In the xWebAdministration directory created by extracting the contents of the zip file download, find the TechNetDocumentation-xWebAdministration.docx file, which contains everything you need to implement the sample .NET website, Fouth Coffee Bakery.

Create a Configuration for a Node

First, you will create a configuration for server2. This sample configuration performs several configuration steps on the target node (which you can see in script comments):

  • Install the IIS role
  • Install ASP.NET 4.5
  • Stop the default web site
  • Copies in the FourthCoffee website content
  • Creates and starts a new website containing FourthCoffee content

However, you will run this configuration script from the pull server (server1 in this example).

IMPORTANT: Be sure you extract the contents of xWebAdministration\Examples\BakeryWebsite.zip and place it in the folder shown in the code snippet below (C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\BakeryWebsite). Share that directory as BakeryWebsite (so it will be accessible remotely by nodes via \\Server1\BakeryWebsite)

The snippet below generates a guid (the DSC configuration ID) for server2.contoso.com and copies the server2.contoso.com.mof file to the appropriate directory on the DSC Pull Server as <guid>.mof.

With the mof in place, you now need to generate a checksum file (for the server2.contoso.com.mof file ) on the pull server. When computers attempt to pull their configuration, they use the checksum to ensure the integrity of the mof file. You create the checksum file in the same PowerShell session with the one-liner:

The checksum file should appear in the same folder as the mof file, as shown below. The file as the same name as the MOF, but with a .checksum on the end.

Configure Pull Mode on Node 

This snippet is going to set or update the local configuration on server2.contoso.com.

NOTE: Add or remove the “s” based on whether you configured your pull server to use http or https.

Force Node to Evaluate Configuration

Run this snippet on the managed node (server2.contoso.com) to force the node to evaluate its configuration and retrieve and apply its configuration mof file.

The server should download it’s new configuration mof, read its contents and perform the following steps:

  • Install the IIS role
  • Install ASP.NET 4.5
  • Stop the default web site
  • Copies in the FourthCoffee website content
  • Creates and starts a new website containing FourthCoffee content

True to PowerShell DSC functionality, all nodes you configure to retrieve this file will re-apply the configuration every few minutes in accordance to the intervals you configured enabling highly standardized server configuration.

Conclusion and Next Steps

That’s all for this installment. I hope you’re beginning to get a sense at the comprehensive scenarios that can be implemented with PowerShell DSC. In my next installment, we’ll expand on this example by walking through how to apply this configuration to an entire farm.

Previous Installments

To see the previous installments in this series, visit “100 Days of DevOps with PowerShell”.

2 thoughts on “Day 20: Enabling Highly Standardized Web Farm Configuration with PowerShell DSC (Part 1)

  1. Pingback: Create a SharePoint 2013 DEV environment the right way | Wouter Spaans

  2. Profile photo of NicolasNicolas

    Hello,

    I’m trying to follow the Topic and I found a problem, I think the solution is elsewhere but it appears that some pages return a 404.

    When I Invoke-CimMethod it tells me that Module canno’t be found. My question is how can I export Modules or I’ll have to make a template with all modules I need.

     

    Thanks for your help, I’m starting with DSC.

    Nicolas

Leave a Reply