# salt.modules.win_iis

Microsoft IIS site management via WebAdministration powershell module

maintainer:

  Shane Lee <slee@saltstack.com>, Robert Booth <rbooth@saltstack.com>

platform:

  Windows

depends:

  PowerShell

depends:

  WebAdministration module (PowerShell) (IIS)

Added in version 2016.3.0.

salt.modules.win_iis.create_app(name, site, sourcepath, apppool=None)

  Create an IIS application.

  Note

  This function only validates against the application name, and will return True even if the application already exists with a different configuration. It will not modify the configuration of an existing application.

  Parameters:

    - name (str) -- The IIS application.

    - site (str) -- The IIS site name.

    - sourcepath (str) -- The physical path.

    - apppool (`str`, optional) -- The name of the IIS application pool. Default is `None`.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_app name='app0' site='site0' sourcepath='C:\site0' apppool='site0'

salt.modules.win_iis.create_apppool(name)

  Create an IIS application pool.

  Note

  This function only validates against the application pool name, and will return True even if the application pool already exists with a different configuration. It will not modify the configuration of an existing application pool.

  Parameters:

    name (str) -- The name of the IIS application pool.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_apppool name='MyTestPool'

salt.modules.win_iis.create_backup(name)

  Backup an IIS Configuration on the System.

  Added in version 2017.7.0.

  Note

  Backups are stored in the `$env:Windir\System32\inetsrv\backup` folder.

  Parameters:

    name (str) -- The name to give the backup

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_backup good_config_20170209

salt.modules.win_iis.create_binding(site, hostheader='', ipaddress='*', port=80, protocol='http', sslflags=None)

  Create an IIS Web Binding.

  Note

  This function only validates against the binding ipaddress:port:hostheader combination, and will return True even if the binding already exists with a different configuration. It will not modify the configuration of an existing binding.

  Parameters:

    - site (str) -- The IIS site name.

    - hostheader (`str`, optional) -- The host header of the binding. Usually a hostname. Default is ""

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is "*"

    - port (`int`, optional) -- The TCP port of the binding. Default is 80

    - protocol (`str`, optional) -- The application protocol of the binding. Default is "http

    - sslflags (`str`, optional) -- The flags representing certificate type and storage of the binding. Default is `None`.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_binding site='site0' hostheader='example.com' ipaddress='*' port='80'

salt.modules.win_iis.create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslflags=0)

  Assign a certificate to an IIS Web Binding.

  Added in version 2016.11.0.

  Note

  The web binding that the certificate is being assigned to must already exist.

  Parameters:

    - name (str) -- The thumbprint of the certificate.

    - site (str) -- The IIS site name.

    - hostheader (`str`, optional) -- The host header of the binding. Default is ""

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is "*"

    - port (`int`, optional) -- The TCP port of the binding. Default is 443

    - sslflags (`int`, optional) -- Flags representing certificate type and certificate storage of the binding. Default is 0

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_cert_binding name='AAA000' site='site0' hostheader='example.com' ipaddress='*' port='443'

salt.modules.win_iis.create_site(name, sourcepath, apppool='', hostheader='', ipaddress='*', port=80, protocol='http')

  Create a basic website in IIS.

  Note

  This function only validates against the site name, and will return True even if the site already exists with a different configuration. It will not modify the configuration of an existing site.

  Parameters:

    - name (str) -- The IIS site name.

    - sourcepath (str) -- The physical path of the IIS site.

    - apppool (`str`, optional) -- The name of the IIS application pool. Default is ""

    - hostheader (`str`, optional) -- The host header of the binding. Usually the hostname or website name, ie: www.contoso.com Default is ""

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is "*"

    - port (`int`, optional) -- The TCP port of the binding. Default is 80

    - protocol (`str`, optional) -- The application protocol of the binding. (http, https, etc.) Default is "http"

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  Note

  If an application pool is specified, and that application pool does not already exist, it will be created.

  CLI Example:

      salt '*' win_iis.create_site name='My Test Site' sourcepath='c:\stage' apppool='TestPool'

salt.modules.win_iis.create_vdir(name, site, sourcepath, app='/')

  Create an IIS virtual directory.

  Note

  This function only validates against the virtual directory name, and will return True even if the virtual directory already exists with a different configuration. It will not modify the configuration of an existing virtual directory.

  Parameters:

    - name (str) -- The virtual directory name.

    - site (str) -- The IIS site name.

    - sourcepath (str) -- The physical path.

    - app (`str`, optional) -- The IIS application. Default is _DEFAULT_APP ("/")

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.create_vdir name='vd0' site='site0' sourcepath='C:\inetpub\vdirs\vd0'

salt.modules.win_iis.get_container_setting(name, container, settings)

  Get the value of the setting for the IIS container.

  Added in version 2016.11.0.

  Parameters:

    - name (str) -- The name of the IIS container.

    - container (str) -- The type of IIS container. The container types are: AppPools, Sites, SslBindings

    - settings (dict) -- A dictionary of the setting names and their values.

  Returns:

    A dictionary of the provided settings and their values.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.get_container_setting name='MyTestPool' container='AppPools'
          settings="['processModel.identityType']"

