Cookbooks
iis
documentation
Iis Vdir

back to resource list (opens in a new tab)


iis_vdir

Allows easy management of IIS virtual directories (i.e. vdirs).

Actions

  • :add - add a new virtual directory
  • :delete - delete an existing virtual directory
  • :config - configure a virtual directory

Properties

NameTypeDefaultDescriptionAllowed Values
application_nameStringname property. This is the name of the website or site + application you are adding it to.
pathStringThe virtual directory path on the site.
physical_pathStringThe physical path of the virtual directory on the disk.
usernameStringThe username required to logon to the physical_path. If set to "" will clear username and password.
passwordStringThe password required to logon to the physical_path.
logon_methodSymbol, String:ClearTextThe method used to logon. For more information on these types, see LogonUser Function (opens in a new tab):Interactive, :Batch, :Network, :ClearText
allow_sub_dir_configtrue, falsetrueBoolean that specifies whether or not the Web server will look for configuration files located in the subdirectories of this virtual directory. Setting this to false can improve performance on servers with very large numbers of web.config files, but doing so prevents IIS configuration from being read in subdirectories.

Examples

# add a virtual directory to default application
iis_vdir 'Default Web Site/' do
  action :add
  path '/Content/Test'
  physical_path 'C:\wwwroot\shared\test'
end
# add a virtual directory to an application under a site
iis_vdir 'Default Web Site/my application' do
  action :add
  path '/Content/Test'
  physical_path 'C:\wwwroot\shared\test'
end
# adds a virtual directory to default application which points to a smb share. (Remember to escape the "\"'s)
iis_vdir 'Default Web Site/' do
  action :add
  path '/Content/Test'
  physical_path '\\\\sharename\\sharefolder\\1'
end
# configure a virtual directory to have a username and password
iis_vdir 'Default Web Site/' do
  action :config
  path '/Content/Test'
  username 'domain\myspecialuser'
  password 'myspecialpassword'
end
# delete a virtual directory from the default application
iis_vdir 'Default Web Site/' do
  action :delete
  path '/Content/Test'
end