Skip to content

Commit 0e59d8b

Browse files
Julian C. DunnSean OMeara
Julian C. Dunn
authored and
Sean OMeara
committed
[COOK-3922] - Refactor not to use WebPI
Signed-off-by: Sean OMeara <someara@opscode.com>
1 parent 6d00ff8 commit 0e59d8b

22 files changed

+166
-215
lines changed

README.md

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ Platform
1414
* Windows 8
1515
* Windows Server 2008 (R1, R2)
1616
* Windows Server 2012
17+
* Windows Server 2012R2
18+
19+
Windows 2003R2 is *not* supported because it lacks Add/Remove Features.
1720

1821
Cookbooks
1922
---------
2023

2124
* windows
22-
* webpi
2325

2426
Attributes
2527
==========
2628

27-
* `node['iis']['accept_eula']` - indicate that you accept the terms of the end user license. default is 'false'
2829
* `node['iis']['home']` - IIS main home directory. default is `%WINDIR%\System32\inetsrv`
2930
* `node['iis']['conf_dir']` - location where main IIS configs lives. default is `%WINDIR%\System32\inetsrv\config`
3031
* `node['iis']['pubroot']` - . default is `%SYSTEMDRIVE%\inetpub`
@@ -209,42 +210,10 @@ Manages modules globally or on a per site basis.
209210
Usage
210211
=====
211212

212-
Installing any of the IIS or any of it's modules requires you to explicitly indicate that you accept the terms of the end user license. The hooks have been added to all recipes to do this via an attribute. Create a role to set the `node['iis']['accept_eula']` attribute to 'true'. For example:
213-
214-
% cat roles/iis.rb
215-
name "iis"
216-
description "IIS Web Server"
217-
run_list(
218-
"recipe[iis]",
219-
"recipe[iis::mod_mvc3]",
220-
"recipe[iis::mod_urlrewrite]"
221-
)
222-
default_attributes(
223-
"iis" => {
224-
"accept_eula" => true
225-
}
226-
)
227-
228-
229213
default
230214
-------
231215

232-
Installs and configures IIS 7.0/7.5/8.0 using the recommended configuration, which includes the following modules/extensions:
233-
234-
* Static Content
235-
* Default Document
236-
* Directory Browse
237-
* HTTP Errors
238-
* HTTP Logging
239-
* Logging Libraries
240-
* Request Monitor
241-
* Request Filtering
242-
* HTTP Static Compression
243-
* Management Console
244-
* ASP.NET
245-
* NetFX Extensibility
246-
* ISAPI Filter
247-
* ISAPI Extensions
216+
Installs and configures IIS 7.0/7.5/8.0 using the default configuration.
248217