salt.modules.win_iis.get_webapp_settings(name, site, settings)

  Added in version 2017.7.0.

  Get the value of the setting for the IIS web application.

  Note

  Params are case sensitive

  Parameters:

    - name (str) -- The name of the IIS web application.

    - site (site) -- The site name contains the web application. Example: Default Web Site

    - settings (str) --

      A dictionary of the setting names and their values. Available settings:

      - physicalPath

      - applicationPool

      - userName

      - password

  Returns:

    A dictionary of the provided settings and their values.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.get_webapp_settings name='app0' site='Default Web Site'
          settings='["physicalPath","applicationPool"]'

salt.modules.win_iis.get_webconfiguration_settings(name, settings)

  Get the webconfiguration settings for the IIS PSPath.

  Parameters:

    - name (str) -- The PSPath of the IIS webconfiguration settings.

    - settings (list) -- A list of dictionaries containing setting name and filter.

  Returns:

    A list of dictionaries containing setting name, filter and value.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.get_webconfiguration_settings name='IIS:\' settings='[{"name": "enabled", "filter": "system.webServer/security/authentication/anonymousAuthentication"}]'

salt.modules.win_iis.list_apppools()

  List all configured IIS application pools.

  Returns:

    A dictionary of IIS application pools and their details.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_apppools

salt.modules.win_iis.list_apps(site)

  Get all configured IIS applications for the specified site.

  Parameters:

    site (str) -- The IIS site name.

  Returns: A dictionary of the application names and properties.

  CLI Example:

      salt '*' win_iis.list_apps site

salt.modules.win_iis.list_backups()

  List the IIS Configuration Backups on the System.

  Added in version 2017.7.0.

  Note

  Backups are made when a configuration is edited. Manual backups are stored in the `$env:Windir\System32\inetsrv\backup` folder.

  Returns:

    A dictionary of IIS Configurations backed up on the system.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_backups

salt.modules.win_iis.list_bindings(site)

  Get all configured IIS bindings for the specified site.

  Parameters:

    site (str) -- The name if the IIS Site

  Returns:

    A dictionary of the binding names and properties.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_bindings site

salt.modules.win_iis.list_cert_bindings(site)

  List certificate bindings for an IIS site.

  Added in version 2016.11.0.

  Parameters:

    site (str) -- The IIS site name.

  Returns:

    A dictionary of the binding names and properties.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_bindings site

salt.modules.win_iis.list_sites()

  List all the currently deployed websites.

  Returns:

    A dictionary of the IIS sites and their properties.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_sites

salt.modules.win_iis.list_vdirs(site, app='/')

  Get all configured IIS virtual directories for the specified site, or for the combination of site and application.

  Parameters:

    - site (str) -- The IIS site name.

    - app (str) -- The IIS application.

  Returns:

    A dictionary of the virtual directory names and properties.

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_vdirs site

salt.modules.win_iis.list_worker_processes(apppool)

  Returns a list of worker processes that correspond to the passed application pool.

  Added in version 2017.7.0.

  Parameters:

    apppool (str) -- The application pool to query

  Returns:

    A dictionary of worker processes with their process IDs

  Return type:

    dict

  CLI Example:

      salt '*' win_iis.list_worker_processes 'My App Pool'

salt.modules.win_iis.modify_binding(site, binding, hostheader=None, ipaddress=None, port=None, sslflags=None)

  Modify an IIS Web Binding. Use `site` and `binding` to target the binding.

  Added in version 2017.7.0.

  Parameters:

    - site (str) -- The IIS site name.

    - binding (str) -- The binding to edit. This is a combination of the IP address, port, and hostheader. It is in the following format: ipaddress:port:hostheader. For example, `*:80:` or `*:80:salt.com`

    - hostheader (`str`, optional) -- The host header of the binding. Usually the hostname. Default is `None`.

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is `None`.

    - port (`int`, optional) -- The TCP port of the binding. Default is `None`.

    - sslflags (`str`, optional) -- The flags representing certificate type and storage of the binding. Default is `None`.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

  The following will seat the host header of binding `*:80:` for `site0` to `example.com`

      salt '*' win_iis.modify_binding site='site0' binding='*:80:' hostheader='example.com'

salt.modules.win_iis.modify_site(name, sourcepath=None, apppool=None)

  Modify a basic website in IIS.

  Added in version 2017.7.0.

  Parameters:

    - name (str) -- The IIS site name.

    - sourcepath (`str`, optional) -- The physical path of the IIS site. Default is `None`.

    - apppool (`str`, optional) -- The name of the IIS application pool. Default is `None`.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  Note

  If an application pool is specified, and that application pool does not already exist, it will be created.

  CLI Example:

      salt '*' win_iis.modify_site name='My Test Site' sourcepath='c:\new_path' apppool='NewTestPool'

