-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
63 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: server_configuration | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: freeze | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: install | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: report_viewer | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: synchronize | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Library:: base_provider | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -26,10 +26,6 @@ module BaseProvider | |
include Chef::Mixin::ShellOut | ||
include Windows::Helper | ||
|
||
def whyrun_supported? | ||
true | ||
end | ||
|
||
def self.uri_to_wsus_endpoint_params(uri) | ||
uri = URI uri | ||
"'#{uri.host}', #{'https'.casecmp(uri.scheme).zero?}, #{uri.port}" | ||
|
@@ -54,7 +50,7 @@ def powershell | |
locate_sysnative_cmd('powershell.exe') | ||
end | ||
|
||
def powershell_out64(cmd, timeout=300) | ||
def powershell_out64(cmd, timeout = 300) | ||
flags = [ | ||
# Hides the copyright banner at startup. | ||
'-NoLogo', | ||
|
@@ -76,7 +72,7 @@ def powershell_out64(cmd, timeout=300) | |
# => https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187.aspx | ||
cmd = shell_out "#{powershell} #{flags.join(' ')} -EncodedCommand #{encoded_command}", timeout: timeout | ||
cmd.error! | ||
fail 'Invalid syntax in PowershellScript' if cmd.stderr && cmd.stderr.include?('ParserError') | ||
raise 'Invalid syntax in PowershellScript' if cmd.stderr && cmd.stderr.include?('ParserError') | ||
cmd | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Library:: base_resource | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -22,15 +22,6 @@ module WsusServer | |
module BaseResource | ||
require 'uri' | ||
|
||
def initialize(name, run_context = nil) | ||
super(name, run_context) | ||
|
||
@action = :configure | ||
@allowed_actions.push(:configure) | ||
|
||
@properties = {} | ||
end | ||
|
||
def endpoint(uri = nil) | ||
@endpoint = validate_http_uri('endpoint', uri) unless uri.nil? | ||
@endpoint | ||
|
@@ -43,7 +34,7 @@ def properties(arg = nil) | |
|
||
def validate_string(name, value, values) | ||
unless values.include? value | ||
fail RangeError, "Invalid value for '#{name}', accepted values are '#{values.join('\', \'')}'" | ||
raise RangeError, "Invalid value for '#{name}', accepted values are '#{values.join('\', \'')}'" | ||
end | ||
value | ||
end | ||
|
@@ -52,29 +43,29 @@ def validate_http_uri(name, value) | |
uri = URI value | ||
uri = URI 'http://' + value unless uri.scheme # also validate the emptyness of the host | ||
unless %w(http https).include? uri.scheme.to_s.downcase | ||
fail ArgumentError, "Invalid scheme for '#{name}' URI, accepted schemes are 'http' and 'https'" | ||
raise ArgumentError, "Invalid scheme for '#{name}' URI, accepted schemes are 'http' and 'https'" | ||
end | ||
uri | ||
end | ||
|
||
def validate_boolean(name, value) | ||
unless value.is_a?(TrueClass) || value.is_a?(FalseClass) | ||
fail TypeError, "Invalid value for '#{name}' expecting 'True' or 'False'" | ||
raise TypeError, "Invalid value for '#{name}' expecting 'True' or 'False'" | ||
end | ||
value | ||
end | ||
|
||
def validate_time(name, value) | ||
unless value =~ /^([01]?[0-9]|2[0-3])(\:[0-5][0-9]){1,2}$/ | ||
fail ArgumentError, "Invalid value for '#{name}', format is: 'HH:MM:SS'" | ||
raise ArgumentError, "Invalid value for '#{name}', format is: 'HH:MM:SS'" | ||
end | ||
value | ||
end | ||
|
||
def validate_integer(name, value, min, max) | ||
i = value.to_i | ||
unless i >= min && i <= max && value.to_s =~ /^\d+$/ | ||
fail ArgumentError, "Invalid value for '#{name}', value must be between #{min} and #{max}" | ||
raise ArgumentError, "Invalid value for '#{name}', value must be between #{min} and #{max}" | ||
end | ||
i | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,10 @@ | |
maintainer_email '[email protected]' | ||
license 'Apache-2.0' | ||
description 'Installs wsus server' | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version '2.3.2' | ||
supports 'windows' | ||
depends 'windows' | ||
|
||
chef_version '>= 12.1' if respond_to?(:chef_version) | ||
source_url 'https://github.com/criteo-cookbooks/wsus-server' if respond_to?(:source_url) | ||
issues_url 'https://github.com/criteo-cookbooks/wsus-server/issues' if respond_to?(:issues_url) | ||
chef_version '>= 12.1' | ||
source_url 'https://github.com/criteo-cookbooks/wsus-server' | ||
issues_url 'https://github.com/criteo-cookbooks/wsus-server/issues' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Provider:: configuration | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -17,7 +17,6 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
use_inline_resources | ||
|
||
include WsusServer::BaseProvider | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Provider:: notification | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -17,7 +17,6 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
use_inline_resources | ||
|
||
include WsusServer::BaseProvider | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Provider:: subscription | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -17,7 +17,6 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
use_inline_resources | ||
|
||
include WsusServer::BaseProvider | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Recipe:: configure | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Recipe:: default | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus | ||
# Cookbook:: wsus | ||
# Attribute:: server_freeze | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -22,10 +22,9 @@ | |
|
||
include_recipe 'wsus-server::install' | ||
|
||
|
||
freeze = node['wsus_server']['freeze']['name'] | ||
|
||
powershell_script 'WSUS Update Freeze' do # ~FC009 | ||
powershell_script 'WSUS Update Freeze' do | ||
code <<-EOH | ||
[Reflection.Assembly]::LoadWithPartialName('Microsoft.UpdateServices.Administration') | Out-Null | ||
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer() | ||
|
@@ -51,7 +50,6 @@ | |
} | ||
} | ||
EOH | ||
guard_interpreter :powershell_script | ||
only_if <<-EOH | ||
[Reflection.Assembly]::LoadWithPartialName('Microsoft.UpdateServices.Administration') | Out-Null | ||
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Recipe:: install | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -24,11 +24,11 @@ | |
|
||
setup_options = '' | ||
if setup_conf['sqlinstance_name'] | ||
if node['platform_version'].to_f >= 6.2 | ||
setup_options << " SQL_INSTANCE_NAME=\"#{setup_conf['sqlinstance_name']}\"" | ||
else | ||
setup_options << " SQLINSTANCE_NAME=\"#{setup_conf['sqlinstance_name']}\"" | ||
end | ||
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 | ||
|
||
if setup_conf['content_dir'] | ||
|
@@ -130,4 +130,4 @@ | |
end | ||
|
||
# Wsus does not need configuration when setup as frontend server | ||
include_recipe 'wsus-server::configure' unless setup_conf['frontend_setup'] | ||
include_recipe 'wsus-server::configure' unless setup_conf['frontend_setup'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Recipe:: report_viewer | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Attribute:: synchronize | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Resource:: configuration | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -20,10 +20,15 @@ | |
include WsusServer::BaseResource | ||
|
||
default_action :configure | ||
unified_mode true | ||
|
||
property :proxy_password, String | ||
property :update_languages, Array | ||
|
||
def initialize(name, run_context = nil) | ||
super(name, run_context) | ||
|
||
@properties = {} | ||
# Default computed value for master_server is nil | ||
@properties['UpstreamWsusServerName'] = nil | ||
@properties['SyncFromMicrosoftUpdate'] = true | ||
|
@@ -50,11 +55,3 @@ def master_server(arg = nil) | |
@properties['IsReplicaServer'] = true | ||
end | ||
end | ||
|
||
def proxy_password(arg = nil) | ||
set_or_return(:proxy_password, arg, kind_of: String) | ||
end | ||
|
||
def update_languages(arg = nil) | ||
set_or_return(:update_languages, arg, kind_of: Array) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# Author:: Baptiste Courtois (<[email protected]>) | ||
# Cookbook Name:: wsus-server | ||
# Cookbook:: wsus-server | ||
# Resource:: notification | ||
# | ||
# Copyright:: Copyright (c) 2014 Criteo. | ||
|
@@ -20,8 +20,17 @@ | |
include WsusServer::BaseResource | ||
|
||
default_action :configure | ||
unified_mode true | ||
|
||
FREQUENCY_VALUES = %w(Daily Weekly) | ||
FREQUENCY_VALUES = %w(Daily Weekly).freeze | ||
|
||
property :smtp_password, String | ||
|
||
def initialize(name, run_context = nil) | ||
super(name, run_context) | ||
|
||
@properties = {} | ||
end | ||
|
||
def enable_sync_notification(arg = nil) | ||
if arg.nil? | ||
|
@@ -79,10 +88,6 @@ def smtp_host(arg = nil) | |
end | ||
end | ||
|
||
def smtp_password(arg = nil) | ||
set_or_return(:smtp_password, arg, kind_of: String) | ||
end | ||
|
||
def smtp_port(arg = nil) | ||
if arg.nil? | ||
@properties['SmtpPort'] | ||
|
Oops, something went wrong.