How to Deploy IIS and ASP.NET with the Puppet Module


Puppet is a great module for automating Windows effectively. It can automate almost anything, including Chocolatey, Azure virtual machines and file system ACLs.

You have to define a set of rules for your server environment. In every 30 minutes, Puppet will check if the rules have been followed and the attempts for making unwanted changes. In this article, you will find the way of deploying IIS and ASP.NET with the Puppet module. Now, let’s dive in.

Deploying IIS and ASP.NET with the Puppet Module

1. At first, you have to define a set of rules. Then, you will have to apply it to the windows server. You can do it by using the following codes:

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',
}
}

Here, you are enabling .NET Framework 4.5 with the Windows Feature module. You are also turning on the IIS, along with HTTP error and logging. To remove the default binding, you are removing default website with the voxopopuli IIS module.

2. Puppet provides you with a report about different events and logs. It looks like this:

How to Deploy IIS and ASP.NET with the Puppet Module

Here, Puppet is showing that it has managed to set up a basic application by executing the required commands. It also reveals that the IIS Management tools have been successfully installed. To remove the default website, it has executed Powershell codes.

3. Now, you have to install SQL Server Compact Edition. Just use these codes:

classwindemo::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
    }
}

4. Next, you have to install a bare application, like Razor C, that utilizes the SQL server, which you have just installed.

# == Class: mvcapp
#
# This class installs the razorC MVC application
#
classwindemo::mvcapp {
    $app_zip = 'razorC_v1.1.1.zip'
    $app_zip_path = "C: WindowsTemp${app_zip}"
    $app_pool - 'mvc'
    $app_location = 'C:inetpubwwwrootrazorC'
    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 => '*',

Here, you are telling Puppet to copy a zip file, which contains the full distribution of the app. You are also commanding it to extract the compressed file to c:inetpubwwwroot, which is the default path for ASP.NET applications. In addition, the application pool has been created, along with a site mapped to Port 80.

5. Now, you can view the deployed ASP.NET app with your favorite browser. It looks like this:

How to Deploy IIS and ASP.NET with the Puppet Module

Conclusion

In this article, you have learned to deploy IIS and ASP.NET with the Puppet module. You have also learned to configure Windows to run IIS. Finally, you have gone through the process of installing a CMS application, which is one of the simplest things that you can do with Puppet.

There are tons of things that you can do with the module on the Windows server. Keep in touch with us to know them.

Check out these top 3 Windows hosting services:

Was this article helpful?