Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Windows Configuration Management: Packages, Services, and PowerShell

DZone's Guide to

Windows Configuration Management: Packages, Services, and PowerShell

Automating Windows-based server deployments can be a hassle. Let's look at how to manage the packages and services needed for deployment by making use of Puppet.

· DevOps Zone ·
Free Resource

Discover how you can reduce your Kubernetes installation from 22 steps to 1.

Installing software and managing services across multiple Windows machines can be a nightmare — if done manually. Puppet can automatically install and update Windows software and ensure services are configured correctly across multiple machines in your infrastructure.

Installing Software

There are two ways to automatically install Windows applications using Puppet. You can run a simple install through Puppet or have Puppet use Chocolatey, a highly customizable Windows installation tool. In this example, we’ll have Puppet install some software using Chocolatey.

The process is simple and can be done through the Puppet dashboard, an easy-to-learn GUI. In this example, we’ve already set up a group of Windows servers with Puppet agents installed, and we've installed and configured Chocolatey (check out our post here to learn all about Puppet and Chocolatey). First, launch Puppet and create a group for your Windows servers. Groups define the requirements for server membership, and in this instance, we’ll choose Windows machines. Next, we'll use some facts to filter out the machines we don't need. I'll use osfamily = windows in order to make sure all of my Windows nodes receive the classification that I'm going to apply.

Once we’ve selected the type of machines we’ll be addressing, we can apply a class to them that will tell Puppet to run the software installation. We’re using the Chocolatey class, which defines our software installation. Once we apply that class to the machines in our group, we can trigger a Puppet run and our software will be installed silently in the background.

With Windows, you usually run a simple command from PowerShell or the command line when you're trying to apply these package changes. Puppet, however, lets you specify and bundle all the packages that you would like to see in your Windows system. In this case, we're actually going to be managing Notepad++, Firefox, Google Chrome, and a plugin.

Let’s look at the Puppet code behind the Chocolatey class to see how it works:

class tse_windows::choco {
    package { ‘notepadplusplus’:
        ensure => latest,
        provider => ‘chocolatey’,
    }

    package { ‘firefox’:
        ensure => latest,
        provider => ‘chocolatey’,
    }

    package { ‘flashplayerplugin’:
        ensure => latest,
        provider => ‘chocolatey’,
    }

    package { ‘googlechrome’:
        ensure => latest,
        provider => ‘chocolatey’,
 }
}

The Puppet code specifies the Chocolatey package. If you need to change any of it, you only do it once in Puppet, and the changes will be applied across your entire infrastructure when Puppet runs.

Managing Services

Monitoring and managing services can be tedious in a large Windows environment. With Puppet, you can interrogate systems to see how resources are being used and managed. In this example, we’ll examine the automatic update service, called wuauserv in Puppet.

Currently, the service is stopped, but that can easily be changed in the Puppet code. It’s just a simple matter of changing the enabled parameter to true.

service { ‘wuauserv’:
    ensure => ‘running’,
enable => ‘false’,
}

service { ‘wuauserv’:
    ensure => ‘running’,
enable => ‘true’,
}

When we run Puppet, the change will be made on one machine in our group. The number of machines doesn’t matter — the same code can be used to update 1,000 machines or more.

WSUS and Puppet

Puppet can easily manage patching and hot fixes in a Windows environment. This diagram shows how you can use Puppet to move a patch from development to testing to production.

WSUS and Puppet

This is the sample code:

class { 
“wsus_client’: 
server_url          => “http://myserver:8530’,
auto_update_option      => “Scheduled”,
scheduled_install_day   => “Tuesday”,
    scheduled_install_hour      => 2,
}

This way, you can schedule the install date and the time to avoid interruptions or disruptions to the flow of your business.

Download the Kubernetes cheatsheet to learn more about easy it is to run Kubernetes on any infrastructure with Mesosphere DC/OS

Topics:
chocolatey ,puppet ,windows ,devops ,server deployments

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}