Skip to content

Commit

Permalink
[sous-chefsGH-476] Allow specifying install method for internal windo…
Browse files Browse the repository at this point in the history
…ws_feature resources

install resource refactored to do the feature name translation if required
by just adding the helper method in the action_class.

Also refactored the install resource to enable and start the W3WVC service
since every other recipe in the cookbook used to call the default recipe
that did that anyway

starting the W3WVC is optional and defaults to false, so that the
current behaviour of that resource that doesn't change for down stream users

This makes a much cleaner implemenation, no helper module monkey patched
into recipe, no extra resources and to all users of the cookbook there are
no breaking changes just new options if desired.

Added a unit test for all the mod recipes just to check they converge,
I think this just gives some confidence things are breaking

Spec tests for the install resource
  • Loading branch information
dave-q committed Apr 15, 2021
1 parent d998ce0 commit cf6838f
Show file tree
Hide file tree
Showing 42 changed files with 827 additions and 183 deletions.
11 changes: 6 additions & 5 deletions documentation/iis_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ Simple resource to install the IIS feature

## Properties

| Name | Type | Required| Description |
| ----------------------- | -------- | -------- | ------------------------------------ |
| `source` | String | No | Source to install the features from. |
| `additional_components` | Array | No | Features of IIS to install |
| `install_method` | :windows_feature_dism, :windows_feature_powershell | No | install_method to be used to any windows_features resources. Default is :windows_feature_dism |
| Name | Type | Required| Description |
| ----------------------- | -------------- | -------- | ------------------------------------ |
| `source` | String | No | Source to install the features from. |
| `additional_components` | String,Array | No | Features of IIS to install |
| `install_method` | String, Symbol| No | install_method to be used to any windows_features resources. Default is :windows_feature_dism. Options are :windows_feature_dism, :windows_feature_powershell |
| `start_iis` | true, false | No | Controls whether the W3WVC service is enabled and started. Default is false

## Examples

Expand Down
12 changes: 6 additions & 6 deletions documentation/iis_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Configures the IIS Manager service

## Properties

| Name | Type | Default | Description |
| --------------------------- | ------------- | ------- | ------------------------------------ |
| `enable_remote_management` | true, false | `true` | If remote access allowed |
| `log_directory` | String | | Optional. The directory to write log files to |
| `port` | Integer | `8172` | The port the service listens on. |
| `install_method` | :windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd | `:windows_feature_dism` | Optional. install_method to be used to any windows_features resources |
| Name | Type | Default | Description |
| --------------------------- | --------------- | ------- | ------------------------------------ |
| `enable_remote_management` | true, false | `true` | If remote access allowed |
| `log_directory` | String | | Optional. The directory to write log files to |
| `port` | Integer | `8172` | The port the service listens on. |
| `install_method` | String, Symbol | `:windows_feature_dism` | Optional. install_method to be used to any windows_features resources. Valid options are :windows_feature_dism, :windows_feature_powershell |

## Examples

Expand Down
42 changes: 0 additions & 42 deletions libraries/windowsfeature_helper.rb

This file was deleted.

8 changes: 2 additions & 6 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
iis_install 'install IIS' do
additional_components node['iis']['components']
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']&.to_sym
end

service 'iis' do
service_name 'W3SVC'
action [:enable, :start]
install_method node['iis']['windows_feature_install_method']
start_iis true
end
10 changes: 5 additions & 5 deletions recipes/mod_application_initialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'
install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-ApplicationInit') do
install_method install_method
iis_install 'install IIS, ApplicationInit' do
additional_components 'IIS-ApplicationInit'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
17 changes: 7 additions & 10 deletions recipes/mod_aspnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
# limitations under the License.
#

