Using the Chef IIS cookbook to build a site/appPool

Because the documentation is sparse, figured I'd post these up.  Spent way more time & trial/error than I should have had to!!  (I was going to post these weeks ago, but didn't get it working until the kindly devs at opscode resolved the bugs.  Note that the fix hasn't actually been published yet, but all this works with the repo linked from here: https://github.com/opscode-cookbooks/iis/issues/77 )

Create the directory:
directory "C:\\Web\\Data\\#{cookbook_name}" do
  action :create
  recursive true
  rights :full_control, "Administrators", :applies_to_children => true
  rights :full_control, "domain\\username", :applies_to_children => true
  rights :full_control, "domain\\group name", :applies_to_children => true
  not_if { ::File.directory?("C:\\Web\\Data\\#{cookbook_name}") }
end

Create an appPool:
 iis_pool "#{cookbook_name}" do
     runtime_version "4.0"
     pipeline_mode :Integrated
     pool_username "domain\\username"
pool_password "password"
action [:add,:config]
 end

Recycle the appPool:
 iis_pool "#{cookbook_name}" do
    action :recycle
 end

Create a website:
 iis_site "#{cookbook_name}" do
path "c:\\web\\data\\#{cookbook_name}\\files"
site_name "#{cookbook_name}"
application_pool "#{cookbook_name}"
action [:add,:start]
 end

Configure the bindings:
 iis_site "#{cookbook_name}" do
bindings "http/*:80:www.domain.com"
action [:config,:restart]
 end

Note that you can do multiple bindings, just comma-separate inside those quotes.
e.g. bindings "http/*:80:www.domain.com,https/*:443:www.domain.com"

Comments

Popular posts from this blog

Learning through failure - a keyboard creation journey

Learning Opportunities - Watching/listening list

DFSR - eventid 4312 - replication just won't work