Deploying IIS and ASP.NET With Puppet

DZone 's Guide to

Deploying IIS and ASP.NET With Puppet

In this post, Ethan Brown will explore automating two common Windows tasks with Puppet Enterprise: deploying ASP.NET and IIS.

· DevOps Zone ·
Free Resource

Editor’s note: This is one in a series of posts about using Puppet to automate your Windows servers. Follow us on social media or subscribe to our RSS feed to be notified when the next post is released.

Puppet has deep support for Windows Server systems. Puppet can automate it all, including file system ACLs, registry settings, users and groups, DSC, Chocolatey, WSUS client, PowerShell and even Azure virtual machines. In this post, we’ll explore automating two common Windows tasks with Puppet Enterprise: deploying ASP.NET and IIS.

With Puppet you write a manifest, or set of rules, for your server environments. Puppet checks in with a centralized master every 30 minutes to see if there have been any undesired changes on agent systems, and attempts to apply newly desired configuration or remediate undesirable configuration changes. Setting up IIS and ASP.NET with Puppet is no different. First, we’ll write a basic manifest that defines what we want and then we’ll apply it to our Windows servers.

This is what the code looks like:

class widemo::iis_enable {

    Include windemo::dotnet_enable

        feature_name => [
installmanagementtools => true, 
} ~>

# Remove default binding by removing default website
# (so it can be used by something else)
Iis::manage_site {‘Default Web Site’:
    ensure => absent,
site_path => ‘any’,
    app_pool => ‘DefaultAppPool’,

We’re using our Windows Feature Module to enable .NET Framework 4.5. We’re also enabling IIS, and turning on HTTP errors and logging. Finally, we’re using the community provided voxpopuli IIS module to remove the default binding.

Puppet runs and generates a report to let us know what happened. In our case, the report shows that a number of things were changed.

Puppet Enterprise report

From the report we see that Puppet executed the commands necessary to se tup a basic web application. In addition, the IIS Management tools are installed and our Puppet module executed some PowerShell code to remove the default web site as desired.

With the following code, Puppet can also install SQL Server Compact Edition, which our demo ASP.NET application requires.

class windemo::sqlce {

    $installer = ‘SSCERuntime_x64-ENU.exe’

    package { ‘Microsoft SQL Server Compact 4.0 SP1 x64 ENU’:
        ensure => ‘4.0.8876.1’,
        provider => ‘windows’,
        # NOTE: would like to use this Puppet style, but must have file
        # source => “puppet:///modules/widemo/${installer}”,
        source => “C:/vagrant/modules/windemo/files/${installer]”,
        Install_options => [  ‘/1’,  ‘/passive’ ] # [ ‘/qn’ ] #/l*v install

Now, let’s use Puppet to install a bare-bones application that uses SQL Server installed in the previous step. In this case, it’s Razor C, which is an ASP.NET-based CMS. Here’s what the Puppet code looks like for installing Razor C:

# == Class: mvcapp
# This class installs the razorC MVC application
class windemo::mvcapp {

    $app_zip = ‘razorC_v1.1.1.zip’
    $app_zip_path = “C: \\Windows\\Temp\\${app_zip}”
    $app_pool - ‘mvc’
    $app_location = ‘C:\inetpub\wwwroot\razorC’

    file { “${app_zip_path}”:
        ensure => file,
        source => “puppet:///modules/windemo/${app_zip}”,
        source_permissions => ignore,
    } ~>

    iis::manage_app_pool {“$app_pool”:
ensure => present,
enable_32_bit => true,
managed_runtime_version => ‘v4.0’,
managed_pipeline_mode => ‘Integrated’,
} ~>

#NOTE: IIS is very touchy around extra slashes

Iis::manage_site {‘razorC’:
ensure => present,
site_path => “${app_location},
port => ‘80’,
Ip_address => ‘*’,

We pointed Puppet to a zip file, containing the full distribution of the application. Puppet will copy the zip file from our module, stage it in a temporary directory and extract it to the default location for ASP.NET applications on disk at c:\inetpub\wwwroot. We have also created an application pool and a site mapped to Port 80, pointing to the location on disk where the Razor C application has been extracted.

With just a short bit of manifest code, we have configured Windows to run IIS and have installed a CMS application.

Viewing this within a browser, we see the deployed application:

ASP.NET site deployed with Puppet Enterprise

That’s just one of hundreds of things you can do with Puppet in a Windows server. In our next piece, we’ll explore how we can manage PowerShell DSC with Puppet. Stay tuned!

asp.net ,devops ,iis ,puppet

Published at DZone with permission of Ethan Brown . See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}