From 83c0ef0cad6c9c35859d3dfaafec57035f01cb5b Mon Sep 17 00:00:00 2001 From: Baptiste Courtois Date: Tue, 30 Jul 2024 22:11:11 +0200 Subject: [PATCH] Drop support for old Windows Servers versions (< 2016) --- README.md | 26 ------- attributes/install.rb | 26 ------- attributes/report_viewer.rb | 31 -------- recipes/install.rb | 118 ++++++++--------------------- recipes/report_viewer.rb | 33 -------- spec/recipes/install_spec.rb | 16 ++-- spec/recipes/report_viewer_spec.rb | 17 ----- 7 files changed, 38 insertions(+), 229 deletions(-) delete mode 100644 attributes/report_viewer.rb delete mode 100644 recipes/report_viewer.rb delete mode 100644 spec/recipes/report_viewer_spec.rb diff --git a/README.md b/README.md index 1eb2a41..711f1bc 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. @@ -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 diff --git a/attributes/install.rb b/attributes/install.rb index 9518c0c..34025d5 100644 --- a/attributes/install.rb +++ b/attributes/install.rb @@ -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 diff --git a/attributes/report_viewer.rb b/attributes/report_viewer.rb deleted file mode 100644 index feed0eb..0000000 --- a/attributes/report_viewer.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# Author:: Baptiste Courtois () -# Cookbook:: wsus-server -# Attribute:: report_viewer -# -# Copyright:: Copyright (c) 2014 Criteo. -# -# 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. -# -# WSUS is a windows only feature -return unless platform?('windows') - -default['wsus_server']['report_viewer']['prerequisite']['name'] = 'Microsoft System CLR Types for SQL Server 2012 (x64)' -default['wsus_server']['report_viewer']['prerequisite']['source'] = 'https://download.microsoft.com/download/F/E/D/FEDB200F-DE2A-46D8-B661-D019DFE9D470/ENU/x64/SQLSysClrTypes.msi' -default['wsus_server']['report_viewer']['prerequisite']['checksum'] = '674c396e9c9bf389dd21cec0780b3b4c808ff50c570fa927b07fa620db7d4537' -default['wsus_server']['report_viewer']['prerequisite']['options'] = '/q' - -default['wsus_server']['report_viewer']['runtime']['name'] = 'Microsoft Report Viewer Runtime 2012' -default['wsus_server']['report_viewer']['runtime']['source'] = 'https://download.microsoft.com/download/F/B/7/FB728406-A1EE-4AB5-9C56-74EB8BDDF2FF/ReportViewer.msi' -default['wsus_server']['report_viewer']['runtime']['checksum'] = '948f28452abddd90b27dc80aba1b48c3faedcf2bd42254c71b5b1e19ac5c6daf' -default['wsus_server']['report_viewer']['runtime']['options'] = '/q' diff --git a/recipes/install.rb b/recipes/install.rb index 33ecc63..9dbe8c6 100644 --- a/recipes/install.rb +++ b/recipes/install.rb @@ -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']}\"" @@ -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 diff --git a/recipes/report_viewer.rb b/recipes/report_viewer.rb deleted file mode 100644 index 1a0987a..0000000 --- a/recipes/report_viewer.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# Author:: Baptiste Courtois () -# Cookbook:: wsus-server -# Recipe:: report_viewer -# -# Copyright:: Copyright (c) 2014 Criteo. -# -# 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. -# -# WSUS is a windows only feature -return unless platform?('windows') - -%w(prerequisite runtime).each do |package| - package_info = node['wsus_server']['report_viewer'][package] - - windows_package package_info['name'] do - action :install - installer_type :custom - source package_info['source'] - checksum package_info['checksum'] - options package_info['options'] - end -end diff --git a/spec/recipes/install_spec.rb b/spec/recipes/install_spec.rb index d20beee..2eba796 100644 --- a/spec/recipes/install_spec.rb +++ b/spec/recipes/install_spec.rb @@ -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 diff --git a/spec/recipes/report_viewer_spec.rb b/spec/recipes/report_viewer_spec.rb deleted file mode 100644 index 097044f..0000000 --- a/spec/recipes/report_viewer_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'wsus-server::report_viewer' do - describe 'On windows' do - it 'installs the report viewer' do - [windows2016_chef_run, windows2016_chef_run].each do |chef_run| - expect(chef_run).to install_windows_package('Microsoft Report Viewer Redistributable 2008 SP1') - end - end - end - - describe 'On linux' do - it 'does nothing' do - expect(linux_chef_run.resource_collection).to be_empty - end - end -end