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

- Introduces new attribute ['iis']['windows_feature_install_method']
if the node is present its value is passed into any windows_feature
resources as the install_method property

Signed-off-by: dave-q <24652224+dave-q@users.noreply.github.com>
  • Loading branch information
dave-q committed Apr 1, 2021
1 parent ec7dd3c commit 2065943
Show file tree
Hide file tree
Showing 23 changed files with 102 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- 'section'
- 'site'
- 'vdir'
- 'default-windowsfeatures-powershell'
fail-fast: false

steps:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of
- `node['iis']['pubroot']` - . default is `%SYSTEMDRIVE%\inetpub`
- `node['iis']['docroot']` - IIS web site home directory. default is `%SYSTEMDRIVE%\inetpub\wwwroot`
- `node['iis']['cache_dir']` - location of cached data. default is `%SYSTEMDRIVE%\inetpub\temp`
- `node['iis']['windows_feature_install_method']` - specify the install method that will be used by any windows_feature resources. If ommitted it will not be specified and will the windows_feature supply a default. Valid options are ':windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd'

## Resources

Expand Down
6 changes: 6 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ suites:
- name: vdir
run_list:
- recipe[test::vdir]
- name: default-windowsfeatures-powershell
run_list:
-recipe[iis::default]
attributes:
iis:
windows_feature_install_method: :windows_feature_powershell
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
iis_install 'install IIS' do
additional_components node['iis']['components']
source node['iis']['source']
install_method node['iis']['windows_feature_install_method']
end

service 'iis' do
Expand Down
5 changes: 4 additions & 1 deletion recipes/mod_application_initialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@

include_recipe 'iis'

windows_feature 'IIS-ApplicationInit'
install_method = node['iis']['windows_feature_install_method']
windows_feature 'IIS-ApplicationInit' do
install_method install_method unless install_method.nil?
end
3 changes: 3 additions & 0 deletions recipes/mod_aspnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
include_recipe 'iis'
include_recipe 'iis::mod_isapi'

install_method = node['iis']['windows_feature_install_method']

windows_feature %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 unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_aspnet45.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
include_recipe 'iis'
include_recipe 'iis::mod_isapi'

windows_feature %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45)
install_method = node['iis']['windows_feature_install_method']

windows_feature %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45) do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_auth_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

include_recipe 'iis'

windows_feature 'IIS-BasicAuthentication'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-BasicAuthentication' do
install_method install_method unless install_method.nil?
end

iis_section 'unlocks basic authentication control in web.config' do
section 'system.webServer/security/authentication/basicAuthentication'
Expand Down
6 changes: 5 additions & 1 deletion recipes/mod_auth_digest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

include_recipe 'iis'

windows_feature 'IIS-DigestAuthentication'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-DigestAuthentication' do
install_method install_method unless install_method.nil?
end

iis_section 'unlocks digest authentication control in web.config' do
section 'system.webServer/security/authentication/digestAuthentication'
Expand Down
6 changes: 5 additions & 1 deletion recipes/mod_auth_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

include_recipe 'iis'

windows_feature 'IIS-WindowsAuthentication'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-WindowsAuthentication' do
install_method install_method unless install_method.nil?
end

iis_section 'unlocks windows authentication control in web.config' do
section 'system.webServer/security/authentication/windowsAuthentication'
Expand Down
6 changes: 5 additions & 1 deletion recipes/mod_cgi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature 'IIS-CGI'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-CGI' do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_compress_dynamic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature 'IIS-HttpCompressionDynamic'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-HttpCompressionDynamic' do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_compress_static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature 'IIS-HttpCompressionStatic'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-HttpCompressionStatic' do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility)
install_method = node['iis']['windows_feature_install_method']

windows_feature %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility) do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_iis6_metabase_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature %w(IIS-IIS6ManagementCompatibility IIS-Metabase)
install_method = node['iis']['windows_feature_install_method']

windows_feature %w(IIS-IIS6ManagementCompatibility IIS-Metabase) do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_isapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature %w(IIS-ISAPIFilter IIS-ISAPIExtensions)
install_method = node['iis']['windows_feature_install_method']

windows_feature %w(IIS-ISAPIFilter IIS-ISAPIExtensions) do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature 'IIS-CustomLogging'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-CustomLogging' do
install_method install_method unless install_method.nil?
end
3 changes: 3 additions & 0 deletions recipes/mod_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

include_recipe 'iis'

install_method = node['iis']['windows_feature_install_method']

windows_feature %w(IIS-ManagementConsole IIS-ManagementService) do
action :install
all !IISCookbook::Helper.older_than_windows2012?
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity)
install_method = node['iis']['windows_feature_install_method']

windows_feature %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity) do
install_method install_method unless install_method.nil?
end
6 changes: 5 additions & 1 deletion recipes/mod_tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@

include_recipe 'iis'

windows_feature 'IIS-HttpTracing'
install_method = node['iis']['windows_feature_install_method']

windows_feature 'IIS-HttpTracing' do
install_method install_method unless install_method.nil?
end
2 changes: 2 additions & 0 deletions resources/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

property :source, String
property :additional_components, Array, default: []
property :install_method, [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], required: false

action :install do
features_to_install = ['IIS-WebServerRole'].concat new_resource.additional_components
Expand All @@ -30,5 +31,6 @@
action :install
all !IISCookbook::Helper.older_than_windows2012?
source new_resource.source unless new_resource.source.nil?
install_method new_resource.install_method unless new_resource.install_method.nil?
end
end
2 changes: 2 additions & 0 deletions resources/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
property :enable_remote_management, [true, false], default: true
property :log_directory, String
property :port, Integer, default: 8172
property :install_method, [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], required: false

action :config do
iis_install 'Web-Mgmt-Service' do
additional_components ['IIS-ManagementService']
install_method new_resource.install_method
end

# properties stored in the registry
Expand Down
14 changes: 14 additions & 0 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@
expect(chef_run).to start_service('iis').with(service_name: 'W3SVC')
end
end

[:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd].each do |method|
context "When iis windows feature install method is provided as #{method}, on a unspecified platform" do
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
node.override['iis']['windows_feature_install_method'] = method
end.converge(described_recipe)
end

it "installs windows features using #{method}" do
expect(chef_run).to install_iis_install('install IIS').with(install_method: method)
end
end
end
end

0 comments on commit 2065943

Please sign in to comment.