249218
mod_*
250219
-----
@@ -256,22 +225,22 @@ This cookbook also contains recipes for installing individual IIS modules (exten
256225
* `mod_auth_windows` - installs Windows Authentication (authenticate clients by using NTLM or Kerberos) support
257226
* `mod_compress_dynamic` - installs dynamic content compression support. *PLEASE NOTE* - enabling dynamic compression always gives you more efficient use of bandwidth, but if your server's processor utilization is already very high, the CPU load imposed by dynamic compression might make your site perform more slowly.
258227
* `mod_compress_static` - installs static content compression support
259-
* `mod_deploy` - installs web deploy 2.0 support. Web Deploy (Web Deployment Tool) simplifies the migration, management and deployment of IIS Web servers, Web applications and Web sites.
260228
* `mod_iis6_metabase_compat` - installs IIS 6 Metabase Compatibility component.
261229
* `mod_isapi` - installs ISAPI (Internet Server Application Programming Interface) extension and filter support.
262230
* `mod_logging` - installs and enables HTTP Logging (logging of Web site activity), Logging Tools (logging tools and scripts) and Custom Logging (log any of the HTTP request/response headers, IIS server variables, and client-side fields with simple configuration) support
263231
* `mod_management` - installs Web server Management Console which supports management of local and remote Web servers
264-
* `mod_mvc3` - installs ASP.NET MVC 3 runtime components
265232
* `mod_security` - installs URL Authorization (Authorizes client access to the URLs that comprise a Web application), Request Filtering (configures rules to block selected client requests) and IP Security (allows or denies content access based on IP address or domain name) support.
266233
* `mod_tracing` - installs support for tracing ASP.NET applications and failed requests.
267-
* `mod_urlrewrite` - installs support for url rewrite rules using rule templates, rewrite maps, .NET providers.
234+
235+
Note: Not every possible IIS module has a corresponding recipe. The foregoing recipes are included for convenience, but users may also place additional IIS modules that are installable as Windows features into the ``node['iis']['components']`` array.
268236

269237
License and Author
270238
==================
271239

272-
Author:: Seth Chisamore (<schisamo@opscode.com>)
240+
* Author:: Seth Chisamore (<schisamo@opscode.com>)
241+
* Author:: Julian Dunn (<jdunn@getchef.com>)
273242

274-
Copyright:: 2011, Opscode, Inc.
243+
Copyright:: 2011-2013, Chef Software, Inc.
275244

276245
Licensed under the Apache License, Version 2.0 (the "License");
277246
you may not use this file except in compliance with the License.

attributes/default.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
# limitations under the License.
1919
#
2020

21-
default['iis']['accept_eula'] = false
22-
2321
default['iis']['home'] = "#{ENV['WINDIR']}\\System32\\inetsrv"
2422
default['iis']['conf_dir'] = "#{iis['home']}\\config"
2523
default['iis']['pubroot'] = "#{ENV['SYSTEMDRIVE']}\\inetpub"
2624
default['iis']['docroot'] = "#{iis['pubroot']}\\wwwroot"
2725
default['iis']['log_dir'] = "#{iis['pubroot']}\\logs\\LogFiles"
2826
default['iis']['cache_dir'] = "#{iis['pubroot']}\\temp"
29-
default['iis']['components'] = "IIS7"
27+
28+
if Opscode::IIS::Helper.older_than_windows2008r2?
29+
default['iis']['components'] = %w{Web-Server}
30+
else
31+
default['iis']['components'] = %w{IIS-WebServerRole}
32+
end

libraries/helper.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Cookbook Name:: iis
3+
# Library:: helper
4+
#
5+
# Author:: Julian C. Dunn <jdunn@getchef.com>
6+
#
7+
# Copyright 2013, Chef Software, Inc.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
#
21+
22+
require 'chef/win32/version'
23+
24+
module Opscode::IIS
25+
class Helper
26+
27+
def self.older_than_windows2008r2?
28+
win_version = Chef::ReservedNames::Win32::Version.new
29+
win_version.windows_server_2008? ||
30+
win_version.windows_vista? ||
31+
win_version.windows_server_2003_r2? ||
32+
win_version.windows_home_server? ||
33+
win_version.windows_server_2003? ||
34+
win_version.windows_xp? ||
35+
win_version.windows_2000?
36+
end
37+
end
38+
end

metadata.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
maintainer "Opscode, Inc."
33
maintainer_email "cookbooks@opscode.com"
44
license "Apache 2.0"
5-
description "Installs/Configures Microsoft Internet Information Services 7.0/7.5"
5+
description "Installs/Configures Microsoft Internet Information Services"
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
77
version "1.5.7"
88
supports "windows"
99
depends "windows", ">= 1.2.6"
10-
depends "webpi", ">= 1.0.0"

recipes/default.rb

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,13 @@
1818
# limitations under the License.
1919
#
2020

21-
include_recipe "webpi"
22-
23-
unless node['iis']['accept_eula'] then
24-
Chef::Application.fatal!("You must accept the EULA by setting the attribute node['iis']['accept_eula'] before installing IIS.")
25-
end
26-
27-
webpi_product node['iis']['components'] do
28-
accept_eula node['iis']['accept_eula']
29-
action :install
30-
notifies :run, "execute[Register ASP.NET v4]", :immediately
31-
notifies :run, "execute[Register ASP.NET v4 (x64)]", :immediately
32-
end
33-
34-
aspnet_regiis = "#{ENV['WinDir']}\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_regiis.exe"
35-
execute 'Register ASP.NET v4' do
36-
command "#{aspnet_regiis} -i"
37-
only_if { File.exists?(aspnet_regiis) }
38-
action :nothing
39-
end
40-
41-
aspnet_regiis64 = "#{ENV['WinDir']}\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_regiis.exe"
42-
execute 'Register ASP.NET v4 (x64)' do
43-
command "#{aspnet_regiis64} -i"
44-
only_if { File.exists?(aspnet_regiis64) }
45-
action :nothing
21+
node['iis']['components'].each do |feature|
22+
windows_feature feature do
23+
action :install
24+
end
4625
end
4726

4827
service "iis" do
4928
service_name "W3SVC"
50-
action :nothing
29+
action [:enable, :start]
5130
end

recipes/mod_application_initialization.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "ApplicationInitialization" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
26-
end
23+
if Opscode::IIS::Helper.older_than_windows2008r2?
24+
log "Application Initialization module is not supported on Windows 2008 or lower, ignoring"
25+
else
26+
windows_feature "IIS-ApplicationInit" do
27+
action :install
28+
end
29+
end

recipes/mod_aspnet.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@
1919
#
2020

2121
include_recipe "iis"
22+
include_recipe "iis::mod_isapi"
2223

23-
webpi_product "ASPNET" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
24+
if Opscode::IIS::Helper.older_than_windows2008r2?
25+
features = %w{NET-Framework}
26+
else
27+
features = %w{IIS-NetFxExtensibility IIS-ASPNET}
28+
end
29+
30+
features.each do |feature|
31+
windows_feature feature do
32+
action :install
33+
end
2634
end

recipes/mod_auth_basic.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "BasicAuthentication" do
24-
accept_eula node['iis']['accept_eula']
23+
if Opscode::IIS::Helper.older_than_windows2008r2?
24+
feature = 'Web-Basic-Auth'
25+
else
26+
feature = 'IIS-BasicAuthentication'
27+
end
28+
29+
windows_feature feature do
2530
action :install
2631
end

recipes/mod_auth_windows.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "WindowsAuthentication" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
23+
24+
if Opscode::IIS::Helper.older_than_windows2008r2?
25+
feature = 'Web-Windows-Auth'
26+
else
27+
feature = 'IIS-WindowsAuthentication'
2628
end
29+
30+
windows_feature feature do
31+
action :install
32+
end

recipes/mod_cgi.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "CGI" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
23+
24+
if Opscode::IIS::Helper.older_than_windows2008r2?
25+
feature = 'Web-CGI'
26+
else
27+
feature = 'IIS-CGI'
2628
end
29+
30+
windows_feature feature do
31+
action :install
32+
end

recipes/mod_compress_dynamic.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "DynamicContentCompression" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
23+
24+
if Opscode::IIS::Helper.older_than_windows2008r2?
25+
feature = 'Web-Dyn-Compression'
26+
else
27+
feature = 'IIS-HttpCompressionDynamic'
2628
end
29+
30+
windows_feature feature do
31+
action :install
32+
end

recipes/mod_compress_static.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "StaticContentCompression" do
24-
accept_eula node['iis']['accept_eula']
23+
if Opscode::IIS::Helper.older_than_windows2008r2?
24+
feature = 'Web-Stat-Compression'
25+
else
26+
feature = 'IIS-HttpCompressionStatic'
27+
end
28+
29+
windows_feature feature do
2530
action :install
2631
end

recipes/mod_deploy.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

recipes/mod_iis6_metabase_compat.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020

2121
include_recipe "iis"
2222

23-
webpi_product "MetabaseAndIIS6Compatibility" do
24-
accept_eula node['iis']['accept_eula']
25-
action :install
23+
if Opscode::IIS::Helper.older_than_windows2008r2?
24+
features = %w{Web-Metabase Web-Mgmt-Compat}
25+
else
26+
features = %w{IIS-Metabase IIS-IIS6ManagementCompatibility}
2627
end
28+
29+
features.each do |f|
30+
windows_feature f do
31+
action :install
32+
end
33+
end

recipes/mod_isapi.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020

2121
include_recipe "iis"
2222

23-
%w{ ISAPIExtensions ISAPIFilters }.each do |product|
24-
webpi_product product do
25-
accept_eula node['iis']['accept_eula']
23+
if Opscode::IIS::Helper.older_than_windows2008r2?
24+
features = %w{Web-ISAPI-Filter Web-ISAPI-Ext}
25+
else
26+
features = %w{IIS-ISAPIFilter IIS-ISAPIExtensions}
27+
end
28+
29+
features.each do |feature|
30+
windows_feature feature do
2631
action :install
2732
end
2833
end

0 commit comments

Comments
 (0)