include_recipe 'iis'
include_recipe 'iis::mod_isapi'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-NetFxExtensibility IIS-ASPNET)) do
action :install
all !IISCookbook::Helper.older_than_windows2012?
source node['iis']['source'] unless node['iis']['source'].nil?
install_method install_method
iis_install 'install IIS, ASPNET' do
additional_components %w(IIS-NetFxExtensibility IIS-ASPNET)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end

include_recipe 'iis::mod_isapi'
14 changes: 7 additions & 7 deletions recipes/mod_aspnet45.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
# limitations under the License.
#

include_recipe 'iis'
include_recipe 'iis::mod_isapi'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45)) do
install_method install_method
iis_install 'install IIS, ASPNET45' do
additional_components %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end

include_recipe 'iis::mod_isapi'
2 changes: 0 additions & 2 deletions recipes/mod_auth_anonymous.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
# limitations under the License.
#

include_recipe 'iis'

iis_section 'unlocks anonymous authentication control in web.config' do
section 'system.webServer/security/authentication/anonymousAuthentication'
action :unlock
Expand Down
11 changes: 5 additions & 6 deletions recipes/mod_auth_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-BasicAuthentication') do
install_method install_method
iis_install 'install IIS, BasicAuth' do
additional_components 'IIS-BasicAuthentication'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end

iis_section 'unlocks basic authentication control in web.config' do
Expand Down
11 changes: 5 additions & 6 deletions recipes/mod_auth_digest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-DigestAuthentication') do
install_method install_method
iis_install 'install IIS, DigestAuth' do
additional_components 'IIS-DigestAuthentication'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end

iis_section 'unlocks digest authentication control in web.config' do
Expand Down
11 changes: 5 additions & 6 deletions recipes/mod_auth_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-WindowsAuthentication') do
install_method install_method
iis_install 'install IIS, WindowsAuth' do
additional_components 'IIS-WindowsAuthentication'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end

iis_section 'unlocks windows authentication control in web.config' do
Expand Down
11 changes: 5 additions & 6 deletions recipes/mod_cgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-CGI') do
install_method install_method
iis_install 'install IIS, CGI' do
additional_components 'IIS-CGI'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_compress_dynamic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-HttpCompressionDynamic') do
install_method install_method
iis_install 'install IIS, HttpCompressionDynamic' do
additional_components 'IIS-HttpCompressionDynamic'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_compress_static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-HttpCompressionStatic') do
install_method install_method
iis_install 'install IIS, HttpCompressionStatic' do
additional_components 'IIS-HttpCompressionStatic'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility)) do
install_method install_method
iis_install 'install IIS, FTP' do
additional_components %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_iis6_metabase_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-IIS6ManagementCompatibility IIS-Metabase)) do
install_method install_method
iis_install 'install IIS, Compatability, Metabase' do
additional_components %w(IIS-IIS6ManagementCompatibility IIS-Metabase)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_isapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-ISAPIFilter IIS-ISAPIExtensions)) do
install_method install_method
iis_install 'install IIS, ISAPI' do
additional_components %w(IIS-ISAPIFilter IIS-ISAPIExtensions)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-CustomLogging') do
install_method install_method
iis_install 'install IIS, CustomLogging' do
additional_components 'IIS-CustomLogging'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
13 changes: 5 additions & 8 deletions recipes/mod_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-ManagementConsole IIS-ManagementService)) do
action :install
all !IISCookbook::Helper.older_than_windows2012?
install_method install_method
iis_install 'install IIS, Management' do
additional_components %w(IIS-ManagementConsole IIS-ManagementService)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity)) do
install_method install_method
iis_install 'install IIS, Security' do
additional_components %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity)
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
11 changes: 5 additions & 6 deletions recipes/mod_tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# limitations under the License.
#

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']&.to_sym

windows_feature transform_feature_name(install_method, 'IIS-HttpTracing') do
install_method install_method
iis_install 'install IIS, Tracing' do
additional_components 'IIS-HttpTracing'
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
start_iis true
end
Loading

0 comments on commit cf6838f

Please sign in to comment.