salt.modules.win_iis.remove_app(name, site)

  Remove an IIS application.

  Parameters:

    - name (str) -- The application name.

    - site (str) -- The IIS site name.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_app name='app0' site='site0'

salt.modules.win_iis.remove_apppool(name)

  Remove an IIS application pool.

  Parameters:

    name (str) -- The name of the IIS application pool.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_apppool name='MyTestPool'

salt.modules.win_iis.remove_backup(name)

  Remove an IIS Configuration backup from the System.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the backup to remove

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_backup backup_20170209

salt.modules.win_iis.remove_binding(site, hostheader='', ipaddress='*', port=80)

  Remove an IIS binding.

  Parameters:

    - site (str) -- The IIS site name.

    - hostheader (`str`, optional) -- The host header of the binding. Default is "".

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is "*"

    - port (`int`, optional) -- The TCP port of the binding. Default is 80

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_binding site='site0' hostheader='example.com' ipaddress='*' port='80'

salt.modules.win_iis.remove_cert_binding(name, site, hostheader='', ipaddress='*', port=443)

  Remove a certificate from an IIS Web Binding.

  Added in version 2016.11.0.

  Note

  This function only removes the certificate from the web binding. It does not remove the web binding itself.

  Parameters:

    - name (str) -- The thumbprint of the certificate.

    - site (str) -- The IIS site name.

    - hostheader (`str`, optional) -- The host header of the binding. Default is ""

    - ipaddress (`str`, optional) -- The IP address of the binding. Default is "*"

    - port (`int`, optional) -- The TCP port of the binding. Default is 443

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_cert_binding name='AAA000' site='site0' hostheader='example.com' ipaddress='*' port='443'

salt.modules.win_iis.remove_site(name)

  Delete a website from IIS.

  Parameters:

    name (str) -- The IIS site name.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  Note

  This will not remove the application pool used by the site.

  CLI Example:

      salt '*' win_iis.remove_site name='My Test Site'

salt.modules.win_iis.remove_vdir(name, site, app='/')

  Remove an IIS virtual directory.

  Parameters:

    - name (str) -- The virtual directory name.

    - site (str) -- The IIS site name.

    - app (`str`, optional) -- The IIS application. Default is _DEFAULT_APP ("/")

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.remove_vdir name='vdir0' site='site0'

salt.modules.win_iis.restart_apppool(name)

  Restart an IIS application pool.

  Added in version 2016.11.0.

  Parameters:

    name (str) -- The name of the IIS application pool.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.restart_apppool name='MyTestPool'

salt.modules.win_iis.restart_site(name)

  Restart a Web Site in IIS.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the website to restart.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.restart_site name='My Test Site'

salt.modules.win_iis.set_container_setting(name, container, settings)

  Set the value of the setting for an IIS container.

  Added in version 2016.11.0.

  Parameters:

    - name (str) -- The name of the IIS container.

    - container (str) -- The type of IIS container. The container types are: AppPools, Sites, SslBindings

    - settings (dict) -- A dictionary of the setting names and their values.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.set_container_setting name='MyTestPool' container='AppPools'
          settings="{'managedPipeLineMode': 'Integrated'}"

salt.modules.win_iis.set_webapp_settings(name, site, settings)

  Added in version 2017.7.0.

  Configure an IIS application.

  Note

  This function only configures an existing app. Params are case-sensitive.

  Parameters:

    - name (str) -- The IIS application.

    - site (str) -- The IIS site name.

    - settings (str) --

      A dictionary of the setting names and their values.

      - physicalPath: The physical path of the webapp.

      - applicationPool: The application pool for the webapp.

      - userName: "connectAs" user

      - password: "connectAs" password for user

  Returns:

    A boolean representing whether all changes succeeded.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.set_webapp_settings name='app0' site='site0' settings='{"physicalPath": "C:\site0", "apppool": "site0"}'

salt.modules.win_iis.set_webconfiguration_settings(name, settings)

  Set the value of the setting for an IIS container.

  Parameters:

    - name (str) -- The PSPath of the IIS webconfiguration settings.

    - settings (list) -- A list of dictionaries containing setting name, filter and value.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.set_webconfiguration_settings name='IIS:\' settings='[{"name": "enabled", "filter": "system.webServer/security/authentication/anonymousAuthentication", "value": False}]'

salt.modules.win_iis.start_apppool(name)

  Start an IIS application pool.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the App Pool to start.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.start_apppool name='MyTestPool'

salt.modules.win_iis.start_site(name)

  Start a Web Site in IIS.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the website to start.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.start_site name='My Test Site'

salt.modules.win_iis.stop_apppool(name)

  Stop an IIS application pool.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the App Pool to stop.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.stop_apppool name='MyTestPool'

salt.modules.win_iis.stop_site(name)

  Stop a Web Site in IIS.

  Added in version 2017.7.0.

  Parameters:

    name (str) -- The name of the website to stop.

  Returns:

    `True` if successful, otherwise `False`.

  Return type:

    bool

  CLI Example:

      salt '*' win_iis.stop_site name='My Test Site'