Downgrade mysql cookbook for now
It doesn't play well with our current dev server setup
This commit is contained in:
@@ -1 +1,2 @@
|
||||
~FC059
|
||||
~FC023
|
||||
@@ -2,38 +2,116 @@
|
||||
|
||||
This file is used to list changes made in each version of the iis cookbook.
|
||||
|
||||
## 6.7.1 (2017-06-09)
|
||||
- [Fix issue with guard clause missing on check](https://github.com/chef-cookbooks/iis/pull/378)
|
||||
|
||||
## 6.7.0 (2017-06-09)
|
||||
- [Fix idempotency in `iis_app`, `iis_root`, and `iis_vdir`](https://github.com/chef-cookbooks/iis/pull/375)
|
||||
|
||||
## 6.6.0 (2017-06-01)
|
||||
- Convert `iis_module` to a custom resource
|
||||
|
||||
## 6.5.3 (2017-05-17)
|
||||
- Refactor `iis_vdir` name property to `application_name`
|
||||
- Resolves a bug in iis_vdir also adds more liberty in config
|
||||
|
||||
## 6.5.2 (2017-05-15)
|
||||
- [Update iis_vdir name to not require a trailing /](https://github.com/chef-cookbooks/iis/pull/363)
|
||||
- [Fix iis_pool identity_type issue](https://github.com/chef-cookbooks/iis/pull/362)
|
||||
|
||||
## 6.5.1 (2017-05-12)
|
||||
- [iis_pool is not Idempotent](https://github.com/chef-cookbooks/iis/issues/354)
|
||||
- Fix whitespace in `iis_pool` name
|
||||
|
||||
## 6.5.0 (2017-05-10)
|
||||
- Convert `iis_root` to a custom resource
|
||||
- [uninitialized constant Chef::Resource::IisRoot](https://github.com/chef-cookbooks/iis/issues/333)
|
||||
- [mime types are not deleted](https://github.com/chef-cookbooks/iis/issues/321)
|
||||
- [iis_root errors on 'duplicate collection entry of type 'mimeMap'](https://github.com/chef-cookbooks/iis/issues/199)
|
||||
|
||||
## 6.4.1 (2017-05-05)
|
||||
- [fix bug with start having ! in front](https://github.com/chef-cookbooks/iis/pull/349)
|
||||
|
||||
## 6.4.0 (2017-05-04)
|
||||
- Convert `iis_section` to a custom resource
|
||||
- Resolve issue with `iis_pool`
|
||||
|
||||
## 6.3.1 (2017-04-26)
|
||||
|
||||
- [Fix multiple issues with ~FC023](https://github.com/chef-cookbooks/iis/pull/341)
|
||||
|
||||
## 6.3.0 (2017-04-24)
|
||||
|
||||
- Convert `iis_pool` to a custom resource
|
||||
- Convert `iis_vdir` to a custom resource
|
||||
- Bug fix for `log` function change to `Chef::Log`
|
||||
|
||||
## 6.2.0 (2017-04-18)
|
||||
|
||||
- Convert `iis_site` to a custom resource
|
||||
|
||||
## 6.1.0 (2017-04-14)
|
||||
|
||||
- Convert `iis_config` to a custom resource
|
||||
|
||||
## 6.0.1 (2017-04-07)
|
||||
|
||||
- Fix undefined method `site_identifier` with iis_app resource.
|
||||
|
||||
## 6.0.0 (2017-04-06)
|
||||
|
||||
- Rewrite of `iis_app` resource to use custom resources.
|
||||
- Addition of testing for `iis_app` resource.
|
||||
|
||||
## 5.1.0 (2017-03-20)
|
||||
|
||||
- Require at least windows 2.0 cookbook
|
||||
- Run integration testing in Appveyer
|
||||
- Switched testing to Inspec from pester/ServerSpec combo
|
||||
- Removed the empty iis_test cookbook
|
||||
|
||||
## 5.0.8 (2017-03-13)
|
||||
|
||||
- [iis-root default_documents broke from last fix](#306)
|
||||
|
||||
## 5.0.7 (2017-03-07)
|
||||
|
||||
- [iis-root default_documents deleted every chef run](#306)
|
||||
|
||||
## 5.0.6 (2017-02-24)
|
||||
|
||||
- [iis_version is not evaluated properly on if statement](#308)
|
||||
|
||||
## 5.0.5 (2016-11-21)
|
||||
|
||||
- [Fixed no_managed_code idempotency](#301)
|
||||
|
||||
## 5.0.4 (2016-10-11)
|
||||
|
||||
- fixed adding an app pool to a site - This fixes a bug where adding an app pool to a site causes an error. This was using the 'add app' where we are working with a site and the syntax is slightly different according to this [documentation](https://technet.microsoft.com/en-us/library/cc732992%28v=ws.10%29.aspx).
|
||||
|
||||
## 5.0.3 (2016-10-10)
|
||||
|
||||
- Log event on recycle - This allows you to specify which events you want to log on recycle. This also changes this so that it defaults to the standard nothing, which means you will need to add this attribute if you are depending on it.
|
||||
|
||||
## 5.0.2 (2016-10-07)
|
||||
|
||||
- [Minor over oversight in IIS::mod_aspnet 5.0.1](#296)
|
||||
- [IIS Pool resource thirty_two_bit false doesn't](#292)
|
||||
|
||||
## 5.0.1 (2016-09-21)
|
||||
|
||||
- Fix mod_management to include dependencies (#293)
|
||||
|
||||
## 5.0.0 (2016-09-06)
|
||||
|
||||
- Adding 2k12 version flag to the windows_feature resource (#291)
|
||||
- Testing updates
|
||||
- Avoid deprecation warnings in the specs
|
||||
- Require Chef 12+
|
||||
|
||||
## 4.2.0 (2016-08-09)
|
||||
|
||||
- Feature pool recycle virtual memory (#288)
|
||||
|
||||
## v4.1.10 (2016-06-29)
|
||||
@@ -115,13 +193,9 @@ This file is used to list changes made in each version of the iis cookbook.
|
||||
- moved to better method for XML checking of previous settings to detect changes (changed all check to use xml searching with appcmd instead of the previous method [none]).
|
||||
|
||||
- Improved pool resource with many more apppool properties that can be set.
|
||||
|
||||
- Fixed bug with default attribute inheritance.
|
||||
|
||||
- New recipe to enable ASP.NET 4.5.
|
||||
|
||||
- Skeleton serverspec+test-kitchen framework.
|
||||
|
||||
- Added Berksfile, Gemfile and .kitchen.yml to assist developers.
|
||||
- Fixed issue [#107] function is_new_or_empty was returning reverse results.
|
||||
- Removed dependency on "chef-client", ">= 3.7.0".
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!-- This is a generated file. Please do not edit directly -->
|
||||
|
||||
# Maintainers
|
||||
|
||||
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
|
||||
|
||||
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# iis Cookbook
|
||||
|
||||
[](https://travis-ci.org/chef-cookbooks/iis) [](https://supermarket.chef.io/cookbooks/iis)
|
||||
[](https://ci.appveyor.com/project/ChefWindowsCookbooks/iis/branch/master) [](https://supermarket.chef.io/cookbooks/iis)
|
||||
|
||||
Installs and configures Microsoft Internet Information Services (IIS) 7.0 and later
|
||||
|
||||
@@ -31,17 +31,13 @@ Installs and configures Microsoft Internet Information Services (IIS) 7.0 and la
|
||||
|
||||
### Platforms
|
||||
|
||||
- Windows Vista
|
||||
- Windows 7
|
||||
- Windows 8, 8.1
|
||||
- Windows Server 2008 (R1, R2)
|
||||
- Windows Server 2012 (R1, R2)
|
||||
|
||||
Windows 2003R2 is _not_ supported because it lacks Add/Remove Features.
|
||||
- Windows Server 2016
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.1+
|
||||
- Chef 12.5+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
@@ -209,7 +205,6 @@ Runs a config command on your IIS instance.
|
||||
|
||||
- `:set` - Edit configuration section (appcmd set config)
|
||||
- `:clear` - Clear the section configuration (appcmd clear config)
|
||||
- `:config` - [ DEPRECATED ] use `:set` instead
|
||||
|
||||
#### Properties
|
||||
|
||||
@@ -287,7 +282,7 @@ Creates an application pool in IIS.
|
||||
|
||||
##### Root Items
|
||||
|
||||
- `pool_name` - name attribute. Specifies the name of the pool to create.
|
||||
- `name` - name attribute. Specifies the name of the pool to create.
|
||||
- `runtime_version` - specifies what .NET version of the runtime to use.
|
||||
- `pipeline_mode` - specifies what pipeline mode to create the pool with, valid values are :Integrated or :Classic, the default is :Integrated
|
||||
- `no_managed_code` - allow Unmanaged Code in setting up IIS app pools is shutting down. - default is true - optional
|
||||
@@ -301,11 +296,11 @@ Creates an application pool in IIS.
|
||||
|
||||
##### Process Model Items
|
||||
|
||||
- `max_proc` - specifies the number of worker processes associated with the pool.
|
||||
- `max_processes` - specifies the number of worker processes associated with the pool.
|
||||
- `load_user_profile` - This property is used only when a service starts in a named user account. - Default is false - optional
|
||||
- `pool_identity` - the account identity that they app pool will run as, valid values are :SpecificUser, :NetworkService, :LocalService, :LocalSystem, :ApplicationPoolIdentity
|
||||
- `pool_username` - username for the identity for the application pool
|
||||
- `pool_password` password for the identity for the application pool is started. Default is true - optional
|
||||
- `identity_type` - the account identity that they app pool will run as, valid values are :SpecificUser, :NetworkService, :LocalService, :LocalSystem, :ApplicationPoolIdentity
|
||||
- `username` - username for the identity for the application pool
|
||||
- `password` password for the identity for the application pool is started. Default is true - optional
|
||||
- `logon_type` - Specifies the logon type for the process identity. (For additional information about [logon types](http://msdn.microsoft.com/en-us/library/aa378184%28VS.85%29.aspx), see the LogonUser Function topic on Microsoft's MSDN Web site.) - Available [:LogonBatch, :LogonService] - default is :LogonBatch - optional
|
||||
- `manual_group_membership` - Specifies whether the IIS_IUSRS group Security Identifier (SID) is added to the worker process token. When false, IIS automatically uses an application pool identity as though it were a member of the built-in IIS_IUSRS group, which has access to necessary file and system resources. When true, an application pool identity must be explicitly added to all resources that a worker process requires at runtime. - default is false - optional
|
||||
- `idle_timeout` - Specifies how long (in minutes) a worker process should run idle if no new requests are received and the worker process is not processing requests. After the allocated time passes, the worker process should request that it be shut down by the WWW service. - default is '00:20:00' - optional
|
||||
@@ -320,12 +315,12 @@ Creates an application pool in IIS.
|
||||
|
||||
- `disallow_rotation_on_config_change` - The DisallowRotationOnConfigChange property specifies whether or not the World Wide Web Publishing Service (WWW Service) should rotate worker processes in an application pool when the configuration has changed. - Default is false - optional
|
||||
- `disallow_overlapping_rotation` - Specifies whether the WWW Service should start another worker process to replace the existing worker process while that process
|
||||
- `log_event_on_recycle` - configure IIS to log an event when one or more of the following configured events cause an application pool to recycle (for additional information about [logging events] (https://technet.microsoft.com/en-us/library/cc771318%28v=ws.10%29.aspx). - default is 'Time, Requests, Schedule, Memory, IsapiUnhealthy, OnDemand, ConfigChange, PrivateMemory' - optional
|
||||
- `log_event_on_recycle` - configure IIS to log an event when one or more of the following configured events cause an application pool to recycle (for additional information about [logging events] (<https://technet.microsoft.com/en-us/library/cc771318%28v=ws.10%29.aspx>). - default is 'Time, Requests, Schedule, Memory, IsapiUnhealthy, OnDemand, ConfigChange, PrivateMemory' - optional
|
||||
- `recycle_schedule_clear` - specifies a pool to clear all scheduled recycle times, [true,false] Default is false - optional
|
||||
- `recycle_after_time` - specifies a pool to recycle at regular time intervals, d.hh:mm:ss, d optional
|
||||
- `recycle_at_time` - schedule a pool to recycle at a specific time, d.hh:mm:ss, d optional
|
||||
- `private_mem` - specifies the amount of private memory (in kilobytes) after which you want the pool to recycle
|
||||
- `virtual_mem` - specifies the amount of virtual memory (in kilobytes) after which you want the pool to recycle
|
||||
- `private_memory` - specifies the amount of private memory (in kilobytes) after which you want the pool to recycle
|
||||
- `virtual_memory` - specifies the amount of virtual memory (in kilobytes) after which you want the pool to recycle
|
||||
|
||||
#### Failure Items
|
||||
|
||||
@@ -381,11 +376,11 @@ Creates an application in IIS.
|
||||
|
||||
```ruby
|
||||
# creates a new app
|
||||
iis_app "myApp" do
|
||||
path "/v1_1"
|
||||
application_pool "myAppPool_v1_1"
|
||||
iis_app 'myApp' do
|
||||
path '/v1_1'
|
||||
application_pool 'myAppPool_v1_1'
|
||||
physical_path "#{node['iis']['docroot']}/testfu/v1_1"
|
||||
enabled_protocols "http,net.pipe"
|
||||
enabled_protocols 'http,net.pipe'
|
||||
action :add
|
||||
end
|
||||
```
|
||||
@@ -402,7 +397,7 @@ Allows easy management of IIS virtual directories (i.e. vdirs).
|
||||
|
||||
#### Attribute Parameters
|
||||
|
||||
- `application_name`: name attribute. Specifies the name of the application attribute. This is the name of the website or application you are adding it to.
|
||||
- `application_name`: name attribute. This is the name of the website or site + application you are adding it to.
|
||||
- `path`: The virtual directory path on the site.
|
||||
- `physical_path`: The physical path of the virtual directory on the disk.
|
||||
- `username`: (optional) The username required to logon to the physical_path. If set to "" will clear username and password.
|
||||
@@ -471,7 +466,10 @@ This is valuable to allow the `web.config` of an individual application/website
|
||||
#### Attribute Parameters
|
||||
|
||||
- `section`: The name of the section to lock.
|
||||
- `site`: The name of the site you want to lock or unlock a section for.
|
||||
- `application_path`: The path to the application you want to lock or unlock a section for.
|
||||
- `returns`: The result of the `shell_out` command.
|
||||
-
|
||||
|
||||
#### Examples
|
||||
|
||||
@@ -507,6 +505,25 @@ iis_section 'unlocked web.config globally for Basic auth' do
|
||||
end
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Sets the static content section for default web site and root to unlocked
|
||||
iis_section 'unlock staticContent of default web site' do
|
||||
section 'system.webServer/staticContent'
|
||||
site 'Default Web Site'
|
||||
action :unlock
|
||||
end
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Sets the static content section for test_app under default website and root to be unlocked
|
||||
iis_section 'unlock staticContent of default web site' do
|
||||
section 'system.webServer/staticContent'
|
||||
site 'Default Web Site'
|
||||
application_path '/test_app'
|
||||
action :unlock
|
||||
end
|
||||
```
|
||||
|
||||
### iis_module
|
||||
|
||||
Manages modules globally or on a per site basis.
|
||||
|
||||
412
cookbooks/iis/libraries/constants.rb
Normal file
412
cookbooks/iis/libraries/constants.rb
Normal file
@@ -0,0 +1,412 @@
|
||||
#
|
||||
# Cookbook:: iis
|
||||
# Library:: constants
|
||||
#
|
||||
# Copyright:: 2013-2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module Opscode
|
||||
module IIS
|
||||
# Contains functions that are used throughout this cookbook
|
||||
module Constants
|
||||
def self.default_documents
|
||||
%w(
|
||||
Default.htm
|
||||
Default.asp
|
||||
index.htm
|
||||
index.html
|
||||
iisstart.htm
|
||||
default.aspx
|
||||
)
|
||||
end
|
||||
|
||||
def self.default_mime_types
|
||||
%w(
|
||||
fileExtension='.323',mimeType='text/h323'
|
||||
fileExtension='.3g2',mimeType='video/3gpp2'
|
||||
fileExtension='.3gp2',mimeType='video/3gpp2'
|
||||
fileExtension='.3gp',mimeType='video/3gpp'
|
||||
fileExtension='.3gpp',mimeType='video/3gpp'
|
||||
fileExtension='.aaf',mimeType='application/octet-stream'
|
||||
fileExtension='.aac',mimeType='audio/aac'
|
||||
fileExtension='.aca',mimeType='application/octet-stream'
|
||||
fileExtension='.accdb',mimeType='application/msaccess'
|
||||
fileExtension='.accde',mimeType='application/msaccess'
|
||||
fileExtension='.accdt',mimeType='application/msaccess'
|
||||
fileExtension='.acx',mimeType='application/internet-property-stream'
|
||||
fileExtension='.adt',mimeType='audio/vnd.dlna.adts'
|
||||
fileExtension='.adts',mimeType='audio/vnd.dlna.adts'
|
||||
fileExtension='.afm',mimeType='application/octet-stream'
|
||||
fileExtension='.ai',mimeType='application/postscript'
|
||||
fileExtension='.aif',mimeType='audio/x-aiff'
|
||||
fileExtension='.aifc',mimeType='audio/aiff'
|
||||
fileExtension='.aiff',mimeType='audio/aiff'
|
||||
fileExtension='.application',mimeType='application/x-ms-application'
|
||||
fileExtension='.art',mimeType='image/x-jg'
|
||||
fileExtension='.asd',mimeType='application/octet-stream'
|
||||
fileExtension='.asf',mimeType='video/x-ms-asf'
|
||||
fileExtension='.asi',mimeType='application/octet-stream'
|
||||
fileExtension='.asm',mimeType='text/plain'
|
||||
fileExtension='.asr',mimeType='video/x-ms-asf'
|
||||
fileExtension='.asx',mimeType='video/x-ms-asf'
|
||||
fileExtension='.atom',mimeType='application/atom+xml'
|
||||
fileExtension='.au',mimeType='audio/basic'
|
||||
fileExtension='.avi',mimeType='video/avi'
|
||||
fileExtension='.axs',mimeType='application/olescript'
|
||||
fileExtension='.bas',mimeType='text/plain'
|
||||
fileExtension='.bcpio',mimeType='application/x-bcpio'
|
||||
fileExtension='.bin',mimeType='application/octet-stream'
|
||||
fileExtension='.bmp',mimeType='image/bmp'
|
||||
fileExtension='.c',mimeType='text/plain'
|
||||
fileExtension='.cab',mimeType='application/vnd.ms-cab-compressed'
|
||||
fileExtension='.calx',mimeType='application/vnd.ms-office.calx'
|
||||
fileExtension='.cat',mimeType='application/vnd.ms-pki.seccat'
|
||||
fileExtension='.cdf',mimeType='application/x-cdf'
|
||||
fileExtension='.chm',mimeType='application/octet-stream'
|
||||
fileExtension='.class',mimeType='application/x-java-applet'
|
||||
fileExtension='.clp',mimeType='application/x-msclip'
|
||||
fileExtension='.cmx',mimeType='image/x-cmx'
|
||||
fileExtension='.cnf',mimeType='text/plain'
|
||||
fileExtension='.cod',mimeType='image/cis-cod'
|
||||
fileExtension='.cpio',mimeType='application/x-cpio'
|
||||
fileExtension='.cpp',mimeType='text/plain'
|
||||
fileExtension='.crd',mimeType='application/x-mscardfile'
|
||||
fileExtension='.crl',mimeType='application/pkix-crl'
|
||||
fileExtension='.crt',mimeType='application/x-x509-ca-cert'
|
||||
fileExtension='.csh',mimeType='application/x-csh'
|
||||
fileExtension='.css',mimeType='text/css'
|
||||
fileExtension='.csv',mimeType='application/octet-stream'
|
||||
fileExtension='.cur',mimeType='application/octet-stream'
|
||||
fileExtension='.dcr',mimeType='application/x-director'
|
||||
fileExtension='.deploy',mimeType='application/octet-stream'
|
||||
fileExtension='.der',mimeType='application/x-x509-ca-cert'
|
||||
fileExtension='.dib',mimeType='image/bmp'
|
||||
fileExtension='.dir',mimeType='application/x-director'
|
||||
fileExtension='.disco',mimeType='text/xml'
|
||||
fileExtension='.dll',mimeType='application/x-msdownload'
|
||||
fileExtension='.dll.config',mimeType='text/xml'
|
||||
fileExtension='.dlm',mimeType='text/dlm'
|
||||
fileExtension='.doc',mimeType='application/msword'
|
||||
fileExtension='.docm',mimeType='application/vnd.ms-word.document.macroEnabled.12'
|
||||
fileExtension='.docx',mimeType='application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||
fileExtension='.dot',mimeType='application/msword'
|
||||
fileExtension='.dotm',mimeType='application/vnd.ms-word.template.macroEnabled.12'
|
||||
fileExtension='.dotx',mimeType='application/vnd.openxmlformats-officedocument.wordprocessingml.template'
|
||||
fileExtension='.dsp',mimeType='application/octet-stream'
|
||||
fileExtension='.dtd',mimeType='text/xml'
|
||||
fileExtension='.dvi',mimeType='application/x-dvi'
|
||||
fileExtension='.dvr-ms',mimeType='video/x-ms-dvr'
|
||||
fileExtension='.dwf',mimeType='drawing/x-dwf'
|
||||
fileExtension='.dwp',mimeType='application/octet-stream'
|
||||
fileExtension='.dxr',mimeType='application/x-director'
|
||||
fileExtension='.eml',mimeType='message/rfc822'
|
||||
fileExtension='.emz',mimeType='application/octet-stream'
|
||||
fileExtension='.eot',mimeType='application/vnd.ms-fontobject'
|
||||
fileExtension='.eps',mimeType='application/postscript'
|
||||
fileExtension='.etx',mimeType='text/x-setext'
|
||||
fileExtension='.evy',mimeType='application/envoy'
|
||||
fileExtension='.exe',mimeType='application/octet-stream'
|
||||
fileExtension='.exe.config',mimeType='text/xml'
|
||||
fileExtension='.fdf',mimeType='application/vnd.fdf'
|
||||
fileExtension='.fif',mimeType='application/fractals'
|
||||
fileExtension='.fla',mimeType='application/octet-stream'
|
||||
fileExtension='.flr',mimeType='x-world/x-vrml'
|
||||
fileExtension='.flv',mimeType='video/x-flv'
|
||||
fileExtension='.gif',mimeType='image/gif'
|
||||
fileExtension='.gtar',mimeType='application/x-gtar'
|
||||
fileExtension='.gz',mimeType='application/x-gzip'
|
||||
fileExtension='.h',mimeType='text/plain'
|
||||
fileExtension='.hdf',mimeType='application/x-hdf'
|
||||
fileExtension='.hdml',mimeType='text/x-hdml'
|
||||
fileExtension='.hhc',mimeType='application/x-oleobject'
|
||||
fileExtension='.hhk',mimeType='application/octet-stream'
|
||||
fileExtension='.hhp',mimeType='application/octet-stream'
|
||||
fileExtension='.hlp',mimeType='application/winhlp'
|
||||
fileExtension='.hqx',mimeType='application/mac-binhex40'
|
||||
fileExtension='.hta',mimeType='application/hta'
|
||||
fileExtension='.htc',mimeType='text/x-component'
|
||||
fileExtension='.htm',mimeType='text/html'
|
||||
fileExtension='.html',mimeType='text/html'
|
||||
fileExtension='.htt',mimeType='text/webviewhtml'
|
||||
fileExtension='.hxt',mimeType='text/html'
|
||||
fileExtension='.ico',mimeType='image/x-icon'
|
||||
fileExtension='.ics',mimeType='text/calendar'
|
||||
fileExtension='.ief',mimeType='image/ief'
|
||||
fileExtension='.iii',mimeType='application/x-iphone'
|
||||
fileExtension='.inf',mimeType='application/octet-stream'
|
||||
fileExtension='.ins',mimeType='application/x-internet-signup'
|
||||
fileExtension='.isp',mimeType='application/x-internet-signup'
|
||||
fileExtension='.IVF',mimeType='video/x-ivf'
|
||||
fileExtension='.jar',mimeType='application/java-archive'
|
||||
fileExtension='.java',mimeType='application/octet-stream'
|
||||
fileExtension='.jck',mimeType='application/liquidmotion'
|
||||
fileExtension='.jcz',mimeType='application/liquidmotion'
|
||||
fileExtension='.jfif',mimeType='image/pjpeg'
|
||||
fileExtension='.jpb',mimeType='application/octet-stream'
|
||||
fileExtension='.jpe',mimeType='image/jpeg'
|
||||
fileExtension='.jpeg',mimeType='image/jpeg'
|
||||
fileExtension='.jpg',mimeType='image/jpeg'
|
||||
fileExtension='.js',mimeType='application/javascript'
|
||||
fileExtension='.json',mimeType='application/json'
|
||||
fileExtension='.jsx',mimeType='text/jscript'
|
||||
fileExtension='.latex',mimeType='application/x-latex'
|
||||
fileExtension='.lit',mimeType='application/x-ms-reader'
|
||||
fileExtension='.lpk',mimeType='application/octet-stream'
|
||||
fileExtension='.lsf',mimeType='video/x-la-asf'
|
||||
fileExtension='.lsx',mimeType='video/x-la-asf'
|
||||
fileExtension='.lzh',mimeType='application/octet-stream'
|
||||
fileExtension='.m13',mimeType='application/x-msmediaview'
|
||||
fileExtension='.m14',mimeType='application/x-msmediaview'
|
||||
fileExtension='.m1v',mimeType='video/mpeg'
|
||||
fileExtension='.m2ts',mimeType='video/vnd.dlna.mpeg-tts'
|
||||
fileExtension='.m3u',mimeType='audio/x-mpegurl'
|
||||
fileExtension='.m4a',mimeType='audio/mp4'
|
||||
fileExtension='.m4v',mimeType='video/mp4'
|
||||
fileExtension='.man',mimeType='application/x-troff-man'
|
||||
fileExtension='.manifest',mimeType='application/x-ms-manifest'
|
||||
fileExtension='.map',mimeType='text/plain'
|
||||
fileExtension='.mdb',mimeType='application/x-msaccess'
|
||||
fileExtension='.mdp',mimeType='application/octet-stream'
|
||||
fileExtension='.me',mimeType='application/x-troff-me'
|
||||
fileExtension='.mht',mimeType='message/rfc822'
|
||||
fileExtension='.mhtml',mimeType='message/rfc822'
|
||||
fileExtension='.mid',mimeType='audio/mid'
|
||||
fileExtension='.midi',mimeType='audio/mid'
|
||||
fileExtension='.mix',mimeType='application/octet-stream'
|
||||
fileExtension='.mmf',mimeType='application/x-smaf'
|
||||
fileExtension='.mno',mimeType='text/xml'
|
||||
fileExtension='.mny',mimeType='application/x-msmoney'
|
||||
fileExtension='.mov',mimeType='video/quicktime'
|
||||
fileExtension='.movie',mimeType='video/x-sgi-movie'
|
||||
fileExtension='.mp2',mimeType='video/mpeg'
|
||||
fileExtension='.mp3',mimeType='audio/mpeg'
|
||||
fileExtension='.mp4',mimeType='video/mp4'
|
||||
fileExtension='.mp4v',mimeType='video/mp4'
|
||||
fileExtension='.mpa',mimeType='video/mpeg'
|
||||
fileExtension='.mpe',mimeType='video/mpeg'
|
||||
fileExtension='.mpeg',mimeType='video/mpeg'
|
||||
fileExtension='.mpg',mimeType='video/mpeg'
|
||||
fileExtension='.mpp',mimeType='application/vnd.ms-project'
|
||||
fileExtension='.mpv2',mimeType='video/mpeg'
|
||||
fileExtension='.ms',mimeType='application/x-troff-ms'
|
||||
fileExtension='.msi',mimeType='application/octet-stream'
|
||||
fileExtension='.mso',mimeType='application/octet-stream'
|
||||
fileExtension='.mvb',mimeType='application/x-msmediaview'
|
||||
fileExtension='.mvc',mimeType='application/x-miva-compiled'
|
||||
fileExtension='.nc',mimeType='application/x-netcdf'
|
||||
fileExtension='.nsc',mimeType='video/x-ms-asf'
|
||||
fileExtension='.nws',mimeType='message/rfc822'
|
||||
fileExtension='.ocx',mimeType='application/octet-stream'
|
||||
fileExtension='.oda',mimeType='application/oda'
|
||||
fileExtension='.odc',mimeType='text/x-ms-odc'
|
||||
fileExtension='.ods',mimeType='application/oleobject'
|
||||
fileExtension='.oga',mimeType='audio/ogg'
|
||||
fileExtension='.ogg',mimeType='video/ogg'
|
||||
fileExtension='.ogv',mimeType='video/ogg'
|
||||
fileExtension='.one',mimeType='application/onenote'
|
||||
fileExtension='.onea',mimeType='application/onenote'
|
||||
fileExtension='.onetoc',mimeType='application/onenote'
|
||||
fileExtension='.onetoc2',mimeType='application/onenote'
|
||||
fileExtension='.onetmp',mimeType='application/onenote'
|
||||
fileExtension='.onepkg',mimeType='application/onenote'
|
||||
fileExtension='.osdx',mimeType='application/opensearchdescription+xml'
|
||||
fileExtension='.otf',mimeType='font/otf'
|
||||
fileExtension='.p10',mimeType='application/pkcs10'
|
||||
fileExtension='.p12',mimeType='application/x-pkcs12'
|
||||
fileExtension='.p7b',mimeType='application/x-pkcs7-certificates'
|
||||
fileExtension='.p7c',mimeType='application/pkcs7-mime'
|
||||
fileExtension='.p7m',mimeType='application/pkcs7-mime'
|
||||
fileExtension='.p7r',mimeType='application/x-pkcs7-certreqresp'
|
||||
fileExtension='.p7s',mimeType='application/pkcs7-signature'
|
||||
fileExtension='.pbm',mimeType='image/x-portable-bitmap'
|
||||
fileExtension='.pcx',mimeType='application/octet-stream'
|
||||
fileExtension='.pcz',mimeType='application/octet-stream'
|
||||
fileExtension='.pdf',mimeType='application/pdf'
|
||||
fileExtension='.pfb',mimeType='application/octet-stream'
|
||||
fileExtension='.pfm',mimeType='application/octet-stream'
|
||||
fileExtension='.pfx',mimeType='application/x-pkcs12'
|
||||
fileExtension='.pgm',mimeType='image/x-portable-graymap'
|
||||
fileExtension='.pko',mimeType='application/vnd.ms-pki.pko'
|
||||
fileExtension='.pma',mimeType='application/x-perfmon'
|
||||
fileExtension='.pmc',mimeType='application/x-perfmon'
|
||||
fileExtension='.pml',mimeType='application/x-perfmon'
|
||||
fileExtension='.pmr',mimeType='application/x-perfmon'
|
||||
fileExtension='.pmw',mimeType='application/x-perfmon'
|
||||
fileExtension='.png',mimeType='image/png'
|
||||
fileExtension='.pnm',mimeType='image/x-portable-anymap'
|
||||
fileExtension='.pnz',mimeType='image/png'
|
||||
fileExtension='.pot',mimeType='application/vnd.ms-powerpoint'
|
||||
fileExtension='.potm',mimeType='application/vnd.ms-powerpoint.template.macroEnabled.12'
|
||||
fileExtension='.potx',mimeType='application/vnd.openxmlformats-officedocument.presentationml.template'
|
||||
fileExtension='.ppam',mimeType='application/vnd.ms-powerpoint.addin.macroEnabled.12'
|
||||
fileExtension='.ppm',mimeType='image/x-portable-pixmap'
|
||||
fileExtension='.pps',mimeType='application/vnd.ms-powerpoint'
|
||||
fileExtension='.ppsm',mimeType='application/vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||
fileExtension='.ppsx',mimeType='application/vnd.openxmlformats-officedocument.presentationml.slideshow'
|
||||
fileExtension='.ppt',mimeType='application/vnd.ms-powerpoint'
|
||||
fileExtension='.pptm',mimeType='application/vnd.ms-powerpoint.presentation.macroEnabled.12'
|
||||
fileExtension='.pptx',mimeType='application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
||||
fileExtension='.prf',mimeType='application/pics-rules'
|
||||
fileExtension='.prm',mimeType='application/octet-stream'
|
||||
fileExtension='.prx',mimeType='application/octet-stream'
|
||||
fileExtension='.ps',mimeType='application/postscript'
|
||||
fileExtension='.psd',mimeType='application/octet-stream'
|
||||
fileExtension='.psm',mimeType='application/octet-stream'
|
||||
fileExtension='.psp',mimeType='application/octet-stream'
|
||||
fileExtension='.pub',mimeType='application/x-mspublisher'
|
||||
fileExtension='.qt',mimeType='video/quicktime'
|
||||
fileExtension='.qtl',mimeType='application/x-quicktimeplayer'
|
||||
fileExtension='.qxd',mimeType='application/octet-stream'
|
||||
fileExtension='.ra',mimeType='audio/x-pn-realaudio'
|
||||
fileExtension='.ram',mimeType='audio/x-pn-realaudio'
|
||||
fileExtension='.rar',mimeType='application/octet-stream'
|
||||
fileExtension='.ras',mimeType='image/x-cmu-raster'
|
||||
fileExtension='.rf',mimeType='image/vnd.rn-realflash'
|
||||
fileExtension='.rgb',mimeType='image/x-rgb'
|
||||
fileExtension='.rm',mimeType='application/vnd.rn-realmedia'
|
||||
fileExtension='.rmi',mimeType='audio/mid'
|
||||
fileExtension='.roff',mimeType='application/x-troff'
|
||||
fileExtension='.rpm',mimeType='audio/x-pn-realaudio-plugin'
|
||||
fileExtension='.rtf',mimeType='application/rtf'
|
||||
fileExtension='.rtx',mimeType='text/richtext'
|
||||
fileExtension='.scd',mimeType='application/x-msschedule'
|
||||
fileExtension='.sct',mimeType='text/scriptlet'
|
||||
fileExtension='.sea',mimeType='application/octet-stream'
|
||||
fileExtension='.setpay',mimeType='application/set-payment-initiation'
|
||||
fileExtension='.setreg',mimeType='application/set-registration-initiation'
|
||||
fileExtension='.sgml',mimeType='text/sgml'
|
||||
fileExtension='.sh',mimeType='application/x-sh'
|
||||
fileExtension='.shar',mimeType='application/x-shar'
|
||||
fileExtension='.sit',mimeType='application/x-stuffit'
|
||||
fileExtension='.sldm',mimeType='application/vnd.ms-powerpoint.slide.macroEnabled.12'
|
||||
fileExtension='.sldx',mimeType='application/vnd.openxmlformats-officedocument.presentationml.slide'
|
||||
fileExtension='.smd',mimeType='audio/x-smd'
|
||||
fileExtension='.smi',mimeType='application/octet-stream'
|
||||
fileExtension='.smx',mimeType='audio/x-smd'
|
||||
fileExtension='.smz',mimeType='audio/x-smd'
|
||||
fileExtension='.snd',mimeType='audio/basic'
|
||||
fileExtension='.snp',mimeType='application/octet-stream'
|
||||
fileExtension='.spc',mimeType='application/x-pkcs7-certificates'
|
||||
fileExtension='.spl',mimeType='application/futuresplash'
|
||||
fileExtension='.spx',mimeType='audio/ogg'
|
||||
fileExtension='.src',mimeType='application/x-wais-source'
|
||||
fileExtension='.ssm',mimeType='application/streamingmedia'
|
||||
fileExtension='.sst',mimeType='application/vnd.ms-pki.certstore'
|
||||
fileExtension='.stl',mimeType='application/vnd.ms-pki.stl'
|
||||
fileExtension='.sv4cpio',mimeType='application/x-sv4cpio'
|
||||
fileExtension='.sv4crc',mimeType='application/x-sv4crc'
|
||||
fileExtension='.svg',mimeType='image/svg+xml'
|
||||
fileExtension='.svgz',mimeType='image/svg+xml'
|
||||
fileExtension='.swf',mimeType='application/x-shockwave-flash'
|
||||
fileExtension='.t',mimeType='application/x-troff'
|
||||
fileExtension='.tar',mimeType='application/x-tar'
|
||||
fileExtension='.tcl',mimeType='application/x-tcl'
|
||||
fileExtension='.tex',mimeType='application/x-tex'
|
||||
fileExtension='.texi',mimeType='application/x-texinfo'
|
||||
fileExtension='.texinfo',mimeType='application/x-texinfo'
|
||||
fileExtension='.tgz',mimeType='application/x-compressed'
|
||||
fileExtension='.thmx',mimeType='application/vnd.ms-officetheme'
|
||||
fileExtension='.thn',mimeType='application/octet-stream'
|
||||
fileExtension='.tif',mimeType='image/tiff'
|
||||
fileExtension='.tiff',mimeType='image/tiff'
|
||||
fileExtension='.toc',mimeType='application/octet-stream'
|
||||
fileExtension='.tr',mimeType='application/x-troff'
|
||||
fileExtension='.trm',mimeType='application/x-msterminal'
|
||||
fileExtension='.ts',mimeType='video/vnd.dlna.mpeg-tts'
|
||||
fileExtension='.tsv',mimeType='text/tab-separated-values'
|
||||
fileExtension='.ttf',mimeType='application/octet-stream'
|
||||
fileExtension='.tts',mimeType='video/vnd.dlna.mpeg-tts'
|
||||
fileExtension='.txt',mimeType='text/plain'
|
||||
fileExtension='.u32',mimeType='application/octet-stream'
|
||||
fileExtension='.uls',mimeType='text/iuls'
|
||||
fileExtension='.ustar',mimeType='application/x-ustar'
|
||||
fileExtension='.vbs',mimeType='text/vbscript'
|
||||
fileExtension='.vcf',mimeType='text/x-vcard'
|
||||
fileExtension='.vcs',mimeType='text/plain'
|
||||
fileExtension='.vdx',mimeType='application/vnd.ms-visio.viewer'
|
||||
fileExtension='.vml',mimeType='text/xml'
|
||||
fileExtension='.vsd',mimeType='application/vnd.visio'
|
||||
fileExtension='.vss',mimeType='application/vnd.visio'
|
||||
fileExtension='.vst',mimeType='application/vnd.visio'
|
||||
fileExtension='.vsto',mimeType='application/x-ms-vsto'
|
||||
fileExtension='.vsw',mimeType='application/vnd.visio'
|
||||
fileExtension='.vsx',mimeType='application/vnd.visio'
|
||||
fileExtension='.vtx',mimeType='application/vnd.visio'
|
||||
fileExtension='.wav',mimeType='audio/wav'
|
||||
fileExtension='.wax',mimeType='audio/x-ms-wax'
|
||||
fileExtension='.wbmp',mimeType='image/vnd.wap.wbmp'
|
||||
fileExtension='.wcm',mimeType='application/vnd.ms-works'
|
||||
fileExtension='.wdb',mimeType='application/vnd.ms-works'
|
||||
fileExtension='.webm',mimeType='video/webm'
|
||||
fileExtension='.wks',mimeType='application/vnd.ms-works'
|
||||
fileExtension='.wm',mimeType='video/x-ms-wm'
|
||||
fileExtension='.wma',mimeType='audio/x-ms-wma'
|
||||
fileExtension='.wmd',mimeType='application/x-ms-wmd'
|
||||
fileExtension='.wmf',mimeType='application/x-msmetafile'
|
||||
fileExtension='.wml',mimeType='text/vnd.wap.wml'
|
||||
fileExtension='.wmlc',mimeType='application/vnd.wap.wmlc'
|
||||
fileExtension='.wmls',mimeType='text/vnd.wap.wmlscript'
|
||||
fileExtension='.wmlsc',mimeType='application/vnd.wap.wmlscriptc'
|
||||
fileExtension='.wmp',mimeType='video/x-ms-wmp'
|
||||
fileExtension='.wmv',mimeType='video/x-ms-wmv'
|
||||
fileExtension='.wmx',mimeType='video/x-ms-wmx'
|
||||
fileExtension='.wmz',mimeType='application/x-ms-wmz'
|
||||
fileExtension='.woff',mimeType='font/x-woff'
|
||||
fileExtension='.wps',mimeType='application/vnd.ms-works'
|
||||
fileExtension='.wri',mimeType='application/x-mswrite'
|
||||
fileExtension='.wrl',mimeType='x-world/x-vrml'
|
||||
fileExtension='.wrz',mimeType='x-world/x-vrml'
|
||||
fileExtension='.wsdl',mimeType='text/xml'
|
||||
fileExtension='.wtv',mimeType='video/x-ms-wtv'
|
||||
fileExtension='.wvx',mimeType='video/x-ms-wvx'
|
||||
fileExtension='.x',mimeType='application/directx'
|
||||
fileExtension='.xaf',mimeType='x-world/x-vrml'
|
||||
fileExtension='.xaml',mimeType='application/xaml+xml'
|
||||
fileExtension='.xap',mimeType='application/x-silverlight-app'
|
||||
fileExtension='.xbap',mimeType='application/x-ms-xbap'
|
||||
fileExtension='.xbm',mimeType='image/x-xbitmap'
|
||||
fileExtension='.xdr',mimeType='text/plain'
|
||||
fileExtension='.xht',mimeType='application/xhtml+xml'
|
||||
fileExtension='.xhtml',mimeType='application/xhtml+xml'
|
||||
fileExtension='.xla',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xlam',mimeType='application/vnd.ms-excel.addin.macroEnabled.12'
|
||||
fileExtension='.xlc',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xlm',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xls',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xlsb',mimeType='application/vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||
fileExtension='.xlsm',mimeType='application/vnd.ms-excel.sheet.macroEnabled.12'
|
||||
fileExtension='.xlsx',mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
fileExtension='.xlt',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xltm',mimeType='application/vnd.ms-excel.template.macroEnabled.12'
|
||||
fileExtension='.xltx',mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.template'
|
||||
fileExtension='.xlw',mimeType='application/vnd.ms-excel'
|
||||
fileExtension='.xml',mimeType='text/xml'
|
||||
fileExtension='.xof',mimeType='x-world/x-vrml'
|
||||
fileExtension='.xpm',mimeType='image/x-xpixmap'
|
||||
fileExtension='.xps',mimeType='application/vnd.ms-xpsdocument'
|
||||
fileExtension='.xsd',mimeType='text/xml'
|
||||
fileExtension='.xsf',mimeType='text/xml'
|
||||
fileExtension='.xsl',mimeType='text/xml'
|
||||
fileExtension='.xslt',mimeType='text/xml'
|
||||
fileExtension='.xsn',mimeType='application/octet-stream'
|
||||
fileExtension='.xtp',mimeType='application/octet-stream'
|
||||
fileExtension='.xwd',mimeType='image/x-xwindowdump'
|
||||
fileExtension='.z',mimeType='application/x-compress'
|
||||
fileExtension='.zip',mimeType='application/x-zip-compressed
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,10 +2,7 @@
|
||||
# Cookbook:: iis
|
||||
# Library:: helper
|
||||
#
|
||||
# Author:: Julian C. Dunn <jdunn@chef.io>
|
||||
# Author:: Justin Schuhmann <jmschu02@gmail.com>
|
||||
#
|
||||
# Copyright:: 2013-2016, Chef Software, Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -73,7 +70,25 @@ module Opscode
|
||||
Chef::Util::PathHelper.cleanpath(path)
|
||||
end
|
||||
# Remove any trailing slashes to prevent them from accidentally escaping any quotes.
|
||||
path.chomp('/').chomp('\\')
|
||||
path.tr('/', '\\')
|
||||
end
|
||||
|
||||
def application_cleanname(application_name)
|
||||
if application_name.count('/') == 0
|
||||
"#{application_name}/"
|
||||
elsif application_name.count('/') > 1
|
||||
application_name.chomp('/')
|
||||
else
|
||||
application_name
|
||||
end
|
||||
end
|
||||
|
||||
def value(document, xpath)
|
||||
XPath.first(document, xpath).to_s
|
||||
end
|
||||
|
||||
def bool(value)
|
||||
value == 'true'
|
||||
end
|
||||
|
||||
def new_value?(document, xpath, value_to_check)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#
|
||||
# Cookbook:: iis
|
||||
# Library:: helper
|
||||
# Library:: processors
|
||||
#
|
||||
# Author:: Justin Schuhmann <jmschu02@gmail.com>
|
||||
#
|
||||
# Copyright:: 2013-2016, Chef Software, Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -23,71 +21,81 @@ module Opscode
|
||||
module IIS
|
||||
# Contains functions that are used throughout this cookbook
|
||||
module Processors
|
||||
def default_documents(default_document, default_documents_enabled, add = true, remove = true, specifier = '')
|
||||
def current_default_documents_config(specifier = '')
|
||||
cmd = shell_out! get_default_documents_command specifier
|
||||
return unless cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = REXML::Document.new xml
|
||||
|
||||
is_new_default_documents_enabled = new_value?(doc.root, 'CONFIG/system.webServer-defaultDocument/@enabled', default_documents_enabled.to_s)
|
||||
current_default_documents = REXML::XPath.match(doc.root, 'CONFIG/system.webServer-defaultDocument/files/add/@value').map(&:value)
|
||||
{
|
||||
default_documents_enabled: value(doc.root, 'CONFIG/system.webServer-defaultDocument/@enabled'),
|
||||
default_documents: REXML::XPath.match(doc.root, 'CONFIG/system.webServer-defaultDocument/files/add/@value').map(&:value),
|
||||
}
|
||||
end
|
||||
|
||||
def current_mime_maps_config(specifier = '')
|
||||
# handles mime maps
|
||||
cmd = shell_out! get_mime_map_command specifier
|
||||
return unless cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = REXML::Document.new xml
|
||||
|
||||
REXML::XPath.match(doc.root, 'CONFIG/system.webServer-staticContent/mimeMap').map { |x| "fileExtension='#{x.attribute 'fileExtension'}',mimeType='#{x.attribute 'mimeType'}'" }
|
||||
end
|
||||
|
||||
def set_default_documents_enabled(value, specifier = '')
|
||||
cmd = default_documents_command specifier
|
||||
cmd << " /enabled:#{value}"
|
||||
shell_out! cmd
|
||||
end
|
||||
|
||||
if is_new_default_documents_enabled
|
||||
cmd << " /enabled:#{default_documents_enabled}"
|
||||
end
|
||||
|
||||
def set_default_documents(desired_default_documents, current_default_documents, add = true, remove = true, specifier = '')
|
||||
cmd = default_documents_command specifier
|
||||
Chef::Log.warn("new #{desired_default_documents} --- old #{current_default_documents}")
|
||||
if add
|
||||
(default_document - current_default_documents).each do |document|
|
||||
(desired_default_documents - current_default_documents).each do |document|
|
||||
cmd << " /+files.[value='#{document}']"
|
||||
end
|
||||
end
|
||||
if remove && !add
|
||||
(default_document - current_default_documents).each do |document|
|
||||
(desired_default_documents - current_default_documents).each do |document|
|
||||
cmd << " /-files.[value='#{document}']"
|
||||
end
|
||||
end
|
||||
if remove && add
|
||||
(current_default_documents - default_document).each do |document|
|
||||
(current_default_documents - desired_default_documents).each do |document|
|
||||
cmd << " /-files.[value='#{document}']"
|
||||
end
|
||||
end
|
||||
|
||||
Chef::Log.warn("before cmd -- #{cmd}")
|
||||
|
||||
return unless cmd != default_documents_command(specifier)
|
||||
Chef::Log.warn("after cmd -- #{cmd}")
|
||||
shell_out! cmd
|
||||
Chef::Log.info('Default Documents updated')
|
||||
@was_updated = true
|
||||
end
|
||||
|
||||
def mime_maps(new_resource_mime_maps, add = true, remove = true, specifier = '')
|
||||
# handles mime maps
|
||||
cmd = shell_out get_mime_map_command specifier
|
||||
return unless cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = REXML::Document.new xml
|
||||
current_mime_maps = REXML::XPath.match(doc.root, 'CONFIG/system.webServer-staticContent/mimeMap').map { |x| "fileExtension='#{x.attribute 'fileExtension'}',mimeType='#{x.attribute 'mimeType'}'" }
|
||||
def set_mime_maps(desired_mime_maps, current_mime_maps, add = true, remove = true, specifier = '')
|
||||
cmd = mime_map_command specifier
|
||||
|
||||
if add
|
||||
(new_resource_mime_maps - current_mime_maps).each do |mime_map|
|
||||
(desired_mime_maps - current_mime_maps).each do |mime_map|
|
||||
cmd << " /+\"[#{mime_map}]\""
|
||||
end
|
||||
end
|
||||
if remove && !add
|
||||
(new_resource_mime_maps - current_mime_maps).each do |mime_map|
|
||||
(desired_mime_maps - current_mime_maps).each do |mime_map|
|
||||
cmd << " /-\"[#{mime_map}]\""
|
||||
end
|
||||
end
|
||||
if remove && add
|
||||
(current_mime_maps - new_resource_mime_maps).each do |mime_map|
|
||||
(current_mime_maps - desired_mime_maps).each do |mime_map|
|
||||
cmd << " /-\"[#{mime_map}]\""
|
||||
end
|
||||
end
|
||||
|
||||
return unless cmd != mime_map_command(specifier)
|
||||
shell_out! cmd
|
||||
Chef::Log.info('mime maps updated')
|
||||
@was_updated = true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
79
cookbooks/iis/libraries/section_helper.rb
Normal file
79
cookbooks/iis/libraries/section_helper.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
#
|
||||
# Cookbook:: iis
|
||||
# Library:: section-helper
|
||||
#
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module Opscode
|
||||
module IIS
|
||||
# Contains functions that are used throughout this cookbook
|
||||
module SectionHelper
|
||||
require 'rexml/document'
|
||||
include REXML
|
||||
|
||||
def lock(node, section, location = '', returns = [0])
|
||||
cmd_list_section node, :lock, section, location, returns
|
||||
end
|
||||
|
||||
def unlock(node, section, location = '', returns = [0])
|
||||
cmd_list_section node, :unlock, section, location, returns
|
||||
end
|
||||
|
||||
def override_mode(node, action, section, location = '', returns = [0])
|
||||
cmd_list_section(node, action, section, location, returns)
|
||||
end
|
||||
|
||||
def get_current_lock(node, section, location = '')
|
||||
command_path = 'MACHINE/WEBROOT/APPHOST'
|
||||
command_path << "/#{location}" if location
|
||||
cmd = "#{appcmd(node)} list config \"#{command_path}}\""
|
||||
cmd << " -section:#{section} -commit:apphost /config:* /xml"
|
||||
result = shell_out cmd
|
||||
if result.stderr.empty?
|
||||
xml = result.stdout
|
||||
doc = Document.new xml
|
||||
value(doc.root, 'CONFIG/@overrideMode')
|
||||
else
|
||||
Chef::Log.info(result.stderr)
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
def cmd_section(node, check, section, location, returns)
|
||||
cmd = "#{appcmd(node)} set config \"MACHINE/WEBROOT/APPHOST/#{location}\""
|
||||
cmd << " -section:\"#{section}\" -overrideMode:#{check}"
|
||||
cmd << ' -commit:apphost'
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: returns)
|
||||
|
||||
return unless location
|
||||
cmd = "#{appcmd(node)} set config \"MACHINE/WEBROOT/APPHOST/#{location}\""
|
||||
cmd << " -section:\"#{section}\" -overrideMode:#{check}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: returns)
|
||||
end
|
||||
|
||||
def cmd_list_section(node, action, section, location, returns)
|
||||
current_lock = get_current_lock(node, section, location)
|
||||
check = action if action == 'Inherit'
|
||||
check = (action == :lock ? 'Deny' : 'Allow') if action != 'Inherit'
|
||||
|
||||
cmd_section node, check, section, location, returns unless current_lock == check
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
File diff suppressed because one or more lines are too long
@@ -1,144 +0,0 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com)
|
||||
# Contributor:: Adam Wayne (awayne@waynedigital.com)
|
||||
# Cookbook:: iis
|
||||
# Provider:: app
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'rexml/document'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :add do
|
||||
if !@current_resource.exists
|
||||
cmd = "#{appcmd(node)} add app /site.name:\"#{new_resource.site_name}\""
|
||||
cmd << " /path:\"#{new_resource.path}\""
|
||||
cmd << " /applicationPool:\"#{new_resource.application_pool}\"" if new_resource.application_pool
|
||||
cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.physical_path)}\"" if new_resource.physical_path
|
||||
cmd << " /enabledProtocols:\"#{new_resource.enabled_protocols}\"" if new_resource.enabled_protocols
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info('App created')
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} app already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
@was_updated = false
|
||||
cmd_current_values = "#{appcmd(node)} list app \"#{site_identifier}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
is_new_path = new_or_empty_value?(doc.root, 'APP/application/@path', new_resource.path.to_s)
|
||||
is_new_application_pool = new_or_empty_value?(doc.root, 'APP/application/@applicationPool', new_resource.application_pool.to_s)
|
||||
is_new_enabled_protocols = new_or_empty_value?(doc.root, 'APP/application/@enabledProtocols', new_resource.enabled_protocols.to_s)
|
||||
is_new_physical_path = new_or_empty_value?(doc.root, 'APP/application/virtualDirectory/@physicalPath', new_resource.physical_path.to_s)
|
||||
|
||||
# only get the beginning of the command if there is something that changeds
|
||||
cmd = "#{appcmd(node)} set app \"#{site_identifier}\"" if (new_resource.path && is_new_path) ||
|
||||
(new_resource.application_pool && is_new_application_pool) ||
|
||||
(new_resource.enabled_protocols && is_new_enabled_protocols)
|
||||
# adds path to the cmd
|
||||
cmd << " /path:\"#{new_resource.path}\"" if new_resource.path && is_new_path
|
||||
# adds applicationPool to the cmd
|
||||
cmd << " /applicationPool:\"#{new_resource.application_pool}\"" if new_resource.application_pool && is_new_application_pool
|
||||
# adds enabledProtocols to the cmd
|
||||
cmd << " /enabledProtocols:\"#{new_resource.enabled_protocols}\"" if new_resource.enabled_protocols && is_new_enabled_protocols
|
||||
Chef::Log.debug(cmd)
|
||||
|
||||
if cmd.nil?
|
||||
Chef::Log.debug("#{new_resource} application - nothing to do")
|
||||
else
|
||||
shell_out!(cmd)
|
||||
@was_updated = true
|
||||
end
|
||||
|
||||
if (new_resource.path && is_new_path) ||
|
||||
(new_resource.application_pool && is_new_application_pool) ||
|
||||
(new_resource.enabled_protocols && is_new_enabled_protocols)
|
||||
@was_updated = true
|
||||
end
|
||||
|
||||
if new_resource.physical_path && is_new_physical_path
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir /vdir.name:\"#{vdir_identifier}\""
|
||||
cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.physical_path)}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
if @was_updated
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} configured application")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} application - nothing to do")
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_app action :config, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if @current_resource.exists
|
||||
shell_out!("#{appcmd(node)} delete app \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} app does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisApp.new(new_resource.name)
|
||||
@current_resource.site_name(new_resource.site_name)
|
||||
@current_resource.path(new_resource.path)
|
||||
@current_resource.application_pool(new_resource.application_pool)
|
||||
cmd = shell_out("#{appcmd(node)} list app")
|
||||
Chef::Log.debug("#{new_resource} list app command output: #{cmd.stdout}")
|
||||
regex = /^APP\s\"#{new_resource.site_name}#{new_resource.path}\"/
|
||||
Chef::Log.debug('Running regex')
|
||||
if cmd.stderr.empty?
|
||||
result = cmd.stdout.match(regex)
|
||||
Chef::Log.debug("#{new_resource} current_resource match output:#{result}")
|
||||
@current_resource.exists = result
|
||||
else
|
||||
log "Failed to run iis_app action :load_current_resource, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def site_identifier
|
||||
"#{new_resource.site_name}#{new_resource.path}"
|
||||
end
|
||||
|
||||
# Ensure VDIR identifier has a trailing slash
|
||||
def vdir_identifier
|
||||
site_identifier.end_with?('/') ? site_identifier : site_identifier + '/'
|
||||
end
|
||||
@@ -1,51 +0,0 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com)
|
||||
# Contributor:: David Dvorak (david.dvorak@webtrends.com)
|
||||
# Cookbook:: iis
|
||||
# Resource:: config
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
# :config deprecated, use :set instead
|
||||
action :config do
|
||||
Chef::Log.warn <<-eos
|
||||
Use of action `:config` in resource `iis_config` is now deprecated and will be removed in a future release (v4.2.0).
|
||||
`:set` should be used instead.
|
||||
eos
|
||||
new_resource.updated_by_last_action(true) if config
|
||||
end
|
||||
|
||||
action :set do
|
||||
new_resource.updated_by_last_action(true) if config
|
||||
end
|
||||
|
||||
action :clear do
|
||||
new_resource.updated_by_last_action(true) if config(:clear)
|
||||
end
|
||||
|
||||
def config(action = :set)
|
||||
cmd = "#{appcmd(node)} #{action} config #{new_resource.cfg_cmd}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: new_resource.returns)
|
||||
Chef::Log.info('IIS Config command run')
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
@@ -1,123 +0,0 @@
|
||||
#
|
||||
# Author:: Jon DeCamp (<jon.decamp@nordstrom.com>)
|
||||
# Cookbook:: iis
|
||||
# Provider:: site
|
||||
#
|
||||
# Copyright:: 2013-2016, Nordstrom, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
include Chef::Mixin::ShellOut
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
# Support whyrun
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
# appcmd syntax for adding modules
|
||||
# appcmd add module /name:string /type:string /preCondition:string
|
||||
action :add do
|
||||
if !@current_resource.exists
|
||||
converge_by("add IIS module #{new_resource.module_name}") do
|
||||
cmd = "#{appcmd(node)} add module /module.name:\"#{new_resource.module_name}\""
|
||||
|
||||
if new_resource.application
|
||||
cmd << " /app.name:\"#{new_resource.application}\""
|
||||
end
|
||||
|
||||
cmd << " /type:\"#{new_resource.type}\"" if new_resource.type
|
||||
|
||||
if new_resource.precondition
|
||||
cmd << " /preCondition:\"#{new_resource.precondition}\""
|
||||
end
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
|
||||
Chef::Log.info("#{new_resource} added module '#{new_resource.module_name}'")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if @current_resource.exists
|
||||
converge_by("delete IIS module #{new_resource.module_name}") do
|
||||
cmd = "#{appcmd(node)} delete module /module.name:\"#{new_resource.module_name}\""
|
||||
if new_resource.application
|
||||
cmd << " /app.name:\"#{new_resource.application}\""
|
||||
end
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
end
|
||||
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
# appcmd syntax for installing native modules
|
||||
# appcmd install module /name:string /add:string(true|false) /image:string
|
||||
action :install do
|
||||
if !@current_resource.exists
|
||||
converge_by("install IIS module #{new_resource.module_name}") do
|
||||
cmd = "#{appcmd(node)} install module /name:\"#{new_resource.module_name}\""
|
||||
cmd << " /add:\"#{new_resource.add}\"" unless new_resource.add.nil?
|
||||
cmd << " /image:\"#{new_resource.image}\"" if new_resource.image
|
||||
cmd << " /preCondition:\"#{new_resource.precondition}\"" if new_resource.precondition
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
|
||||
Chef::Log.info("#{new_resource} installed module '#{new_resource.module_name}'")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
# appcmd syntax for uninstalling native modules
|
||||
# appcmd uninstall module <name>
|
||||
action :uninstall do
|
||||
if @current_resource.exists
|
||||
converge_by("uninstall IIS module #{new_resource.module_name}") do
|
||||
cmd = "#{appcmd(node)} uninstall module \"#{new_resource.module_name}\""
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
end
|
||||
|
||||
Chef::Log.info("#{new_resource} uninstalled module '#{new_resource.module_name}'")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module does not exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisModule.new(new_resource.name)
|
||||
@current_resource.module_name(new_resource.module_name)
|
||||
cmd = if new_resource.application
|
||||
shell_out("#{appcmd(node)} list module /module.name:\"#{new_resource.module_name}\" /app.name:\"#{new_resource.application}\"")
|
||||
else
|
||||
shell_out("#{appcmd(node)} list module /module.name:\"#{new_resource.module_name}\"")
|
||||
end
|
||||
|
||||
# 'MODULE "Module Name" ( type:module.type, preCondition:condition )'
|
||||
# 'MODULE "Module Name" ( native, preCondition:condition )'
|
||||
|
||||
Chef::Log.debug("#{new_resource} list module command output: #{cmd.stdout}")
|
||||
@current_resource.exists = !cmd.stdout.empty?
|
||||
end
|
||||
@@ -1,329 +0,0 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com)
|
||||
# Contributor:: David Dvorak (david.dvorak@webtrends.com)
|
||||
# Cookbook:: iis
|
||||
# Provider:: pool
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'rexml/document'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :add do
|
||||
if !@current_resource.exists
|
||||
cmd = "#{appcmd(node)} add apppool /name:\"#{new_resource.pool_name}\""
|
||||
if new_resource.no_managed_code
|
||||
cmd << ' /managedRuntimeVersion:'
|
||||
elsif new_resource.runtime_version
|
||||
cmd << " /managedRuntimeVersion:v#{new_resource.runtime_version}"
|
||||
end
|
||||
cmd << " /managedPipelineMode:#{new_resource.pipeline_mode.capitalize}" if new_resource.pipeline_mode
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
configure
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info('App pool created')
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} pool already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
new_resource.updated_by_last_action(true) if configure
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if @current_resource.exists
|
||||
shell_out!("#{appcmd(node)} delete apppool \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} pool does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :start do
|
||||
if !@current_resource.running
|
||||
shell_out!("#{appcmd(node)} start apppool \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} started")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already running - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
if @current_resource.running
|
||||
shell_out!("#{appcmd(node)} stop apppool \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} stopped")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already stopped - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
shell_out!("#{appcmd(node)} stop APPPOOL \"#{site_identifier}\"")
|
||||
sleep 2
|
||||
shell_out!("#{appcmd(node)} start APPPOOL \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} restarted")
|
||||
end
|
||||
|
||||
action :recycle do
|
||||
shell_out!("#{appcmd(node)} recycle APPPOOL \"#{site_identifier}\"")
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} recycled")
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisPool.new(new_resource.name)
|
||||
@current_resource.pool_name(new_resource.pool_name)
|
||||
cmd = shell_out("#{appcmd(node)} list apppool")
|
||||
# APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started)
|
||||
Chef::Log.debug("#{new_resource} list apppool command output: #{cmd.stdout}")
|
||||
if cmd.stderr.empty?
|
||||
result = cmd.stdout.gsub(/\r\n?/, "\n") # ensure we have no carriage returns
|
||||
result = result.match(/^APPPOOL\s\"(#{new_resource.pool_name})\"\s\(MgdVersion:(.*),MgdMode:(.*),state:(.*)\)$/i)
|
||||
Chef::Log.debug("#{new_resource} current_resource match output: #{result}")
|
||||
if result
|
||||
@current_resource.exists = true
|
||||
@current_resource.running = result[4] =~ /Started/ ? true : false
|
||||
else
|
||||
@current_resource.exists = false
|
||||
@current_resource.running = false
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_pool action :load_current_resource, #{cmd.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def site_identifier
|
||||
new_resource.pool_name
|
||||
end
|
||||
|
||||
def configure
|
||||
@was_updated = false
|
||||
cmd_current_values = "#{appcmd(node)} list apppool \"#{new_resource.pool_name}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
|
||||
# root items
|
||||
is_new_managed_runtime_version =
|
||||
if new_resource.no_managed_code
|
||||
new_value?(doc.root, 'APPPOOL/@RuntimeVersion', '')
|
||||
else
|
||||
new_value?(doc.root, 'APPPOOL/@RuntimeVersion', "v#{new_resource.runtime_version}")
|
||||
end
|
||||
is_new_pipeline_mode = new_value?(doc.root, 'APPPOOL/@PipelineMode', new_resource.pipeline_mode)
|
||||
|
||||
# add items
|
||||
if iis_version >= 7.0
|
||||
is_new_auto_start = new_value?(doc.root, 'APPPOOL/add/@autoStart', new_resource.auto_start.to_s)
|
||||
end
|
||||
|
||||
if iis_version > 7.0
|
||||
is_new_start_mode = new_value?(doc.root, 'APPPOOL/add/@startMode', new_resource.start_mode.to_s)
|
||||
end
|
||||
|
||||
is_new_queue_length = new_value?(doc.root, 'APPPOOL/add/@queueLength', new_resource.queue_length.to_s)
|
||||
is_new_enable_32_bit_app_on_win_64 = new_value?(doc.root, 'APPPOOL/add/@enable32BitAppOnWin64', new_resource.thirty_two_bit.to_s)
|
||||
|
||||
# processModel items
|
||||
is_new_max_processes = new_or_empty_value?(doc.root, 'APPPOOL/add/processModel/@maxProcesses', new_resource.max_proc.to_s)
|
||||
is_new_load_user_profile = new_value?(doc.root, 'APPPOOL/add/processModel/@loadUserProfile', new_resource.load_user_profile.to_s)
|
||||
if iis_version > 7.0
|
||||
is_new_identity_type = new_value?(doc.root, 'APPPOOL/add/processModel/@identityType', new_resource.pool_identity.to_s)
|
||||
end
|
||||
is_new_user_name = new_or_empty_value?(doc.root, 'APPPOOL/add/processModel/@userName', new_resource.pool_username.to_s)
|
||||
is_new_password = new_or_empty_value?(doc.root, 'APPPOOL/add/processModel/@password', new_resource.pool_password.to_s)
|
||||
if iis_version > 7.0
|
||||
is_new_logon_type = new_value?(doc.root, 'APPPOOL/add/processModel/@logonType', new_resource.logon_type.to_s)
|
||||
end
|
||||
is_new_manual_group_membership = new_value?(doc.root, 'APPPOOL/add/processModel/@manualGroupMembership', new_resource.manual_group_membership.to_s)
|
||||
is_new_idle_timeout = new_value?(doc.root, 'APPPOOL/add/processModel/@idleTimeout', new_resource.idle_timeout.to_s)
|
||||
if iis_version >= 8.5
|
||||
is_new_idle_timeout_action = new_value?(doc.root, 'APPPOOL/add/processModel/@idleTimeoutAction', new_resource.idle_timeout_action)
|
||||
end
|
||||
is_new_shutdown_time_limit = new_value?(doc.root, 'APPPOOL/add/processModel/@shutdownTimeLimit', new_resource.shutdown_time_limit.to_s)
|
||||
is_new_startup_time_limit = new_value?(doc.root, 'APPPOOL/add/processModel/@startupTimeLimit', new_resource.startup_time_limit.to_s)
|
||||
is_new_pinging_enabled = new_value?(doc.root, 'APPPOOL/add/processModel/@pingingEnabled', new_resource.pinging_enabled.to_s)
|
||||
is_new_ping_interval = new_value?(doc.root, 'APPPOOL/add/processModel/@pingInterval', new_resource.ping_interval.to_s)
|
||||
is_new_ping_response_time = new_value?(doc.root, 'APPPOOL/add/processModel/@pingResponseTime', new_resource.ping_response_time.to_s)
|
||||
|
||||
# failure items
|
||||
is_new_load_balancer_capabilities = new_value?(doc.root, 'APPPOOL/add/failure/@loadBalancerCapabilities', new_resource.load_balancer_capabilities.to_s)
|
||||
is_new_orphan_worker_process = new_value?(doc.root, 'APPPOOL/add/failure/@orphanWorkerProcess', new_resource.orphan_worker_process.to_s)
|
||||
is_new_orphan_action_exe = new_or_empty_value?(doc.root, 'APPPOOL/add/failure/@orphanActionExe', new_resource.orphan_action_exe.to_s)
|
||||
is_new_orphan_action_params = new_or_empty_value?(doc.root, 'APPPOOL/add/failure/@orphanActionParams', new_resource.orphan_action_params.to_s)
|
||||
is_new_rapid_fail_protection = new_value?(doc.root, 'APPPOOL/add/failure/@rapidFailProtection', new_resource.rapid_fail_protection.to_s)
|
||||
is_new_rapid_fail_protection_interval = new_value?(doc.root, 'APPPOOL/add/failure/@rapidFailProtectionInterval', new_resource.rapid_fail_protection_interval.to_s)
|
||||
is_new_rapid_fail_protection_max_crashes = new_value?(doc.root, 'APPPOOL/add/failure/@rapidFailProtectionMaxCrashes', new_resource.rapid_fail_protection_max_crashes.to_s)
|
||||
is_new_auto_shutdown_exe = new_or_empty_value?(doc.root, 'APPPOOL/add/failure/@autoShutdownExe', new_resource.auto_shutdown_exe.to_s)
|
||||
is_new_auto_shutdown_params = new_or_empty_value?(doc.root, 'APPPOOL/add/failure/@autoShutdownParams', new_resource.auto_shutdown_params.to_s)
|
||||
|
||||
# recycling items
|
||||
is_new_disallow_overlapping_rotation = new_value?(doc.root, 'APPPOOL/add/recycling/@disallowOverlappingRotation', new_resource.disallow_overlapping_rotation.to_s)
|
||||
is_new_disallow_rotation_on_config_change = new_value?(doc.root, 'APPPOOL/add/recycling/@disallowRotationOnConfigChange', new_resource.disallow_rotation_on_config_change.to_s)
|
||||
is_new_recycle_after_time = new_or_empty_value?(doc.root, 'APPPOOL/add/recycling/periodicRestart/@time', new_resource.recycle_after_time.to_s)
|
||||
is_new_recycle_at_time = new_or_empty_value?(doc.root, "APPPOOL/add/recycling/periodicRestart/schedule/add[@value='#{new_resource.recycle_at_time}']/@value", new_resource.recycle_at_time.to_s)
|
||||
is_new_private_memory = new_or_empty_value?(doc.root, 'APPPOOL/add/recycling/periodicRestart/@privateMemory', new_resource.private_mem.to_s)
|
||||
is_new_virtual_memory = new_or_empty_value?(doc.root, 'APPPOOL/add/recycling/periodicRestart/@memory', new_resource.virtual_mem.to_s)
|
||||
is_new_log_event_on_recycle = new_or_empty_value?(doc.root, 'APPPOOL/add/recycling/@logEventOnRecycle', new_resource.log_event_on_recycle.to_s)
|
||||
|
||||
# cpu items
|
||||
is_new_cpu_action = new_value?(doc.root, 'APPPOOL/add/cpu/@action', new_resource.cpu_action.to_s)
|
||||
is_new_cpu_limit = new_value?(doc.root, 'APPPOOL/add/cpu/@limit', new_resource.cpu_limit.to_s)
|
||||
is_new_cpu_smp_affinitized = new_value?(doc.root, 'APPPOOL/add/cpu/@smpAffinitized', new_resource.cpu_smp_affinitized.to_s)
|
||||
is_new_cpu_reset_interval = new_value?(doc.root, 'APPPOOL/add/cpu/@resetInterval', new_resource.cpu_reset_interval.to_s)
|
||||
is_new_smp_processor_affinity_mask = new_value?(doc.root, 'APPPOOL/add/cpu/@smpProcessorAffinityMask', new_resource.smp_processor_affinity_mask.floor)
|
||||
is_new_smp_processor_affinity_mask_2 = new_value?(doc.root, 'APPPOOL/add/cpu/@smpProcessorAffinityMask2', new_resource.smp_processor_affinity_mask_2.floor)
|
||||
|
||||
# Application Pool Config
|
||||
@cmd = "#{appcmd(node)} set config /section:applicationPools"
|
||||
|
||||
# root items
|
||||
if iis_version >= 7.0
|
||||
configure_application_pool(is_new_auto_start, "autoStart:#{new_resource.auto_start}")
|
||||
end
|
||||
|
||||
if iis_version >= 7.5
|
||||
configure_application_pool(is_new_start_mode, "startMode:#{new_resource.start_mode}")
|
||||
end
|
||||
|
||||
if new_resource.no_managed_code
|
||||
configure_application_pool(is_new_managed_runtime_version, 'managedRuntimeVersion:')
|
||||
else
|
||||
configure_application_pool(new_resource.runtime_version && is_new_managed_runtime_version, "managedRuntimeVersion:v#{new_resource.runtime_version}")
|
||||
end
|
||||
configure_application_pool(new_resource.pipeline_mode && is_new_pipeline_mode, "managedPipelineMode:#{new_resource.pipeline_mode}")
|
||||
configure_application_pool(is_new_enable_32_bit_app_on_win_64, "enable32BitAppOnWin64:#{new_resource.thirty_two_bit}")
|
||||
configure_application_pool(new_resource.queue_length && is_new_queue_length, "queueLength:#{new_resource.queue_length}")
|
||||
|
||||
# processModel items
|
||||
configure_application_pool(new_resource.max_proc && is_new_max_processes, "processModel.maxProcesses:#{new_resource.max_proc}")
|
||||
configure_application_pool(is_new_load_user_profile, "processModel.loadUserProfile:#{new_resource.load_user_profile}")
|
||||
configure_application_pool(is_new_logon_type, "processModel.logonType:#{new_resource.logon_type}")
|
||||
configure_application_pool(is_new_manual_group_membership, "processModel.manualGroupMembership:#{new_resource.manual_group_membership}")
|
||||
configure_application_pool(is_new_idle_timeout, "processModel.idleTimeout:#{new_resource.idle_timeout}")
|
||||
if iis_version >= 8.5
|
||||
configure_application_pool(is_new_idle_timeout_action, "processModel.idleTimeoutAction:#{new_resource.idle_timeout_action}")
|
||||
end
|
||||
configure_application_pool(is_new_shutdown_time_limit, "processModel.shutdownTimeLimit:#{new_resource.shutdown_time_limit}")
|
||||
configure_application_pool(is_new_startup_time_limit, "processModel.startupTimeLimit:#{new_resource.startup_time_limit}")
|
||||
configure_application_pool(is_new_pinging_enabled, "processModel.pingingEnabled:#{new_resource.pinging_enabled}")
|
||||
configure_application_pool(is_new_ping_interval, "processModel.pingInterval:#{new_resource.ping_interval}")
|
||||
configure_application_pool(is_new_ping_response_time, "processModel.pingResponseTime:#{new_resource.ping_response_time}")
|
||||
|
||||
node_array = XPath.match(doc.root, 'APPPOOL/add/recycling/periodicRestart/schedule/add')
|
||||
should_clear_apppool_schedules = ((new_resource.recycle_at_time && is_new_recycle_at_time) && !node_array.empty?) || (new_resource.recycle_schedule_clear && !node_array.empty?)
|
||||
|
||||
# recycling items
|
||||
## Special case this collection removal for now.
|
||||
if should_clear_apppool_schedules
|
||||
@was_updated = true
|
||||
is_new_recycle_at_time = true
|
||||
clear_pool_schedule_cmd = "#{appcmd(node)} set config /section:applicationPools \"/-[name='#{new_resource.pool_name}'].recycling.periodicRestart.schedule\""
|
||||
Chef::Log.debug(clear_pool_schedule_cmd)
|
||||
shell_out!(clear_pool_schedule_cmd)
|
||||
end
|
||||
|
||||
configure_application_pool(new_resource.recycle_after_time && is_new_recycle_after_time, "recycling.periodicRestart.time:#{new_resource.recycle_after_time}")
|
||||
configure_application_pool(new_resource.recycle_at_time && is_new_recycle_at_time, "recycling.periodicRestart.schedule.[value='#{new_resource.recycle_at_time}']", '+')
|
||||
configure_application_pool(new_resource.log_event_on_recycle && is_new_log_event_on_recycle, "recycling.logEventOnRecycle:#{new_resource.log_event_on_recycle}")
|
||||
configure_application_pool(new_resource.private_mem && is_new_private_memory, "recycling.periodicRestart.privateMemory:#{new_resource.private_mem}")
|
||||
configure_application_pool(new_resource.virtual_mem && is_new_virtual_memory, "recycling.periodicRestart.memory:#{new_resource.virtual_mem}")
|
||||
configure_application_pool(is_new_disallow_rotation_on_config_change, "recycling.disallowRotationOnConfigChange:#{new_resource.disallow_rotation_on_config_change}")
|
||||
configure_application_pool(is_new_disallow_overlapping_rotation, "recycling.disallowOverlappingRotation:#{new_resource.disallow_overlapping_rotation}")
|
||||
|
||||
# failure items
|
||||
configure_application_pool(is_new_load_balancer_capabilities, "failure.loadBalancerCapabilities:#{new_resource.load_balancer_capabilities}")
|
||||
configure_application_pool(is_new_orphan_worker_process, "failure.orphanWorkerProcess:#{new_resource.orphan_worker_process}")
|
||||
configure_application_pool(new_resource.orphan_action_exe && is_new_orphan_action_exe, "failure.orphanActionExe:#{new_resource.orphan_action_exe}")
|
||||
configure_application_pool(new_resource.orphan_action_params && is_new_orphan_action_params, "failure.orphanActionParams:#{new_resource.orphan_action_params}")
|
||||
configure_application_pool(is_new_rapid_fail_protection, "failure.rapidFailProtection:#{new_resource.rapid_fail_protection}")
|
||||
configure_application_pool(is_new_rapid_fail_protection_interval, "failure.rapidFailProtectionInterval:#{new_resource.rapid_fail_protection_interval}")
|
||||
configure_application_pool(is_new_rapid_fail_protection_max_crashes, "failure.rapidFailProtectionMaxCrashes:#{new_resource.rapid_fail_protection_max_crashes}")
|
||||
configure_application_pool(new_resource.auto_shutdown_exe && is_new_auto_shutdown_exe, "failure.autoShutdownExe:#{new_resource.auto_shutdown_exe}")
|
||||
configure_application_pool(new_resource.auto_shutdown_params && is_new_auto_shutdown_params, "failure.autoShutdownParams:#{new_resource.auto_shutdown_params}")
|
||||
|
||||
# cpu items
|
||||
configure_application_pool(is_new_cpu_action, "cpu.action:#{new_resource.cpu_action}")
|
||||
configure_application_pool(is_new_cpu_limit, "cpu.limit:#{new_resource.cpu_limit}")
|
||||
configure_application_pool(is_new_cpu_reset_interval, "cpu.resetInterval:#{new_resource.cpu_reset_interval}")
|
||||
configure_application_pool(is_new_cpu_smp_affinitized, "cpu.smpAffinitized:#{new_resource.cpu_smp_affinitized}")
|
||||
configure_application_pool(is_new_smp_processor_affinity_mask, "cpu.smpProcessorAffinityMask:#{new_resource.smp_processor_affinity_mask.floor}")
|
||||
configure_application_pool(is_new_smp_processor_affinity_mask_2, "cpu.smpProcessorAffinityMask2:#{new_resource.smp_processor_affinity_mask_2.floor}")
|
||||
|
||||
if @cmd != "#{appcmd(node)} set config /section:applicationPools"
|
||||
Chef::Log.debug(@cmd)
|
||||
shell_out!(@cmd)
|
||||
end
|
||||
|
||||
# Application Pool Identity Settings
|
||||
if (new_resource.pool_username && new_resource.pool_username != '') && (is_new_user_name || is_new_password)
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set config /section:applicationPools"
|
||||
cmd << " \"/[name='#{new_resource.pool_name}'].processModel.identityType:SpecificUser\""
|
||||
cmd << " \"/[name='#{new_resource.pool_name}'].processModel.userName:#{new_resource.pool_username}\""
|
||||
cmd << " \"/[name='#{new_resource.pool_name}'].processModel.password:#{new_resource.pool_password}\"" if new_resource.pool_password && new_resource.pool_password != '' && is_new_password
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
elsif (new_resource.pool_username.nil? || new_resource.pool_username == '') &&
|
||||
(new_resource.pool_password.nil? || new_resource.pool_username == '') &&
|
||||
(is_new_identity_type && new_resource.pool_identity != 'SpecificUser')
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set config /section:applicationPools"
|
||||
cmd << " \"/[name='#{new_resource.pool_name}'].processModel.identityType:#{new_resource.pool_identity}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if @was_updated
|
||||
Chef::Log.info("#{new_resource} configured application pool")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} application pool - nothing to do")
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_pool action :config, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
|
||||
@was_updated
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def configure_application_pool(condition, config, add_remove = '')
|
||||
return unless condition
|
||||
|
||||
@was_updated = true
|
||||
@cmd << " \"/#{add_remove}[name='#{new_resource.pool_name}'].#{config}\""
|
||||
end
|
||||
@@ -1,68 +0,0 @@
|
||||
#
|
||||
# Author:: Justin Schuhmann (<jmschu02@gmail.com>)
|
||||
# Cookbook:: iis
|
||||
# Provider:: root
|
||||
#
|
||||
# Copyright:: 2016, Justin Schuhmann
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :add do
|
||||
@was_updated = false
|
||||
|
||||
@was_updated = default_documents(new_resource.add_default_documents, new_resource.default_documents_enabled, true, false) | @was_updated
|
||||
@was_updated = mime_maps(new_resource.add_mime_maps, true, false) | @was_updated
|
||||
|
||||
if @was_updated
|
||||
new_resource.updated_by_last_action(true)
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
@was_updated = false
|
||||
|
||||
@was_updated = default_documents(new_resource.delete_default_documents, new_resource.default_documents_enabled, false) | @was_updated
|
||||
@was_updated = mime_maps(new_resource.delete_mime_maps, false) | @was_updated
|
||||
|
||||
if @was_updated
|
||||
new_resource.updated_by_last_action(true)
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
@was_updated = false
|
||||
|
||||
@was_updated = default_documents(new_resource.default_documents, new_resource.default_documents_enabled) | @was_updated
|
||||
@was_updated = mime_maps(new_resource.mime_maps) | @was_updated
|
||||
|
||||
if @was_updated
|
||||
new_resource.updated_by_last_action(true)
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisRoot.new(new_resource.name)
|
||||
@current_resource.default_documents(new_resource.default_documents)
|
||||
@current_resource.default_documents_enabled(new_resource.default_documents_enabled)
|
||||
@current_resource.mime_maps(new_resource.mime_maps)
|
||||
end
|
||||
@@ -1,72 +0,0 @@
|
||||
#
|
||||
# Author:: Justin Schuhmann
|
||||
# Cookbook:: iis
|
||||
# Resource:: lock
|
||||
#
|
||||
# Copyright:: 2016, Justin Schuhmann
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'rexml/document'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :lock do
|
||||
@current_resource.exists = new_value?(doc.root, 'CONFIG/@overrideMode', 'Deny')
|
||||
|
||||
if @current_resource.exists
|
||||
cmd = "#{appcmd(node)} lock config -section:\"#{new_resource.section}\" -commit:apphost"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: new_resource.returns)
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info('IIS Config command run')
|
||||
else
|
||||
Chef::Log.debug("#{new_resource.section} already locked - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :unlock do
|
||||
@current_resource.exists = new_value?(doc.root, 'CONFIG/@overrideMode', 'Allow')
|
||||
|
||||
if @current_resource.exists
|
||||
cmd = "#{appcmd(node)} unlock config -section:\"#{new_resource.section}\" -commit:apphost"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: new_resource.returns)
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info('IIS Config command run')
|
||||
else
|
||||
Chef::Log.debug("#{new_resource.section} already unlocked - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisSection.new(new_resource.section)
|
||||
@current_resource.section(new_resource.section)
|
||||
end
|
||||
|
||||
def doc
|
||||
cmd_current_values = "#{appcmd(node)} list config -section:#{new_resource.section} /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
return Document.new(xml)
|
||||
end
|
||||
|
||||
cmd_current_values.error!
|
||||
end
|
||||
@@ -1,226 +0,0 @@
|
||||
#
|
||||
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
||||
# Cookbook:: iis
|
||||
# Provider:: site
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'rexml/document'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :add do
|
||||
if !@current_resource.exists
|
||||
cmd = "#{appcmd(node)} add site /name:\"#{new_resource.site_name}\""
|
||||
cmd << " /id:#{new_resource.site_id}" if new_resource.site_id
|
||||
cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.path)}\"" if new_resource.path
|
||||
if new_resource.bindings
|
||||
cmd << " /bindings:\"#{new_resource.bindings}\""
|
||||
else
|
||||
cmd << " /bindings:#{new_resource.protocol}/*"
|
||||
cmd << ":#{new_resource.port}:" if new_resource.port
|
||||
cmd << new_resource.host_header if new_resource.host_header
|
||||
end
|
||||
|
||||
# support for additional options -logDir, -limits, -ftpServer, etc...
|
||||
cmd << " #{new_resource.options}" if new_resource.options
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
|
||||
configure
|
||||
|
||||
if new_resource.application_pool
|
||||
shell_out!("#{appcmd(node)} set site /site.name:\"#{new_resource.site_name}\" /[path='/'].applicationPool:\"#{new_resource.application_pool}\"", returns: [0, 42])
|
||||
end
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} added new site '#{new_resource.site_name}'")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} site already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
new_resource.updated_by_last_action(true) if configure
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if @current_resource.exists
|
||||
Chef::Log.info("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"")
|
||||
shell_out!("#{appcmd(node)} delete site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} site does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :start do
|
||||
if !@current_resource.running
|
||||
shell_out!("#{appcmd(node)} start site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} started")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already running - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
if @current_resource.running
|
||||
Chef::Log.info("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"")
|
||||
shell_out!("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} stopped")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already stopped - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
shell_out!("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
sleep 2
|
||||
shell_out!("#{appcmd(node)} start site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} restarted")
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisSite.new(new_resource.name)
|
||||
@current_resource.site_name(new_resource.site_name)
|
||||
cmd = shell_out("#{appcmd(node)} list site")
|
||||
Chef::Log.debug(appcmd(node))
|
||||
# 'SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)'
|
||||
Chef::Log.debug("#{new_resource} list site command output: #{cmd.stdout}")
|
||||
if cmd.stderr.empty?
|
||||
result = cmd.stdout.gsub(/\r\n?/, "\n") # ensure we have no carriage returns
|
||||
result = result.match(/^SITE\s\"(#{new_resource.site_name})\"\s\(id:(.*),bindings:(.*),state:(.*)\)$/i)
|
||||
Chef::Log.debug("#{new_resource} current_resource match output: #{result}")
|
||||
if result
|
||||
@current_resource.site_id(result[2].to_i)
|
||||
@current_resource.exists = true
|
||||
@current_resource.bindings(result[3])
|
||||
@current_resource.running = result[4] =~ /Started/ ? true : false
|
||||
else
|
||||
@current_resource.exists = false
|
||||
@current_resource.running = false
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_site action :config, #{cmd.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def configure
|
||||
@was_updated = false
|
||||
cmd_current_values = "#{appcmd(node)} list site \"#{new_resource.site_name}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
is_new_bindings = new_value?(doc.root, 'SITE/@bindings', new_resource.bindings.to_s)
|
||||
is_new_physical_path = new_or_empty_value?(doc.root, 'SITE/site/application/virtualDirectory/@physicalPath', new_resource.path.to_s)
|
||||
is_new_port_host_provided = !"#{XPath.first(doc.root, 'SITE/@bindings')},".include?("#{new_resource.protocol}/*:#{new_resource.port}:#{new_resource.host_header},")
|
||||
is_new_site_id = new_value?(doc.root, 'SITE/site/@id', new_resource.site_id.to_s)
|
||||
is_new_log_directory = new_or_empty_value?(doc.root, 'SITE/site/logFile/@directory', new_resource.log_directory.to_s)
|
||||
is_new_log_period = new_or_empty_value?(doc.root, 'SITE/site/logFile/@period', new_resource.log_period.to_s)
|
||||
is_new_log_trunc = new_or_empty_value?(doc.root, 'SITE/site/logFile/@truncateSize', new_resource.log_truncsize.to_s)
|
||||
is_new_application_pool = new_value?(doc.root, 'SITE/site/application/@applicationPool', new_resource.application_pool)
|
||||
|
||||
if new_resource.bindings && is_new_bindings
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site /site.name:\"#{new_resource.site_name}\""
|
||||
cmd << " /bindings:\"#{new_resource.bindings}\""
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
elsif ((new_resource.port || new_resource.host_header || new_resource.protocol) && is_new_port_host_provided) && !new_resource.bindings
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /bindings:#{new_resource.protocol}/*:#{new_resource.port}:#{new_resource.host_header}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
if new_resource.application_pool && is_new_application_pool
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set app \"#{new_resource.site_name}/\" /applicationPool:\"#{new_resource.application_pool}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
end
|
||||
|
||||
if new_resource.path && is_new_physical_path
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{new_resource.site_name}/\""
|
||||
cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.path)}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if new_resource.site_id && is_new_site_id
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /id:#{new_resource.site_id}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
if new_resource.log_directory && is_new_log_directory
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.directory:#{windows_cleanpath(new_resource.log_directory)}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
if new_resource.log_period && is_new_log_period
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.period:#{new_resource.log_period}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
if new_resource.log_truncsize && is_new_log_trunc
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.truncateSize:#{new_resource.log_truncsize}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
new_resource.updated_by_last_action(true)
|
||||
end
|
||||
|
||||
if @was_updated
|
||||
Chef::Log.info("#{new_resource} configured site '#{new_resource.site_name}'")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} site - nothing to do")
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_site action :config, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
|
||||
@was_updated
|
||||
end
|
||||
@@ -1,155 +0,0 @@
|
||||
#
|
||||
# Author:: Justin Schuhmann (<jmschu02@gmail.com>)
|
||||
# Cookbook:: iis
|
||||
# Provider:: site
|
||||
#
|
||||
# Copyright:: 2016, Justin Schuhmann
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'chef/mixin/shell_out'
|
||||
require 'rexml/document'
|
||||
|
||||
include Chef::Mixin::ShellOut
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
action :add do
|
||||
if !@current_resource.exists
|
||||
cmd = "#{appcmd(node)} add vdir /app.name:\"#{new_resource.application_name}\""
|
||||
cmd << " /path:\"#{new_resource.path}\""
|
||||
cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.physical_path)}\""
|
||||
cmd << " /userName:\"#{new_resource.username}\"" if new_resource.username
|
||||
cmd << " /password:\"#{new_resource.password}\"" if new_resource.password
|
||||
cmd << " /logonMethod:#{new_resource.logon_method}" if new_resource.logon_method
|
||||
cmd << " /allowSubDirConfig:#{new_resource.allow_sub_dir_config}" if new_resource.allow_sub_dir_config
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
|
||||
Chef::Log.info(cmd)
|
||||
shell_out!(cmd, returns: [0, 42, 183])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} added new virtual directory to application: '#{new_resource.application_name}'")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} virtual directory already exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
@was_updated = false
|
||||
cmd_current_values = "#{appcmd(node)} list vdir \"#{application_identifier}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out!(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
is_new_physical_path = new_or_empty_value?(doc.root, 'VDIR/@physicalPath', new_resource.physical_path.to_s)
|
||||
is_new_user_name = new_or_empty_value?(doc.root, 'VDIR/virtualDirectory/@userName', new_resource.username.to_s)
|
||||
is_new_password = new_or_empty_value?(doc.root, 'VDIR/virtualDirectory/@password', new_resource.password.to_s)
|
||||
is_new_logon_method = new_or_empty_value?(doc.root, 'VDIR/virtualDirectory/@logonMethod', new_resource.logon_method.to_s)
|
||||
is_new_allow_sub_dir_config = new_or_empty_value?(doc.root, 'VDIR/virtualDirectory/@allowSubDirConfig', new_resource.allow_sub_dir_config.to_s)
|
||||
|
||||
if new_resource.physical_path && is_new_physical_path
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\" /physicalPath:\"#{new_resource.physical_path}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if new_resource.username && is_new_user_name
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\" /userName:\"#{new_resource.username}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if new_resource.password && is_new_password
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\" /password:\"#{new_resource.password}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if new_resource.logon_method && is_new_logon_method
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\" /logonMethod:#{new_resource.logon_method}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if new_resource.allow_sub_dir_config && is_new_allow_sub_dir_config
|
||||
@was_updated = true
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\" /allowSubDirConfig:#{new_resource.allow_sub_dir_config}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
if @was_updated
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} configured virtual directory to application: '#{new_resource.application_name}'")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} virtual directory - nothing to do")
|
||||
end
|
||||
else
|
||||
log "Failed to run iis_vdir action :config, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if @current_resource.exists
|
||||
shell_out!("#{appcmd(node)} delete vdir \"#{application_identifier}\"", returns: [0, 42])
|
||||
new_resource.updated_by_last_action(true)
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} virtual directory does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
@current_resource = Chef::Resource::IisVdir.new(new_resource.name)
|
||||
@current_resource.application_name(application_name_check)
|
||||
@current_resource.path(new_resource.path)
|
||||
@current_resource.physical_path(new_resource.physical_path)
|
||||
cmd = shell_out("#{appcmd(node)} list vdir \"#{application_identifier}\"")
|
||||
Chef::Log.debug("#{new_resource} list vdir command output: #{cmd.stdout}")
|
||||
|
||||
if cmd.stderr.empty?
|
||||
# VDIR "Testfu Site/Content/Test"
|
||||
result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(application_identifier)}\"/)
|
||||
Chef::Log.debug("#{new_resource} current_resource match output: #{result}")
|
||||
@current_resource.exists = result
|
||||
else
|
||||
log "Failed to run iis_vdir action :load_current_resource, #{cmd_current_values.stderr}" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def application_identifier
|
||||
new_resource.application_name.chomp('/') + new_resource.path
|
||||
end
|
||||
|
||||
def application_name_check
|
||||
if !new_resource.application_name.include?('/') && !new_resource.application_name.end_with?('/')
|
||||
new_resource.application_name("#{new_resource.application_name}/")
|
||||
elsif new_resource.application_name.chomp('/').include?('/') && new_resource.application_name.end_with?('/')
|
||||
new_resource.application_name(new_resource.application_name.chomp('/'))
|
||||
else
|
||||
new_resource.application_name
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com>)
|
||||
# Cookbook:: iis
|
||||
# Resource:: app
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
# Copyright:: 2011-2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,15 +17,130 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :delete, :config
|
||||
require 'rexml/document'
|
||||
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
|
||||
property :site_name, String, name_property: true
|
||||
property :path, String, default: '/'
|
||||
property :application_pool, String
|
||||
property :physical_path, String
|
||||
property :enabled_protocols, String
|
||||
|
||||
default_action :add
|
||||
|
||||
attribute :site_name, kind_of: String, name_attribute: true
|
||||
attribute :path, kind_of: String, default: '/'
|
||||
attribute :application_pool, kind_of: String
|
||||
attribute :physical_path, kind_of: String
|
||||
attribute :enabled_protocols, kind_of: String
|
||||
attribute :default_documents, kind_of: Array, default: []
|
||||
attribute :mime_maps, kind_of: Array, default: []
|
||||
load_current_value do |desired|
|
||||
site_name desired.site_name
|
||||
# Sanitize physical path
|
||||
desired.physical_path = windows_cleanpath(desired.physical_path) if desired.physical_path
|
||||
cmd = shell_out("#{appcmd(node)} list app \"#{desired.site_name}#{desired.path}\"")
|
||||
Chef::Log.debug("#{appcmd(node)} list app command output: #{cmd.stdout}")
|
||||
if cmd.stderr.empty?
|
||||
Chef::Log.debug('Running regex')
|
||||
regex = /^APP\s\"#{desired.site_name}#{desired.path}\"/
|
||||
result = cmd.stdout.match(regex)
|
||||
Chef::Log.debug("#{desired} current_resource match output: #{result}")
|
||||
if !result.nil?
|
||||
cmd_current_values = "#{appcmd(node)} list app \"#{desired.site_name}#{desired.path}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
path value doc.root, 'APP/application/@path'
|
||||
application_pool value doc.root, 'APP/application/@applicationPool'
|
||||
enabled_protocols value doc.root, 'APP/application/@enabledProtocols'
|
||||
physical_path windows_cleanpath(value(doc.root, 'APP/application/virtualDirectory/@physicalPath'))
|
||||
end
|
||||
else
|
||||
path ''
|
||||
end
|
||||
else
|
||||
Chef::Log.warn "Failed to run iis_app action :load_current_resource, #{cmd_current_values.stderr}"
|
||||
end
|
||||
end
|
||||
|
||||
attr_accessor :exists, :running
|
||||
action :add do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource.inspect} app already exists - nothing to do")
|
||||
else
|
||||
converge_by "Creating the Application - \"#{new_resource}\"" do
|
||||
cmd = "#{appcmd(node)} add app /site.name:\"#{new_resource.site_name}\""
|
||||
cmd << " /path:\"#{new_resource.path}\""
|
||||
cmd << " /applicationPool:\"#{new_resource.application_pool}\"" if new_resource.application_pool
|
||||
cmd << " /physicalPath:\"#{new_resource.physical_path}\"" if new_resource.physical_path
|
||||
cmd << " /enabledProtocols:\"#{new_resource.enabled_protocols}\"" if new_resource.enabled_protocols
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
if exists
|
||||
# only get the beginning of the command if there is something that changes
|
||||
cmd = cmd_set_app
|
||||
converge_if_changed :path do
|
||||
# adds path to the cmd
|
||||
cmd << " /path:\"#{new_resource.path}\"" if new_resource.path
|
||||
end
|
||||
converge_if_changed :application_pool do
|
||||
# adds applicationPool to the cmd
|
||||
cmd << " /applicationPool:\"#{new_resource.application_pool}\"" if new_resource.application_pool
|
||||
end
|
||||
converge_if_changed :enabled_protocols do
|
||||
# adds enabledProtocols to the cmd
|
||||
cmd << " /enabledProtocols:\"#{new_resource.enabled_protocols}\"" if new_resource.enabled_protocols
|
||||
end
|
||||
Chef::Log.debug(cmd)
|
||||
|
||||
if cmd == cmd_set_app
|
||||
Chef::Log.debug("#{new_resource.inspect} application - nothing to do")
|
||||
else
|
||||
converge_by "Updating the Application - \"#{new_resource}\"" do
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
converge_if_changed :physical_path do
|
||||
cmd = "#{appcmd(node)} set vdir /vdir.name:\"#{vdir_identifier}\""
|
||||
cmd << " /physicalPath:\"#{new_resource.physical_path}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource.inspect} app needs to be added - cannot configure non-existent items")
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists
|
||||
converge_by "Deleting the Application - \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} delete app \"#{site_identifier}\"")
|
||||
Chef::Log.info("#{new_resource} deleted")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource.inspect} app does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def exists
|
||||
!current_resource.path.empty?
|
||||
end
|
||||
|
||||
def cmd_set_app
|
||||
"#{appcmd(node)} set app \"#{site_identifier}\""
|
||||
end
|
||||
|
||||
def site_identifier
|
||||
"#{new_resource.site_name}#{new_resource.path}"
|
||||
end
|
||||
|
||||
# Ensure VDIR identifier has a trailing slash
|
||||
def vdir_identifier
|
||||
site_identifier.end_with?('/') ? site_identifier : site_identifier + '/'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com)
|
||||
# Cookbook:: iis
|
||||
# Resource:: config
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +17,28 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :config, :clear, :set
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
property :cfg_cmd, String, name_attribute: true
|
||||
property :returns, [Integer, Array], default: 0
|
||||
|
||||
default_action :set
|
||||
|
||||
attribute :cfg_cmd, kind_of: String, name_attribute: true
|
||||
attribute :returns, kind_of: [Integer, Array], default: 0
|
||||
action :set do
|
||||
config
|
||||
end
|
||||
|
||||
action :clear do
|
||||
config(:clear)
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def config(action = :set)
|
||||
converge_by "Executing IIS Config #{action}" do
|
||||
cmd = "#{appcmd(node)} #{action} config #{new_resource.cfg_cmd}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: new_resource.returns)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Jon DeCamp (<jon.decamp@nordstrom.com>)
|
||||
# Cookbook:: iis
|
||||
# Resource:: module
|
||||
#
|
||||
# Copyright:: 2012-2016, Nordstrom, Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,14 +17,119 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :delete, :install, :uninstall
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
include Opscode::IIS::SectionHelper
|
||||
|
||||
property :module_name, String, name_property: true
|
||||
property :type, String
|
||||
property :add, [true, false], default: false
|
||||
property :image, String
|
||||
property :precondition, String
|
||||
property :application, String
|
||||
property :previous_lock, String
|
||||
|
||||
default_action :add
|
||||
|
||||
attribute :module_name, kind_of: String, name_attribute: true
|
||||
attribute :type, kind_of: String, default: nil
|
||||
attribute :add, kind_of: [FalseClass, TrueClass], default: nil
|
||||
attribute :image, kind_of: String, default: nil
|
||||
attribute :precondition, kind_of: String, default: nil
|
||||
attribute :application, kind_of: String, default: nil
|
||||
load_current_value do |desired|
|
||||
module_name desired.module_name
|
||||
application desired.application if desired.application
|
||||
# Sanitize Image Path (file system path)
|
||||
desired.image = windows_cleanpath(desired.image) if desired.image
|
||||
cmd = "#{appcmd(node)} list module /module.name:\"#{desired.module_name}\""
|
||||
cmd << " /app.name:\"#{desired.application}\"" if desired.application
|
||||
|
||||
attr_accessor :exists
|
||||
cmd_result = shell_out cmd
|
||||
# 'MODULE "Module Name" ( type:module.type, preCondition:condition )'
|
||||
# 'MODULE "Module Name" ( native, preCondition:condition )'
|
||||
|
||||
Chef::Log.debug("#{desired.name} list module command output: #{cmd_result.stdout}")
|
||||
unless cmd_result.stdout.empty?
|
||||
previous_lock get_current_lock(node, 'system.webServer/modules', desired.application)
|
||||
cmd = "#{appcmd(node)} list module /module.name:\"#{desired.module_name}\""
|
||||
cmd << " /app.name:\"#{desired.application}\"" if desired.application
|
||||
cmd << ' /config:* /xml'
|
||||
cmd_result = shell_out cmd
|
||||
if cmd_result.stderr.empty?
|
||||
xml = cmd_result.stdout
|
||||
doc = Document.new(xml)
|
||||
type value doc.root, 'MODULE/@type'
|
||||
precondition value doc.root, 'MODULE/@preCondition'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# appcmd syntax for adding modules
|
||||
# appcmd add module /name:string /type:string /preCondition:string
|
||||
action :add do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource} module already exists - nothing to do")
|
||||
else
|
||||
converge_by("add IIS module #{new_resource.module_name}") do
|
||||
unlock(node, 'system.webServer/modules', new_resource.application)
|
||||
cmd = "#{appcmd(node)} add module /module.name:\"#{new_resource.module_name}\""
|
||||
cmd << " /app.name:\"#{new_resource.application}\"" if new_resource.application
|
||||
cmd << " /type:\"#{new_resource.type}\"" if new_resource.type
|
||||
cmd << " /preCondition:\"#{new_resource.precondition}\"" if new_resource.precondition
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
override_mode(node, current_resource.previous_lock, 'system.webServer/modules', new_resource.application)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists
|
||||
converge_by("delete IIS module #{new_resource.module_name}") do
|
||||
unlock(node, 'system.webServer/modules', new_resource.application)
|
||||
cmd = "#{appcmd(node)} delete module /module.name:\"#{new_resource.module_name}\""
|
||||
cmd << " /app.name:\"#{new_resource.application}\"" if new_resource.application
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
override_mode(node, current_resource.previous_lock, 'system.webServer/modules', new_resource.application)
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
# appcmd syntax for installing native modules
|
||||
# appcmd install module /name:string /add:string(true|false) /image:string
|
||||
action :install do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource} module already exists - nothing to do")
|
||||
else
|
||||
converge_by("install IIS module #{new_resource.module_name}") do
|
||||
unlock(node, 'system.webServer/modules', new_resource.application)
|
||||
cmd = "#{appcmd(node)} install module /name:\"#{new_resource.module_name}\""
|
||||
cmd << " /add:\"#{new_resource.add}\"" unless new_resource.add.nil?
|
||||
cmd << " /image:\"#{new_resource.image}\"" if new_resource.image
|
||||
cmd << " /preCondition:\"#{new_resource.precondition}\"" if new_resource.precondition
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
override_mode(node, current_resource.previous_lock, 'system.webServer/modules', new_resource.application)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# appcmd syntax for uninstalling native modules
|
||||
# appcmd uninstall module <name>
|
||||
action :uninstall do
|
||||
if exists
|
||||
converge_by("uninstall IIS module #{new_resource.module_name}") do
|
||||
unlock(node, 'system.webServer/modules', new_resource.application)
|
||||
cmd = "#{appcmd(node)} uninstall module \"#{new_resource.module_name}\""
|
||||
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
override_mode(node, current_resource.previous_lock, 'system.webServer/modules', new_resource.application)
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} module does not exists - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def exists
|
||||
current_resource.type ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (kendrick.martin@webtrends.com>)
|
||||
# Contributor:: David Dvorak (david.dvorak@webtrends.com)
|
||||
# Cookbook:: iis
|
||||
# Resource:: pool
|
||||
#
|
||||
# Copyright:: 2011-2016, Webtrends Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -19,64 +17,435 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :config, :delete, :start, :stop, :restart, :recycle
|
||||
default_action :add
|
||||
require 'rexml/document'
|
||||
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
# root
|
||||
attribute :pool_name, kind_of: String, name_attribute: true
|
||||
attribute :no_managed_code, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :pipeline_mode, kind_of: Symbol, equal_to: [:Integrated, :Classic]
|
||||
attribute :runtime_version, kind_of: String
|
||||
property :name, String, name_property: true
|
||||
property :no_managed_code, [true, false], default: false
|
||||
property :pipeline_mode, [Symbol, String], equal_to: [:Integrated, :Classic], coerce: proc { |v| v.to_sym }
|
||||
property :runtime_version, String
|
||||
|
||||
# add items
|
||||
attribute :start_mode, kind_of: Symbol, equal_to: [:AlwaysRunning, :OnDemand], default: :OnDemand
|
||||
attribute :auto_start, kind_of: [TrueClass, FalseClass], default: true
|
||||
attribute :queue_length, kind_of: Integer, default: 1000
|
||||
attribute :thirty_two_bit, kind_of: [TrueClass, FalseClass], default: false
|
||||
property :start_mode, [Symbol, String], equal_to: [:AlwaysRunning, :OnDemand], default: :OnDemand, coerce: proc { |v| v.to_sym }
|
||||
property :auto_start, [true, false], default: true
|
||||
property :queue_length, Integer, default: 1000, coerce: proc { |v| v.to_i }
|
||||
property :thirty_two_bit, [true, false], default: false
|
||||
|
||||
# processModel items
|
||||
attribute :max_proc, kind_of: Integer
|
||||
attribute :load_user_profile, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :pool_identity, kind_of: Symbol, equal_to: [:SpecificUser, :NetworkService, :LocalService, :LocalSystem, :ApplicationPoolIdentity], default: :ApplicationPoolIdentity
|
||||
attribute :pool_username, kind_of: String
|
||||
attribute :pool_password, kind_of: String
|
||||
attribute :logon_type, kind_of: Symbol, equal_to: [:LogonBatch, :LogonService], default: :LogonBatch
|
||||
attribute :manual_group_membership, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :idle_timeout, kind_of: String, default: '00:20:00'
|
||||
attribute :idle_timeout_action, kind_of: Symbol, equal_to: [:Terminate, :Suspend], default: :Terminate
|
||||
attribute :shutdown_time_limit, kind_of: String, default: '00:01:30'
|
||||
attribute :startup_time_limit, kind_of: String, default: '00:01:30'
|
||||
attribute :pinging_enabled, kind_of: [TrueClass, FalseClass], default: true
|
||||
attribute :ping_interval, kind_of: String, default: '00:00:30'
|
||||
attribute :ping_response_time, kind_of: String, default: '00:01:30'
|
||||
property :max_processes, Integer, coerce: proc { |v| v.to_i }
|
||||
property :load_user_profile, [true, false], default: false
|
||||
property :identity_type, [Symbol, String], equal_to: [:SpecificUser, :NetworkService, :LocalService, :LocalSystem, :ApplicationPoolIdentity], default: :ApplicationPoolIdentity, coerce: proc { |v| v.to_sym }
|
||||
property :username, String
|
||||
property :password, String
|
||||
property :logon_type, [Symbol, String], equal_to: [:LogonBatch, :LogonService], default: :LogonBatch, coerce: proc { |v| v.to_sym }
|
||||
property :manual_group_membership, [true, false], default: false
|
||||
property :idle_timeout, String, default: '00:20:00'
|
||||
property :idle_timeout_action, [Symbol, String], equal_to: [:Terminate, :Suspend], default: :Terminate, coerce: proc { |v| v.to_sym }
|
||||
property :shutdown_time_limit, String, default: '00:01:30'
|
||||
property :startup_time_limit, String, default: '00:01:30'
|
||||
property :pinging_enabled, [true, false], default: true
|
||||
property :ping_interval, String, default: '00:00:30'
|
||||
property :ping_response_time, String, default: '00:01:30'
|
||||
|
||||
# recycling items
|
||||
attribute :disallow_rotation_on_config_change, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :disallow_overlapping_rotation, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :recycle_schedule_clear, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :log_event_on_recycle, kind_of: String, default: node['iis']['recycle']['log_events']
|
||||
attribute :recycle_after_time, kind_of: String
|
||||
attribute :recycle_at_time, kind_of: String
|
||||
attribute :private_mem, kind_of: Integer
|
||||
attribute :virtual_mem, kind_of: Integer
|
||||
property :disallow_rotation_on_config_change, [true, false], default: false
|
||||
property :disallow_overlapping_rotation, [true, false], default: false
|
||||
property :recycle_schedule_clear, [true, false], default: false
|
||||
property :log_event_on_recycle, String, default: node['iis']['recycle']['log_events']
|
||||
property :recycle_after_time, String
|
||||
property :recycle_at_time, String
|
||||
property :private_memory, Integer, coerce: proc { |v| v.to_i }
|
||||
property :virtual_memory, Integer, coerce: proc { |v| v.to_i }
|
||||
|
||||
# failure items
|
||||
attribute :load_balancer_capabilities, kind_of: Symbol, equal_to: [:HttpLevel, :TcpLevel], default: :HttpLevel
|
||||
attribute :orphan_worker_process, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :orphan_action_exe, kind_of: String
|
||||
attribute :orphan_action_params, kind_of: String
|
||||
attribute :rapid_fail_protection, kind_of: [TrueClass, FalseClass], default: true
|
||||
attribute :rapid_fail_protection_interval, kind_of: String, default: '00:05:00'
|
||||
attribute :rapid_fail_protection_max_crashes, kind_of: Integer, default: 5
|
||||
attribute :auto_shutdown_exe, kind_of: String
|
||||
attribute :auto_shutdown_params, kind_of: String
|
||||
property :load_balancer_capabilities, [Symbol, String], equal_to: [:HttpLevel, :TcpLevel], default: :HttpLevel, coerce: proc { |v| v.to_sym }
|
||||
property :orphan_worker_process, [true, false], default: false
|
||||
property :orphan_action_exe, String
|
||||
property :orphan_action_params, String
|
||||
property :rapid_fail_protection, [true, false], default: true
|
||||
property :rapid_fail_protection_interval, String, default: '00:05:00'
|
||||
property :rapid_fail_protection_max_crashes, Integer, default: 5, coerce: proc { |v| v.to_i }
|
||||
property :auto_shutdown_exe, String
|
||||
property :auto_shutdown_params, String
|
||||
|
||||
# cpu items
|
||||
attribute :cpu_action, kind_of: Symbol, equal_to: [:NoAction, :KillW3wp, :Throttle, :ThrottleUnderLoad], default: :NoAction
|
||||
attribute :cpu_limit, kind_of: Integer, default: 0
|
||||
attribute :cpu_reset_interval, kind_of: String, default: '00:05:00'
|
||||
attribute :cpu_smp_affinitized, kind_of: [TrueClass, FalseClass], default: false
|
||||
attribute :smp_processor_affinity_mask, kind_of: Float, default: 4_294_967_295.0
|
||||
attribute :smp_processor_affinity_mask_2, kind_of: Float, default: 4_294_967_295.0
|
||||
property :cpu_action, [Symbol, String], equal_to: [:NoAction, :KillW3wp, :Throttle, :ThrottleUnderLoad], default: :NoAction, coerce: proc { |v| v.to_sym }
|
||||
property :cpu_limit, Integer, default: 0, coerce: proc { |v| v.to_i }
|
||||
property :cpu_reset_interval, String, default: '00:05:00'
|
||||
property :cpu_smp_affinitized, [true, false], default: false
|
||||
property :smp_processor_affinity_mask, Float, default: 4_294_967_295.0, coerce: proc { |v| v.to_f }
|
||||
property :smp_processor_affinity_mask_2, Float, default: 4_294_967_295.0, coerce: proc { |v| v.to_f }
|
||||
|
||||
attr_accessor :exists, :running
|
||||
# internally used for the state of the pool [Starting, Started, Stopping, Stopped, Unknown, Undefined value]
|
||||
property :running, [true, false], desired_state: true
|
||||
|
||||
default_action :add
|
||||
|
||||
load_current_value do |desired|
|
||||
name desired.name
|
||||
cmd = shell_out("#{appcmd(node)} list apppool \"#{desired.name}\"")
|
||||
# APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started)
|
||||
Chef::Log.debug("#{desired} list apppool command output: #{cmd.stdout}")
|
||||
unless cmd.stderr.empty?
|
||||
Chef::Log.warn "Failed to run iis_pool action :load_current_resource, #{cmd.stderr}"
|
||||
return
|
||||
end
|
||||
|
||||
result = cmd.stdout.gsub(/\r\n?/, "\n") # ensure we have no carriage returns
|
||||
result = result.match(/^APPPOOL\s\"(#{desired.name})\"\s\(MgdVersion:(.*),MgdMode:(.*),state:(.*)\)$/i)
|
||||
Chef::Log.debug("#{desired} current_resource match output: #{result}")
|
||||
unless result
|
||||
running false
|
||||
return
|
||||
end
|
||||
|
||||
running result[4] =~ /Started/ ? true : false
|
||||
cmd_current_values = "#{appcmd(node)} list apppool \"#{desired.name}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd_current_values)
|
||||
cmd_current_values = shell_out(cmd_current_values)
|
||||
if cmd_current_values.stderr.empty?
|
||||
xml = cmd_current_values.stdout
|
||||
doc = Document.new(xml)
|
||||
|
||||
# root items
|
||||
runtime_version value(doc.root, 'APPPOOL/@RuntimeVersion').gsub(/^v/, '')
|
||||
pipeline_mode value(doc.root, 'APPPOOL/@PipelineMode').to_sym
|
||||
|
||||
# add items
|
||||
auto_start bool(value(doc.root, 'APPPOOL/add/@autoStart')) if iis_version >= 7.0
|
||||
start_mode value(doc.root, 'APPPOOL/add/@startMode').to_sym if iis_version > 7.0
|
||||
queue_length value(doc.root, 'APPPOOL/add/@queueLength').to_i
|
||||
thirty_two_bit bool(value(doc.root, 'APPPOOL/add/@enable32BitAppOnWin64'))
|
||||
|
||||
# processModel items
|
||||
max_processes value(doc.root, 'APPPOOL/add/processModel/@maxProcesses').to_i
|
||||
load_user_profile bool(value(doc.root, 'APPPOOL/add/processModel/@loadUserProfile'))
|
||||
identity_type value(doc.root, 'APPPOOL/add/processModel/@identityType').to_sym if iis_version > 7.0
|
||||
username value doc.root, 'APPPOOL/add/processModel/@userName'
|
||||
unless username.nil? || desired.username.nil?
|
||||
Chef::Log.info('username: ' + username + ' -> ' + desired.username)
|
||||
end
|
||||
password value doc.root, 'APPPOOL/add/processModel/@password'
|
||||
logon_type value(doc.root, 'APPPOOL/add/processModel/@logonType').to_sym if iis_version > 7.0
|
||||
manual_group_membership bool(value(doc.root, 'APPPOOL/add/processModel/@manualGroupMembership'))
|
||||
idle_timeout value doc.root, 'APPPOOL/add/processModel/@idleTimeout'
|
||||
idle_timeout_action value(doc.root, 'APPPOOL/add/processModel/@idleTimeoutAction').to_sym if iis_version >= 8.5
|
||||
shutdown_time_limit value doc.root, 'APPPOOL/add/processModel/@shutdownTimeLimit'
|
||||
startup_time_limit value doc.root, 'APPPOOL/add/processModel/@startupTimeLimit'
|
||||
pinging_enabled bool(value(doc.root, 'APPPOOL/add/processModel/@pingingEnabled'))
|
||||
ping_interval value doc.root, 'APPPOOL/add/processModel/@pingInterval'
|
||||
ping_response_time value doc.root, 'APPPOOL/add/processModel/@pingResponseTime'
|
||||
|
||||
# recycling items
|
||||
disallow_overlapping_rotation bool(value(doc.root, 'APPPOOL/add/recycling/@disallowOverlappingRotation'))
|
||||
disallow_rotation_on_config_change bool(value(doc.root, 'APPPOOL/add/recycling/@disallowRotationOnConfigChange'))
|
||||
recycle_after_time value doc.root, 'APPPOOL/add/recycling/periodicRestart/@time'
|
||||
recycle_at_time value doc.root, "APPPOOL/add/recycling/periodicRestart/schedule/add[@value='#{desired.recycle_at_time}']/@value"
|
||||
private_memory value(doc.root, 'APPPOOL/add/recycling/periodicRestart/@privateMemory').to_i
|
||||
virtual_memory value(doc.root, 'APPPOOL/add/recycling/periodicRestart/@memory').to_i
|
||||
log_event_on_recycle value doc.root, 'APPPOOL/add/recycling/@logEventOnRecycle'
|
||||
|
||||
# failure items
|
||||
load_balancer_capabilities value(doc.root, 'APPPOOL/add/failure/@loadBalancerCapabilities').to_sym
|
||||
orphan_worker_process bool(value(doc.root, 'APPPOOL/add/failure/@orphanWorkerProcess'))
|
||||
orphan_action_exe value doc.root, 'APPPOOL/add/failure/@orphanActionExe'
|
||||
orphan_action_params value doc.root, 'APPPOOL/add/failure/@orphanActionParams'
|
||||
rapid_fail_protection bool(value(doc.root, 'APPPOOL/add/failure/@rapidFailProtection'))
|
||||
rapid_fail_protection_interval value doc.root, 'APPPOOL/add/failure/@rapidFailProtectionInterval'
|
||||
rapid_fail_protection_max_crashes value(doc.root, 'APPPOOL/add/failure/@rapidFailProtectionMaxCrashes').to_i
|
||||
auto_shutdown_exe value doc.root, 'APPPOOL/add/failure/@autoShutdownExe'
|
||||
auto_shutdown_params value doc.root, 'APPPOOL/add/failure/@autoShutdownParams'
|
||||
|
||||
# cpu items
|
||||
cpu_action value(doc.root, 'APPPOOL/add/cpu/@action').to_sym
|
||||
cpu_limit value(doc.root, 'APPPOOL/add/cpu/@limit').to_i
|
||||
cpu_smp_affinitized bool(value(doc.root, 'APPPOOL/add/cpu/@smpAffinitized'))
|
||||
cpu_reset_interval value doc.root, 'APPPOOL/add/cpu/@resetInterval'
|
||||
smp_processor_affinity_mask value(doc.root, 'APPPOOL/add/cpu/@smpProcessorAffinityMask').to_f
|
||||
smp_processor_affinity_mask_2 value(doc.root, 'APPPOOL/add/cpu/@smpProcessorAffinityMask2').to_f
|
||||
|
||||
@node_array = XPath.match(doc.root, 'APPPOOL/add/recycling/periodicRestart/schedule/add')
|
||||
end
|
||||
end
|
||||
|
||||
action :add do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource} pool already exists - nothing to do")
|
||||
else
|
||||
converge_by "Created Application Pool \"#{new_resource}\"" do
|
||||
cmd = "#{appcmd(node)} add apppool /name:\"#{new_resource.name}\""
|
||||
if new_resource.no_managed_code
|
||||
cmd << ' /managedRuntimeVersion:'
|
||||
elsif new_resource.runtime_version
|
||||
cmd << " /managedRuntimeVersion:v#{new_resource.runtime_version}"
|
||||
end
|
||||
cmd << " /managedPipelineMode:#{new_resource.pipeline_mode.capitalize}" if new_resource.pipeline_mode
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
configure
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
configure if exists
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists
|
||||
converge_by "Deleted Application Pool \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} delete apppool \"#{new_resource.name}\"")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} pool does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :start do
|
||||
if exists && !current_resource.running
|
||||
converge_by "Started Application Pool \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} start apppool \"#{new_resource.name}\"")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already running - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
if exists && current_resource.running
|
||||
converge_by "Stopped Application Pool \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} stop apppool \"#{new_resource.name}\"")
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already stopped - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
if exists
|
||||
converge_by "Restarted Application Pool \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} stop APPPOOL \"#{new_resource.name}\"") if current_resource.running
|
||||
sleep 2
|
||||
shell_out!("#{appcmd(node)} start APPPOOL \"#{new_resource.name}\"")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :recycle do
|
||||
if exists
|
||||
converge_by "Recycled Application Pool \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} recycle APPPOOL \"#{new_resource.name}\"") if current_resource.running
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def exists
|
||||
current_resource.runtime_version ? true : false
|
||||
end
|
||||
|
||||
def configure
|
||||
# Application Pool Config
|
||||
cmd = "#{appcmd(node)} set config /section:applicationPools"
|
||||
|
||||
# root items
|
||||
if iis_version >= 7.0
|
||||
converge_if_changed :auto_start do
|
||||
cmd << configure_application_pool("autoStart:#{new_resource.auto_start}")
|
||||
end
|
||||
end
|
||||
|
||||
if iis_version >= 7.5
|
||||
converge_if_changed :start_mode do
|
||||
cmd << configure_application_pool("startMode:#{new_resource.start_mode}")
|
||||
end
|
||||
end
|
||||
|
||||
if new_resource.no_managed_code
|
||||
converge_if_changed :runtime_version do
|
||||
cmd << configure_application_pool('managedRuntimeVersion:')
|
||||
end
|
||||
else
|
||||
converge_if_changed :runtime_version do
|
||||
cmd << configure_application_pool("managedRuntimeVersion:v#{new_resource.runtime_version}")
|
||||
end
|
||||
end
|
||||
|
||||
converge_if_changed :pipeline_mode do
|
||||
cmd << configure_application_pool("managedPipelineMode:#{new_resource.pipeline_mode}")
|
||||
end
|
||||
converge_if_changed :thirty_two_bit do
|
||||
cmd << configure_application_pool("enable32BitAppOnWin64:#{new_resource.thirty_two_bit}")
|
||||
end
|
||||
converge_if_changed :queue_length do
|
||||
cmd << configure_application_pool("queueLength:#{new_resource.queue_length}")
|
||||
end
|
||||
|
||||
# processModel items
|
||||
converge_if_changed :max_processes do
|
||||
cmd << configure_application_pool("processModel.maxProcesses:#{new_resource.max_processes}")
|
||||
end
|
||||
converge_if_changed :load_user_profile do
|
||||
cmd << configure_application_pool("processModel.loadUserProfile:#{new_resource.load_user_profile}")
|
||||
end
|
||||
converge_if_changed :logon_type do
|
||||
cmd << configure_application_pool("processModel.logonType:#{new_resource.logon_type}")
|
||||
end
|
||||
converge_if_changed :manual_group_membership do
|
||||
cmd << configure_application_pool("processModel.manualGroupMembership:#{new_resource.manual_group_membership}")
|
||||
end
|
||||
converge_if_changed :idle_timeout do
|
||||
cmd << configure_application_pool("processModel.idleTimeout:#{new_resource.idle_timeout}")
|
||||
end
|
||||
if iis_version >= 8.5
|
||||
converge_if_changed :idle_timeout_action do
|
||||
cmd << configure_application_pool("processModel.idleTimeoutAction:#{new_resource.idle_timeout_action}")
|
||||
end
|
||||
end
|
||||
converge_if_changed :shutdown_time_limit do
|
||||
cmd << configure_application_pool("processModel.shutdownTimeLimit:#{new_resource.shutdown_time_limit}")
|
||||
end
|
||||
converge_if_changed :startup_time_limit do
|
||||
cmd << configure_application_pool("processModel.startupTimeLimit:#{new_resource.startup_time_limit}")
|
||||
end
|
||||
converge_if_changed :pinging_enabled do
|
||||
cmd << configure_application_pool("processModel.pingingEnabled:#{new_resource.pinging_enabled}")
|
||||
end
|
||||
converge_if_changed :ping_interval do
|
||||
cmd << configure_application_pool("processModel.pingInterval:#{new_resource.ping_interval}")
|
||||
end
|
||||
converge_if_changed :ping_response_time do
|
||||
cmd << configure_application_pool("processModel.pingResponseTime:#{new_resource.ping_response_time}")
|
||||
end
|
||||
|
||||
should_clear_apppool_schedules = ((new_resource.recycle_at_time != current_resource.recycle_at_time) && !@node_array.nil? && !@node_array.empty?) || (new_resource.recycle_schedule_clear && !@node_array.nil? && !@node_array.empty?)
|
||||
|
||||
# recycling items
|
||||
## Special case this collection removal for now.
|
||||
# TODO: test if this is needed
|
||||
# is_new_recycle_at_time = true
|
||||
if !current_resource.runtime_version && should_clear_apppool_schedules
|
||||
converge_by "Cleared Periodic Restart Schedule #{new_resource} - #{should_clear_apppool_schedules}" do
|
||||
clear_pool_schedule_cmd = "#{appcmd(node)} set config /section:applicationPools \"/-[name='#{new_resource.name}'].recycling.periodicRestart.schedule\""
|
||||
Chef::Log.debug(clear_pool_schedule_cmd)
|
||||
shell_out!(clear_pool_schedule_cmd)
|
||||
end
|
||||
end
|
||||
|
||||
converge_if_changed :recycle_after_time do
|
||||
cmd << configure_application_pool("recycling.periodicRestart.time:#{new_resource.recycle_after_time}")
|
||||
end
|
||||
converge_if_changed :recycle_at_time do
|
||||
cmd << configure_application_pool("recycling.periodicRestart.schedule.[value='#{new_resource.recycle_at_time}']", '+')
|
||||
end
|
||||
converge_if_changed :log_event_on_recycle do
|
||||
cmd << configure_application_pool("recycling.logEventOnRecycle:#{new_resource.log_event_on_recycle}")
|
||||
end
|
||||
converge_if_changed :private_memory do
|
||||
cmd << configure_application_pool("recycling.periodicRestart.privateMemory:#{new_resource.private_memory}")
|
||||
end
|
||||
converge_if_changed :virtual_memory do
|
||||
cmd << configure_application_pool("recycling.periodicRestart.memory:#{new_resource.virtual_memory}")
|
||||
end
|
||||
converge_if_changed :disallow_rotation_on_config_change do
|
||||
cmd << configure_application_pool("recycling.disallowRotationOnConfigChange:#{new_resource.disallow_rotation_on_config_change}")
|
||||
end
|
||||
converge_if_changed :disallow_overlapping_rotation do
|
||||
cmd << configure_application_pool("recycling.disallowOverlappingRotation:#{new_resource.disallow_overlapping_rotation}")
|
||||
end
|
||||
|
||||
# failure items
|
||||
converge_if_changed :load_balancer_capabilities do
|
||||
cmd << configure_application_pool("failure.loadBalancerCapabilities:#{new_resource.load_balancer_capabilities}")
|
||||
end
|
||||
converge_if_changed :orphan_worker_process do
|
||||
cmd << configure_application_pool("failure.orphanWorkerProcess:#{new_resource.orphan_worker_process}")
|
||||
end
|
||||
converge_if_changed :orphan_action_exe do
|
||||
cmd << configure_application_pool("failure.orphanActionExe:#{new_resource.orphan_action_exe}")
|
||||
end
|
||||
converge_if_changed :orphan_action_params do
|
||||
cmd << configure_application_pool("failure.orphanActionParams:#{new_resource.orphan_action_params}")
|
||||
end
|
||||
converge_if_changed :rapid_fail_protection do
|
||||
cmd << configure_application_pool("failure.rapidFailProtection:#{new_resource.rapid_fail_protection}")
|
||||
end
|
||||
converge_if_changed :rapid_fail_protection_interval do
|
||||
cmd << configure_application_pool("failure.rapidFailProtectionInterval:#{new_resource.rapid_fail_protection_interval}")
|
||||
end
|
||||
converge_if_changed :rapid_fail_protection_max_crashes do
|
||||
cmd << configure_application_pool("failure.rapidFailProtectionMaxCrashes:#{new_resource.rapid_fail_protection_max_crashes}")
|
||||
end
|
||||
converge_if_changed :auto_shutdown_exe do
|
||||
cmd << configure_application_pool("failure.autoShutdownExe:#{new_resource.auto_shutdown_exe}")
|
||||
end
|
||||
converge_if_changed :auto_shutdown_params do
|
||||
cmd << configure_application_pool("failure.autoShutdownParams:#{new_resource.auto_shutdown_params}")
|
||||
end
|
||||
|
||||
# cpu items
|
||||
converge_if_changed :cpu_action do
|
||||
cmd << configure_application_pool("cpu.action:#{new_resource.cpu_action}")
|
||||
end
|
||||
converge_if_changed :cpu_limit do
|
||||
cmd << configure_application_pool("cpu.limit:#{new_resource.cpu_limit}")
|
||||
end
|
||||
converge_if_changed :cpu_reset_interval do
|
||||
cmd << configure_application_pool("cpu.resetInterval:#{new_resource.cpu_reset_interval}")
|
||||
end
|
||||
converge_if_changed :cpu_smp_affinitized do
|
||||
cmd << configure_application_pool("cpu.smpAffinitized:#{new_resource.cpu_smp_affinitized}")
|
||||
end
|
||||
converge_if_changed :smp_processor_affinity_mask do
|
||||
cmd << configure_application_pool("cpu.smpProcessorAffinityMask:#{new_resource.smp_processor_affinity_mask.floor}")
|
||||
end
|
||||
converge_if_changed :smp_processor_affinity_mask_2 do
|
||||
cmd << configure_application_pool("cpu.smpProcessorAffinityMask2:#{new_resource.smp_processor_affinity_mask_2.floor}")
|
||||
end
|
||||
|
||||
unless current_resource.runtime_version && cmd == "#{appcmd(node)} set config /section:applicationPools"
|
||||
converge_by "Configured Application Pool \"#{new_resource}\"" do
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
# Application Pool Identity Settings
|
||||
if new_resource.username && new_resource.username != ''
|
||||
cmd = default_app_pool_user
|
||||
converge_if_changed :username do
|
||||
cmd << " \"/[name='#{new_resource.name}'].processModel.userName:#{new_resource.username}\""
|
||||
end
|
||||
converge_if_changed :password do
|
||||
cmd << " \"/[name='#{new_resource.name}'].processModel.password:#{new_resource.password}\""
|
||||
end
|
||||
if cmd != default_app_pool_user
|
||||
converge_by "Configured Application Pool Identity Settings \"#{new_resource}\"" do
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
elsif new_resource.identity_type != 'SpecificUser'
|
||||
converge_if_changed :identity_type do
|
||||
cmd = "#{appcmd(node)} set config /section:applicationPools"
|
||||
cmd << " \"/[name='#{new_resource.name}'].processModel.identityType:#{new_resource.identity_type}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def default_app_pool_user
|
||||
cmd_default = "#{appcmd(node)} set config /section:applicationPools"
|
||||
cmd_default << " \"/[name='#{new_resource.name}'].processModel.identityType:SpecificUser\""
|
||||
end
|
||||
|
||||
def configure_application_pool(config, add_remove = '')
|
||||
" \"/#{add_remove}[name='#{new_resource.name}'].#{config}\""
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Justin Schuhmann
|
||||
# Cookbook:: iis
|
||||
# Resource:: lock
|
||||
# Resource:: section
|
||||
#
|
||||
# Copyright:: 2016, Justin Schuhmann
|
||||
# Copyright:: 2016-2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,10 +17,57 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :lock, :unlock
|
||||
default_action :lock
|
||||
require 'rexml/document'
|
||||
|
||||
attribute :section, kind_of: String
|
||||
attribute :returns, kind_of: [Integer, Array], default: 0
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::SectionHelper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
attr_accessor :exists
|
||||
property :section, String, name_property: true
|
||||
property :site, String
|
||||
property :application_path, String
|
||||
property :returns, [Integer, Array], default: 0
|
||||
property :locked, String
|
||||
|
||||
default_action :unlock
|
||||
|
||||
load_current_value do |desired|
|
||||
section desired.section
|
||||
site desired.site
|
||||
application_path desired.application_path
|
||||
command_path = 'MACHINE/WEBROOT/APPHOST'
|
||||
command_path << "/#{site}" if site
|
||||
command_path << application_path.to_s if application_path
|
||||
cmd = "#{appcmd(node)} list config \"#{command_path}\""
|
||||
cmd << " -section:\"#{section}\" /commit:apphost /config:* /xml"
|
||||
Chef::Log.debug(cmd)
|
||||
cmd = shell_out(cmd)
|
||||
if cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = Document.new(xml)
|
||||
locked value doc.root, 'CONFIG/@overrideMode'
|
||||
else
|
||||
Chef::Log.info(cmd.stderr)
|
||||
end
|
||||
end
|
||||
|
||||
action :lock do
|
||||
if current_resource.locked != 'Deny'
|
||||
converge_by "Locking the section - \"#{new_resource}\"" do
|
||||
lock node, new_resource.section, "#{new_resource.site}#{new_resource.application_path}", new_resource.returns
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already locked - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :unlock do
|
||||
if current_resource.locked != 'Allow'
|
||||
converge_by "Unlocking the section - \"#{new_resource}\"" do
|
||||
unlock node, new_resource.section, "#{new_resource.site}#{new_resource.application_path}", new_resource.returns
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already unlocked - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
||||
# Cookbook:: iis
|
||||
# Resource:: site
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, Inc.
|
||||
# Copyright:: 2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,20 +17,219 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :delete, :start, :stop, :restart, :config
|
||||
require 'rexml/document'
|
||||
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
property :site_name, String, name_property: true
|
||||
property :site_id, Integer
|
||||
property :port, Integer, default: 80, coerce: proc { |v| v.to_i }
|
||||
property :path, String
|
||||
property :protocol, [Symbol, String], equal_to: [:http, :https], default: :http, coerce: proc { |v| v.to_sym }
|
||||
property :host_header, String
|
||||
property :bindings, String
|
||||
property :application_pool, String
|
||||
property :options, String, default: ''
|
||||
property :log_directory, String, default: node['iis']['log_dir']
|
||||
property :log_period, [Symbol, String], equal_to: [:Daily, :Hourly, :MaxSize, :Monthly, :Weekly], default: :Daily, coerce: proc { |v| v.to_sym }
|
||||
property :log_truncsize, Integer, default: 1_048_576
|
||||
property :running, [true, false], desired_state: true
|
||||
|
||||
default_action :add
|
||||
|
||||
attribute :site_name, kind_of: String, name_attribute: true
|
||||
attribute :site_id, kind_of: Integer
|
||||
attribute :port, kind_of: Integer, default: 80
|
||||
attribute :path, kind_of: String
|
||||
attribute :protocol, kind_of: Symbol, default: :http, equal_to: [:http, :https]
|
||||
attribute :host_header, kind_of: String, default: nil
|
||||
attribute :bindings, kind_of: String, default: nil
|
||||
attribute :application_pool, kind_of: String, default: nil
|
||||
attribute :options, kind_of: String, default: ''
|
||||
attribute :log_directory, kind_of: String, default: node['iis']['log_dir']
|
||||
attribute :log_period, kind_of: Symbol, default: :Daily, equal_to: [:Daily, :Hourly, :MaxSize, :Monthly, :Weekly]
|
||||
attribute :log_truncsize, kind_of: Integer, default: 1_048_576
|
||||
load_current_value do |desired|
|
||||
site_name desired.site_name
|
||||
# Sanitize windows file system path
|
||||
desired.path = windows_cleanpath(desired.path) if desired.path
|
||||
desired.log_directory = windows_cleanpath(desired.log_directory) if desired.log_directory
|
||||
cmd = shell_out "#{appcmd(node)} list site \"#{site_name}\""
|
||||
Chef::Log.debug(appcmd(node))
|
||||
# 'SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)'
|
||||
Chef::Log.debug("#{desired} list site command output: #{cmd.stdout}")
|
||||
if cmd.stderr.empty?
|
||||
result = cmd.stdout.gsub(/\r\n?/, "\n") # ensure we have no carriage returns
|
||||
result = result.match(/^SITE\s\"(?<site>#{desired.site_name})\"\s\(id:(?<site_id>.*),bindings:(?<bindings>.*),state:(?<state>.*)\)$/i)
|
||||
Chef::Log.debug("#{desired} current_resource match output: #{result}")
|
||||
if result
|
||||
site_id result[:site_id].to_i
|
||||
bindings result[:bindings]
|
||||
running result[:state] =~ /Started/ ? true : false
|
||||
else
|
||||
running false
|
||||
end
|
||||
|
||||
attr_accessor :exists, :running
|
||||
if site_id
|
||||
values = "#{bindings},".match(%r{(?<protocol>[^\/]+)\/\*:(?<port>[^:]+):(?<host_header>[^,]*),})
|
||||
# get current values
|
||||
cmd = "#{appcmd(node)} list site \"#{site_name}\" /config:* /xml"
|
||||
Chef::Log.debug(cmd)
|
||||
cmd = shell_out cmd
|
||||
if cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = Document.new(xml)
|
||||
path windows_cleanpath(value(doc.root, 'SITE/site/application/virtualDirectory/@physicalPath'))
|
||||
log_directory windows_cleanpath(value(doc.root, 'SITE/site/logFile/@directory'))
|
||||
log_period value(doc.root, 'SITE/site/logFile/@period').to_sym
|
||||
log_truncsize value(doc.root, 'SITE/site/logFile/@truncateSize').to_i
|
||||
application_pool value doc.root, 'SITE/site/application/@applicationPool'
|
||||
end
|
||||
|
||||
if values
|
||||
protocol values[:protocol].to_sym
|
||||
port values[:port].to_i
|
||||
host_header values[:host_header]
|
||||
end
|
||||
else
|
||||
running false
|
||||
end
|
||||
|
||||
if values
|
||||
protocol values[:protocol]
|
||||
port values[:port].to_i
|
||||
host_header values[:host_header]
|
||||
end
|
||||
else
|
||||
Chef::Log.warn "Failed to run iis_site action :config, #{cmd.stderr}"
|
||||
end
|
||||
end
|
||||
|
||||
action :add do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource} site already exists - nothing to do")
|
||||
else
|
||||
converge_by "Created the Site - \"#{new_resource}\"" do
|
||||
cmd = "#{appcmd(node)} add site /name:\"#{new_resource.site_name}\""
|
||||
cmd << " /id:#{new_resource.site_id}" if new_resource.site_id
|
||||
cmd << " /physicalPath:\"#{new_resource.path}\"" if new_resource.path
|
||||
if new_resource.bindings
|
||||
cmd << " /bindings:\"#{new_resource.bindings}\""
|
||||
else
|
||||
cmd << " /bindings:#{new_resource.protocol}/*"
|
||||
cmd << ":#{new_resource.port}:" if new_resource.port
|
||||
cmd << new_resource.host_header if new_resource.host_header
|
||||
end
|
||||
|
||||
# support for additional options -logDir, -limits, -ftpServer, etc...
|
||||
cmd << " #{new_resource.options}" if new_resource.options
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
|
||||
configure
|
||||
|
||||
if new_resource.application_pool
|
||||
shell_out!("#{appcmd(node)} set site /site.name:\"#{new_resource.site_name}\" /[path='/'].applicationPool:\"#{new_resource.application_pool}\"", returns: [0, 42])
|
||||
end
|
||||
Chef::Log.info("#{new_resource} added new site '#{new_resource.site_name}'")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
configure if exists
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists
|
||||
converge_by "Deleted the Site - \"#{new_resource}\"" do
|
||||
Chef::Log.info("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"")
|
||||
shell_out!("#{appcmd(node)} delete site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} site does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :start do
|
||||
if exists && !current_resource.running
|
||||
converge_by "Started the Site - \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} start site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already running - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
if exists && current_resource.running
|
||||
converge_by "Stopped the Site - \"#{new_resource}\"" do
|
||||
Chef::Log.info("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"")
|
||||
shell_out!("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} already stopped - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
converge_by "Restarted the Site - \"#{new_resource}\"" do
|
||||
shell_out!("#{appcmd(node)} stop site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42]) if running
|
||||
sleep 2
|
||||
shell_out!("#{appcmd(node)} start site /site.name:\"#{new_resource.site_name}\"", returns: [0, 42])
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def exists
|
||||
current_resource.site_id ? true : false
|
||||
end
|
||||
|
||||
def configure
|
||||
if new_resource.bindings
|
||||
converge_if_changed :bindings do
|
||||
cmd = "#{appcmd(node)} set site /site.name:\"#{new_resource.site_name}\""
|
||||
cmd << " /bindings:\"#{new_resource.bindings}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
elsif new_resource.port || new_resource.host_header || new_resource.protocol
|
||||
converge_if_changed :bindings, :host_header, :protocol do
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /bindings:#{new_resource.protocol}/*:#{new_resource.port}:#{new_resource.host_header}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
converge_if_changed :application_pool do
|
||||
cmd = "#{appcmd(node)} set app \"#{new_resource.site_name}/\" /applicationPool:\"#{new_resource.application_pool}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: [0, 42])
|
||||
end
|
||||
|
||||
converge_if_changed :path do
|
||||
cmd = "#{appcmd(node)} set vdir \"#{new_resource.site_name}/\""
|
||||
cmd << " /physicalPath:\"#{new_resource.path}\""
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
converge_if_changed :site_id do
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /id:#{new_resource.site_id}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
converge_if_changed :log_directory do
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.directory:#{new_resource.log_directory}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
converge_if_changed :log_period do
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.period:#{new_resource.log_period}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
|
||||
converge_if_changed :log_truncsize do
|
||||
cmd = "#{appcmd(node)} set site \"#{new_resource.site_name}\""
|
||||
cmd << " /logFile.truncateSize:#{new_resource.log_truncsize}"
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#
|
||||
# Author:: Justin Schuhmann (<jmschu02@gmail.com>)
|
||||
# Cookbook:: iis
|
||||
# Resource:: site
|
||||
# Resource:: vdir
|
||||
#
|
||||
# Copyright:: 2016, Justin Schuhmann
|
||||
# Copyright:: 2016-2017, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,15 +17,128 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :add, :delete, :config
|
||||
require 'rexml/document'
|
||||
|
||||
include REXML
|
||||
include Opscode::IIS::Helper
|
||||
include Opscode::IIS::Processors
|
||||
|
||||
property :application_name, String, name_property: true
|
||||
property :path, String
|
||||
property :physical_path, String
|
||||
property :username, String
|
||||
property :password, String
|
||||
property :logon_method, [Symbol, String], default: :ClearText, equal_to: [:Interactive, :Batch, :Network, :ClearText], coerce: proc { |v| v.to_sym }
|
||||
property :allow_sub_dir_config, [true, false], default: true
|
||||
|
||||
default_action :add
|
||||
|
||||
attribute :application_name, kind_of: String, name_attribute: true
|
||||
attribute :path, kind_of: String
|
||||
attribute :physical_path, kind_of: String
|
||||
attribute :username, kind_of: String, default: nil
|
||||
attribute :password, kind_of: String, default: nil
|
||||
attribute :logon_method, kind_of: Symbol, default: :ClearText, equal_to: [:Interactive, :Batch, :Network, :ClearText]
|
||||
attribute :allow_sub_dir_config, kind_of: [TrueClass, FalseClass], default: true
|
||||
load_current_value do |desired|
|
||||
# Sanitize Application Name
|
||||
desired.application_name = application_cleanname(desired.application_name)
|
||||
# Sanitize Physical Path
|
||||
desired.physical_path = windows_cleanpath(desired.physical_path) if desired.physical_path
|
||||
application_name desired.application_name
|
||||
path desired.path
|
||||
cmd = shell_out("#{appcmd(node)} list vdir \"#{application_name.chomp('/') + path}\"")
|
||||
Chef::Log.debug("#{desired} list vdir command output: #{cmd.stdout}")
|
||||
|
||||
attr_accessor :exists
|
||||
if cmd.stderr.empty?
|
||||
# VDIR "Testfu Site/Content/Test"
|
||||
result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(application_name.chomp('/') + path)}\"/)
|
||||
Chef::Log.debug("#{desired} current_resource match output: #{result}")
|
||||
unless result.nil?
|
||||
cmd = shell_out("#{appcmd(node)} list vdir \"#{application_name.chomp('/') + path}\" /config:* /xml")
|
||||
if cmd.stderr.empty?
|
||||
xml = cmd.stdout
|
||||
doc = Document.new(xml)
|
||||
physical_path windows_cleanpath(value(doc.root, 'VDIR/@physicalPath'))
|
||||
username value doc.root, 'VDIR/virtualDirectory/@userName'
|
||||
password value doc.root, 'VDIR/virtualDirectory/@password'
|
||||
logon_method value(doc.root, 'VDIR/virtualDirectory/@logonMethod').to_sym
|
||||
allow_sub_dir_config bool(value(doc.root, 'VDIR/virtualDirectory/@allowSubDirConfig'))
|
||||
end
|
||||
end
|
||||
else
|
||||
Chef::Log.warn "Failed to run iis_vdir action :load_current_resource, #{cmd.stderr}"
|
||||
end
|
||||
end
|
||||
|
||||
action :add do
|
||||
if exists
|
||||
Chef::Log.debug("#{new_resource} virtual directory already exists - nothing to do")
|
||||
else
|
||||
converge_by "Created the VDIR - \"#{new_resource}\"" do
|
||||
cmd = "#{appcmd(node)} add vdir /app.name:\"#{vdir_identifier}\""
|
||||
cmd << " /path:\"#{new_resource.path}\""
|
||||
cmd << " /physicalPath:\"#{new_resource.physical_path}\""
|
||||
cmd << " /userName:\"#{new_resource.username}\"" if new_resource.username
|
||||
cmd << " /password:\"#{new_resource.password}\"" if new_resource.password
|
||||
cmd << " /logonMethod:#{new_resource.logon_method}" if new_resource.logon_method
|
||||
cmd << " /allowSubDirConfig:#{new_resource.allow_sub_dir_config}" if new_resource.allow_sub_dir_config
|
||||
cmd << ' /commit:\"MACHINE/WEBROOT/APPHOST\"'
|
||||
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd, returns: [0, 42, 183])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :config do
|
||||
if exists
|
||||
cmd = "#{appcmd(node)} set vdir \"#{application_identifier}\""
|
||||
converge_if_changed :physical_path do
|
||||
cmd << " /physicalPath:\"#{new_resource.physical_path}\""
|
||||
end
|
||||
|
||||
converge_if_changed :username do
|
||||
cmd << " /userName:\"#{new_resource.username}\""
|
||||
end
|
||||
|
||||
converge_if_changed :password do
|
||||
cmd << " /password:\"#{new_resource.password}\""
|
||||
end
|
||||
|
||||
converge_if_changed :logon_method do
|
||||
cmd << " /logonMethod:#{new_resource.logon_method}"
|
||||
end
|
||||
|
||||
converge_if_changed :allow_sub_dir_config do
|
||||
cmd << " /allowSubDirConfig:#{new_resource.allow_sub_dir_config}"
|
||||
end
|
||||
|
||||
if cmd != "#{appcmd(node)} set vdir \"#{application_identifier}\""
|
||||
converge_by "Updated the VDIR - \"#{new_resource}\"" do
|
||||
Chef::Log.debug(cmd)
|
||||
shell_out!(cmd)
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} virtual directory - nothing changed")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
if exists
|
||||
converge_by "Deleted the VDIR - \"#{new_resource}\"" do
|
||||
Chef::Log.debug("#{appcmd(node)} delete vdir \"#{application_identifier}\"")
|
||||
shell_out!("#{appcmd(node)} delete vdir \"#{application_identifier}\"", returns: [0, 42])
|
||||
end
|
||||
else
|
||||
Chef::Log.debug("#{new_resource} virtual directory does not exist - nothing to do")
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def exists
|
||||
current_resource.physical_path ? true : false
|
||||
end
|
||||
|
||||
def application_identifier
|
||||
new_resource.path.start_with?('/') ? vdir_identifier.chomp('/') + new_resource.path : vdir_identifier + new_resource.path
|
||||
end
|
||||
|
||||
def vdir_identifier
|
||||
new_resource.application_name.include?('/') ? new_resource.application_name : new_resource.application_name + '/'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user