Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh cookbook #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/criteo-cookbooks-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is a basic workflow to help you get started with Actions
name: Criteo Cookbooks CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]

jobs:
cookstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run Cookstyle
run: bundle exec cookstyle --display-cop-names --extra-details
rspec:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run RSpec
run: bundle exec rspec
supermarket:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [cookstyle, rspec]
steps:
- uses: actions/checkout@v4
- name: Publish to supermarket
uses: afaundez/chef-supermarket-action@8cdbe1cccbe1ecd8685b2ea8f48780135bae7cee
with:
user: criteo
cookbook: wsus-server
category: Package Management
env:
SUPERMARKET_API_KEY: ${{ secrets.SUPERMARKET_API_KEY }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pkg/
# Berkshelf
.vagrant
/cookbooks
Berksfile.lock
Policyfile.lock.json

# Bundler
Gemfile.lock
Expand Down
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

Binary file removed .travis/client.pem.enc
Binary file not shown.
3 changes: 0 additions & 3 deletions Berksfile

This file was deleted.

17 changes: 6 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
source 'https://rubygems.org'

gem 'rake'

group :test do
gem 'rspec-mocks'
gem 'chefspec', '>= 4.2'
gem 'fauxhai', '>= 2.2'
gem 'foodcritic', '>= 4.0'
gem 'gherkin', '~> 5.1'

platforms :mri_19 do
gem 'ohai', '~> 7.4.0'
end
gem 'chef', '= 17.9.46'
gem 'cookstyle', '>= 7.32.8'
gem 'fauxhai-chef', '>= 9.3.16'
# TODO: Unpin chefspec and remove rspec pin once chefspec integrates breaking rspec-expectations change
gem 'chefspec', '= 9.3.6'
gem 'rspec-expectations', '= 3.12.3'
end
8 changes: 8 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'wsus-server'

run_list %w(wsus-server)

default_source :supermarket

# Current cookbook
cookbook 'wsus-server', path: '.'
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
7 changes: 0 additions & 7 deletions Rakefile

This file was deleted.

2 changes: 1 addition & 1 deletion attributes/configure.rb
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.
Expand Down
2 changes: 1 addition & 1 deletion attributes/freeze.rb
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.
Expand Down
28 changes: 1 addition & 27 deletions attributes/install.rb
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.
Expand Down 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.

2 changes: 1 addition & 1 deletion attributes/synchronize.rb
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.
Expand Down
17 changes: 4 additions & 13 deletions libraries/base_provider.rb
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.
Expand All @@ -24,11 +24,6 @@ module BaseProvider
require 'yaml'
require 'base64'
include Chef::Mixin::ShellOut
include Windows::Helper

def whyrun_supported?
true
end

def self.uri_to_wsus_endpoint_params(uri)
uri = URI uri
Expand All @@ -50,11 +45,7 @@ def endpoint_params
@endpoint ||= @new_resource.endpoint ? WsusServer::BaseProvider.uri_to_wsus_endpoint_params(@new_resource.endpoint) : ''
end

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',
Expand All @@ -74,9 +65,9 @@ def powershell_out64(cmd, timeout=300)
# Use powershell with absolute path to the binary (it's the same path for all versions)
# Use the locate_sysnative helper to target the right powershell binary
# => https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187.aspx
cmd = shell_out "#{powershell} #{flags.join(' ')} -EncodedCommand #{encoded_command}", timeout: timeout
cmd = shell_out "powershell.exe #{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

Expand Down
21 changes: 6 additions & 15 deletions libraries/base_resource.rb
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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions libraries/matchers.rb

This file was deleted.

Loading
Loading