Cookbooks
iis
documentation
Iis Site

back to resource list (opens in a new tab)


iis_site

Allows for easy management of IIS virtual sites.

Actions

  • :add - add a new virtual site
  • :config - apply configuration to an existing virtual site
  • :delete - delete an existing virtual site
  • :start - start a virtual site
  • :stop - stop a virtual site
  • :restart - restart a virtual site

Properties

NameTypeDefaultDescriptionAllowed Values
site_nameStringname property. Specify the name of the site
site_idIntegerif not given IIS generates a unique ID for the site
pathStringIIS will create a root application and a root virtual directory mapped to this specified local pathq
protocolSymbol, StringProtocol type the site should respond.:http, :https, :ftp
portInteger80port site will listen on.
host_headerStringhost header (also known as domains or host names) the site should map to.
bindingsStringAdvanced options to configure the information required for requests to communicate with a Web site. See iis bindings (opens in a new tab) for parameter format. When binding is used, port protocol and host_header should not be used..
application_poolStringset the application pool of the site.
optionsStringadditional options to configure the site. Such as "-logDir", "-limits", "-ftpServer", "-applicationDefaults.preloadEnabled:True". This can be anything that you would normally add to a appcmd. This only runs during add since it isn't idempotent
log_directoryStringspecifies the logging directory, where the log file and logging-related support files are stored.
log_periodSymbol, String:Dailyspecifies how often iis creates a new log file.:Daily, :Hourly, :MaxSize, :Monthly, :Weekly
log_truncsizeInteger1048576specifies the maximum size of the log file (in bytes) after which to create a new log file.

Examples

# stop and delete the default site
iis_site 'Default Web Site' do
  action [:stop, :delete]
end
# create and start a new site that maps to
# the physical location C:\inetpub\wwwroot\testfu
# first the physical location must exist
directory "#{node['iis']['docroot']}/testfu" do
  action :create
end
 
# now create and start the site (note this will use the default application pool which must exist)
iis_site 'Testfu Site' do
  protocol :http
  port 80
  path "#{node['iis']['docroot']}/testfu"
  action [:add,:start]
end
# do the same but map to testfu.chef.io domain
# first the physical location must exist
directory "#{node['iis']['docroot']}/testfu" do
  action :create
end
 
# now create and start the site (note this will use the default application pool which must exist)
iis_site 'Testfu Site' do
  protocol :http
  port 80
  path "#{node['iis']['docroot']}/testfu"
  host_header "testfu.chef.io"
  action [:add,:start]
end
# create and start a new site that maps to
# the physical C:\inetpub\wwwroot\testfu
# first the physical location must exist
directory "#{node['iis']['docroot']}/testfu" do
  action :create
end
 
# also adds bindings to http and https
# binding http to the ip address 10.12.0.136,
# the port 80, and the host header www.domain.com
# also binding https to any ip address,
# the port 443, and the host header www.domain.com
# now create and start the site (note this will use the default application pool which must exist)
iis_site 'FooBar Site' do
  bindings "http/10.12.0.136:80:www.domain.com,https/*:443:www.domain.com"
  path "#{node['iis']['docroot']}/testfu"
  action [:add,:start]
end
# create a site with preloadEnabled enabled
iis_site 'mysite.com' do
  protocol :http
  port 80
  path "#{node['iis']['docroot']}\dataverify"
  application_pool 'dataverify.com'
  options "-applicationDefaults.preloadEnabled:True"
  action [:add, :start, :config]
end