DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Frameworks
  4. Deploying IIS and ASP.NET With Puppet

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.

Ethan Brown user avatar by
Ethan Brown
·
Oct. 01, 16 · Tutorial
Like (2)
Save
Tweet
Share
5.81K Views

Join the DZone community and get the full member experience.

Join For Free

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

    Windowsfeature{‘IIS_NET45’:
        feature_name => [
            ‘Web-WebServer’,
            ‘Web-Http-Errors’,
            ‘Web-Http-Logging’,
‘Web-Asp-Net45’,
‘NET-Framework-45-ASPNET’,
],
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 application File system

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Front-End Troubleshooting Using OpenTelemetry
  • Key Elements of Site Reliability Engineering (SRE)
  • HTTP vs Messaging for Microservices Communications
  • Custom Validators in Quarkus

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: