Skip to content

Commit

Permalink
Drop support for old Windows Servers versions (< 2016)
Browse files Browse the repository at this point in the history
  • Loading branch information
Annih committed Jul 30, 2024
1 parent 55ef27c commit 83c0ef0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 229 deletions.
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Requirements
This cookbook requires Chef 12.1+.

### Platforms
* Windows Server 2008 (R1, R2)
* Windows Server 2012 (R1, R2)
* Windows Server 2016
* Windows Server 2019

Expand Down Expand Up @@ -196,28 +194,6 @@ source | Source of the windows package | String | *depen
checksum | Checksum of the windows package | String | *depends of the architecture*
options | Options to use when installing the windows package | String | `/q`

## wsus-server::report_viewer
Install reporting viewer 2012 to enable wsus reports.

### Attributes
Attributes to configure Reportviewer prerequisite package are accessible via `node['wsus_server']['report_viewer']['prerequisite']`.

Attribute | Description | Type | Default
----------|----------------------------------------------------|--------|--------
name | Name of the windows package | String | `Microsoft System CLR Types for SQL Server 2012 (x64)`
source | Source of the windows package | String | [https://download.microsoft.com/.../SQLSysClrTypes.msi][sql_clr_types]
checksum | Checksum of the windows package | String | `674c396e9c9bf389dd21c...c570fa927b07fa620db7d4537`
options | Options to use when installing the windows package | String | `/q`

Attributes to configure Reportviewer runtime package are accessible via `node['wsus_server']['report_viewer']['runtime']`.

Attribute | Description | Type | Default
----------|----------------------------------------------------|--------|--------
name | Name of the windows package | String | `Microsoft Report Viewer 2012 Runtime`
source | Source of the windows package | String | [https://download.microsoft.com/.../ReportViewer.exe][report_viewer]
checksum | Checksum of the windows package | String | `948f28452abddd90b27dc...d42254c71b5b1e19ac5c6daf`
options | Options to use when installing the windows package | String | `/q`

## wsus-server::synchronize
This recipe performs a synchronous update of the update catalog, according to the configured subscriptions.

Expand Down Expand Up @@ -269,8 +245,6 @@ limitations under the License.
[subscription]: http://msdn.microsoft.com/library/microsoft.updateservices.administration.isubscription
[subscription_members]: http://msdn.microsoft.com/library/microsoft.updateservices.administration.isubscription_members
[frontend_server]: http://technet.microsoft.com/library/dd939896
[report_viewer]: https://download.microsoft.com/download/F/B/7/FB728406-A1EE-4AB5-9C56-74EB8BDDF2FF/ReportViewer.msi
[sql_clr_types]: https://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SQLSysClrTypes.msi
[build_status]: https://api.travis-ci.org/criteo-cookbooks/wsus-server.svg?branch=master
[cookbook_version]: https://img.shields.io/cookbook/v/wsus-server.svg
[cookbook]: https://supermarket.chef.io/cookbooks/wsus-server
Expand Down
26 changes: 0 additions & 26 deletions attributes/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,3 @@
default['wsus_server']['setup']['content_dir'] = nil
# Defines the local or remote SQL instance used for WSUS configuration database.
default['wsus_server']['setup']['sqlinstance_name'] = nil

# Following attributes are not required anymore on Windows Server 2012 and later
if node['platform_version'].to_f < 6.2
# Enables the inventory feature.
default['wsus_server']['setup']['enable_inventory'] = false
# Determines whether WSUS should be setup as an additional frontend server.
# Frontend server shares the configuration of the main server, using the value of above attribute sqlinstance_name.
# see http://technet.microsoft.com/en-us/library/dd939896.aspx
default['wsus_server']['setup']['frontend_setup'] = false
# Joins the Microsoft Update Improvement Program.
default['wsus_server']['setup']['join_improvement_program'] = false
# Determines whether WSUS should be set as default website - port 80 - or not - port 8530.
default['wsus_server']['setup']['use_default_website'] = false
# Defines path to windows internal database data directory.
default['wsus_server']['setup']['wyukon_data_dir'] = nil

default['wsus_server']['package']['name'] = 'Windows Server Update Services 3.0 SP2'
default['wsus_server']['package']['options'] = '/q'
if node['kernel']['machine'] == 'x86_64'
default['wsus_server']['package']['source'] = 'http://download.microsoft.com/download/B/0/6/B06A69C3-CF97-42CF-86BF-3C59D762E0B2/WSUS30-KB972455-x64.exe'
default['wsus_server']['package']['checksum'] = '50d027431d64c35ad62291825eed35d7ffd3c3ecc96421588465445e195571d0'
else
default['wsus_server']['package']['source'] = 'http://download.microsoft.com/download/B/0/6/B06A69C3-CF97-42CF-86BF-3C59D762E0B2/WSUS30-KB972455-x86.exe'
default['wsus_server']['package']['checksum'] = 'bec8bdd6cdad1edd50cc43e6121b73188b31ba4ad08e55b49f4287923a7f3290'
end
end
31 changes: 0 additions & 31 deletions attributes/report_viewer.rb

This file was deleted.

118 changes: 30 additions & 88 deletions recipes/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
setup_conf = node['wsus_server']['setup']

setup_options = ''
if setup_conf['sqlinstance_name']
setup_options << if node['platform_version'].to_f >= 6.2
" SQL_INSTANCE_NAME=\"#{setup_conf['sqlinstance_name']}\""
else
" SQLINSTANCE_NAME=\"#{setup_conf['sqlinstance_name']}\""
end
end
setup_options << " SQL_INSTANCE_NAME=\"#{setup_conf['sqlinstance_name']}\"" if setup_conf['sqlinstance_name']

if setup_conf['content_dir']
setup_options << " CONTENT_LOCAL=1 CONTENT_DIR=\"#{setup_conf['content_dir']}\""
Expand All @@ -39,94 +33,42 @@
end
end

require 'chef/win32/version'
if node['platform_version'].to_f >= 6.2
[
'NET-WCF-HTTP-Activation45', # This feature is required for KB3159706
'UpdateServices',
'UpdateServices-UI',
].each do |feature_name|
windows_feature feature_name do
action :install
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end
end

windows_feature 'UpdateServices-WidDB' do
action setup_conf['sqlinstance_name'] ? :remove : :install
all true
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end

windows_feature 'UpdateServices-DB' do
action setup_conf['sqlinstance_name'] ? :install : :remove
all true
[
'NET-WCF-HTTP-Activation45', # This feature is required for KB3159706
'UpdateServices',
'UpdateServices-UI',
].each do |feature_name|
windows_feature feature_name do
action :install
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end
end

guard_file = ::File.join(Chef::Config['file_cache_path'], 'wsus_postinstall')
execute 'WSUS PostInstall' do
command "WsusUtil.exe PostInstall #{setup_options}"
cwd 'C:\Program Files\Update Services\Tools'
not_if { ::File.exist?(guard_file) && ::File.read(guard_file) == setup_options }
end

file guard_file do
path guard_file
content setup_options
end
else
setup_options << ' ENABLE_INVENTORY=' + (setup_conf['enable_inventory'] ? '1' : '0')
setup_options << ' MU_ROLLUP=' + (setup_conf['join_improvement_program'] ? '1' : '0')
setup_options << ' DEFAULT_WEBSITE=' + (setup_conf['use_default_website'] ? '1' : '0')
setup_options << ' FRONTEND_SETUP=1 CREATE_DATABASE=0' if setup_conf['frontend_setup']

if setup_conf['wyukon_data_dir']
setup_options << " WYUKON_DATA_DIR=\"#{setup_conf['wyukon_data_dir']}\""
directory setup_conf['wyukon_data_dir'] { recursive true }
end

# WSUS 3.0 SP2 requires some IIS features: http://technet.microsoft.com/en-us/library/dd939916.aspx
features = %w(
IIS-WebServerRole
IIS-WebServer
IIS-ApplicationDevelopment
IIS-ISAPIFilter
IIS-ISAPIExtensions
IIS-NetFxExtensibility
IIS-ASPNET
IIS-WindowsAuthentication
IIS-HttpCompressionDynamic
IIS-IIS6ManagementCompatibility
IIS-WMICompatibility
IIS-Metabase
IIS-LegacyScripts
)

# IIS 6 SnapIn is not compatible with core version
features << 'IIS-LegacySnapIn' unless Chef::ReservedNames::Win32::Version.new.core?
features.each do |feature_name|
windows_feature feature_name do
action :install
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end
end
windows_feature 'UpdateServices-WidDB' do
action setup_conf['sqlinstance_name'] ? :remove : :install
all true
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end

include_recipe 'wsus-server::report_viewer'
windows_feature 'UpdateServices-DB' do
action setup_conf['sqlinstance_name'] ? :install : :remove
all true
install_method :windows_feature_powershell if respond_to? :install_method
provider :windows_feature_powershell unless respond_to? :install_method
end

package_info = node['wsus_server']['package']
guard_file = ::File.join(Chef::Config['file_cache_path'], 'wsus_postinstall')
execute 'WSUS PostInstall' do
command "WsusUtil.exe PostInstall #{setup_options}"
cwd 'C:\Program Files\Update Services\Tools'
not_if { ::File.exist?(guard_file) && ::File.read(guard_file) == setup_options }
end

windows_package package_info['name'] do
action :install
installer_type :custom
options "#{package_info['options']} #{setup_options}"
source package_info['source']
checksum package_info['checksum']
end
file guard_file do
path guard_file
content setup_options
end

# Wsus does not need configuration when setup as frontend server
Expand Down
33 changes: 0 additions & 33 deletions recipes/report_viewer.rb

This file was deleted.

16 changes: 8 additions & 8 deletions spec/recipes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
end
it 'installs windows feature UpdateServices' do
[windows2016_chef_run, windows2019_chef_run].each do |chef_run|
expect(chef_run).to install_windows_feature('UpdateServices').with(all: true)
expect(chef_run).to install_windows_feature('UpdateServices')
end
end
it 'installs windows feature UpdateServices-UI' do
[windows2016_chef_run, windows2019_chef_run].each do |chef_run|
expect(chef_run).to install_windows_feature('UpdateServices-UI').with(all: true)
expect(chef_run).to install_windows_feature('UpdateServices-UI')
end
end
it 'installs windows feature UpdateServices-WidDatabase when no sql_instance_name is provided' do
it 'installs windows feature UpdateServices-WidDB when no sql_instance_name is provided' do
conf = { wsus_server: { setup: { sqlinstance_name: nil } } }
[windows2016_chef_run(conf), windows2019_chef_run(conf)].each do |chef_run|
expect(chef_run).to install_windows_feature('UpdateServices-WidDatabase').with(all: true)
expect(chef_run).to remove_windows_feature('UpdateServices-Database').with(all: true)
expect(chef_run).to install_windows_feature('UpdateServices-WidDB').with(all: true)
expect(chef_run).to remove_windows_feature('UpdateServices-WidDB').with(all: true)
end
end
it 'installs windows feature UpdateServices-Database instead when sql_instance_name is provided' do
it 'installs windows feature UpdateServices-DB instead when sql_instance_name is provided' do
conf = { wsus_server: { setup: { sqlinstance_name: 'instance' } } }
[windows2016_chef_run(conf), windows2019_chef_run(conf)].each do |chef_run|
expect(chef_run).to remove_windows_feature('UpdateServices-WidDatabase').with(all: true)
expect(chef_run).to install_windows_feature('UpdateServices-Database').with(all: true)
expect(chef_run).to remove_windows_feature('UpdateServices-DB').with(all: true)
expect(chef_run).to install_windows_feature('UpdateServices-DB').with(all: true)
end
end
it 'executes WSUS PostInstall when there is no guard file' do
Expand Down
17 changes: 0 additions & 17 deletions spec/recipes/report_viewer_spec.rb

This file was deleted.

0 comments on commit 83c0ef0

Please sign in to comment.