From 6e10c45c4bcbb221aba64b280eb4d3d1c4ef4de1 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Thu, 16 Apr 2020 14:26:40 -0700 Subject: [PATCH 1/9] Vendor cookbooks --- vendor-cookbooks/chocolatey/CHANGELOG.md | 110 +++ vendor-cookbooks/chocolatey/README.md | 45 + .../chocolatey/attributes/default.rb | 11 + vendor-cookbooks/chocolatey/files/install.ps1 | 345 +++++++ .../chocolatey/libraries/helpers.rb | 55 ++ vendor-cookbooks/chocolatey/metadata.json | 1 + .../chocolatey/recipes/default.rb | 40 + vendor-cookbooks/ohai/CHANGELOG.md | 205 +++++ vendor-cookbooks/ohai/CONTRIBUTING.md | 2 + vendor-cookbooks/ohai/README.md | 139 +++ .../ohai/libraries/hint_helpers.rb | 35 + .../ohai/libraries/plugin_helpers.rb | 77 ++ vendor-cookbooks/ohai/metadata.json | 1 + vendor-cookbooks/ohai/metadata.rb | 15 + vendor-cookbooks/ohai/recipes/default.rb | 20 + vendor-cookbooks/ohai/resources/hint.rb | 41 + vendor-cookbooks/ohai/resources/plugin.rb | 71 ++ vendor-cookbooks/seven_zip/.gitignore | 26 + .../seven_zip/.kitchen.appveyor.yml | 25 + vendor-cookbooks/seven_zip/.kitchen.yml | 28 + vendor-cookbooks/seven_zip/.rspec | 3 + vendor-cookbooks/seven_zip/.rubocop.yml | 16 + vendor-cookbooks/seven_zip/Berksfile | 7 + vendor-cookbooks/seven_zip/CHANGELOG.md | 52 ++ vendor-cookbooks/seven_zip/Gemfile | 8 + vendor-cookbooks/seven_zip/Gemfile.lock | 79 ++ vendor-cookbooks/seven_zip/LICENSE | 201 ++++ vendor-cookbooks/seven_zip/README.md | 114 +++ vendor-cookbooks/seven_zip/appveyor.yml | 42 + .../seven_zip/attributes/default.rb | 31 + vendor-cookbooks/seven_zip/chefignore | 98 ++ .../seven_zip/libraries/matchers.rb | 33 + vendor-cookbooks/seven_zip/metadata.json | 35 + vendor-cookbooks/seven_zip/metadata.rb | 12 + .../seven_zip/providers/archive.rb | 64 ++ vendor-cookbooks/seven_zip/rakefile.rb | 27 + vendor-cookbooks/seven_zip/recipes/default.rb | 24 + .../seven_zip/resources/archive.rb | 29 + vendor-cookbooks/seven_zip/resources/tool.rb | 47 + .../seven_zip/spec/default_spec.rb | 27 + .../seven_zip/spec/spec_helper.rb | 15 + .../test_archive/attributes/default.rb | 3 + .../cookbooks/test_archive/metadata.rb | 3 + .../cookbooks/test_archive/recipes/default.rb | 17 + .../default/serverspec/default_spec.rb | 27 + .../helpers/serverspec/spec_helper.rb | 4 + vendor-cookbooks/windows/CHANGELOG.md | 870 ++++++++++++++++++ vendor-cookbooks/windows/CONTRIBUTING.md | 2 + vendor-cookbooks/windows/README.md | 426 +++++++++ .../windows/libraries/powershell_helper.rb | 53 ++ .../windows/libraries/registry_helper.rb | 356 +++++++ vendor-cookbooks/windows/libraries/version.rb | 189 ++++ .../windows/libraries/version_helper.rb | 93 ++ .../windows/libraries/windows_helper.rb | 165 ++++ .../windows/libraries/windows_privileged.rb | 103 +++ .../windows/libraries/wmi_helper.rb | 34 + vendor-cookbooks/windows/metadata.json | 1 + vendor-cookbooks/windows/metadata.rb | 10 + vendor-cookbooks/windows/providers/dns.rb | 148 +++ vendor-cookbooks/windows/recipes/default.rb | 21 + .../windows/resources/certificate_binding.rb | 134 +++ vendor-cookbooks/windows/resources/dns.rb | 29 + .../windows/resources/http_acl.rb | 109 +++ .../windows/resources/schannel.rb | 39 + .../windows/resources/user_privilege.rb | 40 + vendor-cookbooks/windows/resources/zipfile.rb | 128 +++ 66 files changed, 5260 insertions(+) create mode 100644 vendor-cookbooks/chocolatey/CHANGELOG.md create mode 100644 vendor-cookbooks/chocolatey/README.md create mode 100644 vendor-cookbooks/chocolatey/attributes/default.rb create mode 100644 vendor-cookbooks/chocolatey/files/install.ps1 create mode 100644 vendor-cookbooks/chocolatey/libraries/helpers.rb create mode 100644 vendor-cookbooks/chocolatey/metadata.json create mode 100644 vendor-cookbooks/chocolatey/recipes/default.rb create mode 100644 vendor-cookbooks/ohai/CHANGELOG.md create mode 100644 vendor-cookbooks/ohai/CONTRIBUTING.md create mode 100644 vendor-cookbooks/ohai/README.md create mode 100644 vendor-cookbooks/ohai/libraries/hint_helpers.rb create mode 100644 vendor-cookbooks/ohai/libraries/plugin_helpers.rb create mode 100644 vendor-cookbooks/ohai/metadata.json create mode 100644 vendor-cookbooks/ohai/metadata.rb create mode 100644 vendor-cookbooks/ohai/recipes/default.rb create mode 100644 vendor-cookbooks/ohai/resources/hint.rb create mode 100644 vendor-cookbooks/ohai/resources/plugin.rb create mode 100644 vendor-cookbooks/seven_zip/.gitignore create mode 100644 vendor-cookbooks/seven_zip/.kitchen.appveyor.yml create mode 100644 vendor-cookbooks/seven_zip/.kitchen.yml create mode 100644 vendor-cookbooks/seven_zip/.rspec create mode 100644 vendor-cookbooks/seven_zip/.rubocop.yml create mode 100644 vendor-cookbooks/seven_zip/Berksfile create mode 100644 vendor-cookbooks/seven_zip/CHANGELOG.md create mode 100644 vendor-cookbooks/seven_zip/Gemfile create mode 100644 vendor-cookbooks/seven_zip/Gemfile.lock create mode 100644 vendor-cookbooks/seven_zip/LICENSE create mode 100644 vendor-cookbooks/seven_zip/README.md create mode 100644 vendor-cookbooks/seven_zip/appveyor.yml create mode 100644 vendor-cookbooks/seven_zip/attributes/default.rb create mode 100644 vendor-cookbooks/seven_zip/chefignore create mode 100644 vendor-cookbooks/seven_zip/libraries/matchers.rb create mode 100644 vendor-cookbooks/seven_zip/metadata.json create mode 100644 vendor-cookbooks/seven_zip/metadata.rb create mode 100644 vendor-cookbooks/seven_zip/providers/archive.rb create mode 100644 vendor-cookbooks/seven_zip/rakefile.rb create mode 100644 vendor-cookbooks/seven_zip/recipes/default.rb create mode 100644 vendor-cookbooks/seven_zip/resources/archive.rb create mode 100644 vendor-cookbooks/seven_zip/resources/tool.rb create mode 100644 vendor-cookbooks/seven_zip/spec/default_spec.rb create mode 100644 vendor-cookbooks/seven_zip/spec/spec_helper.rb create mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb create mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb create mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb create mode 100644 vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb create mode 100644 vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb create mode 100644 vendor-cookbooks/windows/CHANGELOG.md create mode 100644 vendor-cookbooks/windows/CONTRIBUTING.md create mode 100644 vendor-cookbooks/windows/README.md create mode 100644 vendor-cookbooks/windows/libraries/powershell_helper.rb create mode 100644 vendor-cookbooks/windows/libraries/registry_helper.rb create mode 100644 vendor-cookbooks/windows/libraries/version.rb create mode 100644 vendor-cookbooks/windows/libraries/version_helper.rb create mode 100644 vendor-cookbooks/windows/libraries/windows_helper.rb create mode 100644 vendor-cookbooks/windows/libraries/windows_privileged.rb create mode 100644 vendor-cookbooks/windows/libraries/wmi_helper.rb create mode 100644 vendor-cookbooks/windows/metadata.json create mode 100644 vendor-cookbooks/windows/metadata.rb create mode 100644 vendor-cookbooks/windows/providers/dns.rb create mode 100644 vendor-cookbooks/windows/recipes/default.rb create mode 100644 vendor-cookbooks/windows/resources/certificate_binding.rb create mode 100644 vendor-cookbooks/windows/resources/dns.rb create mode 100644 vendor-cookbooks/windows/resources/http_acl.rb create mode 100644 vendor-cookbooks/windows/resources/schannel.rb create mode 100644 vendor-cookbooks/windows/resources/user_privilege.rb create mode 100644 vendor-cookbooks/windows/resources/zipfile.rb diff --git a/vendor-cookbooks/chocolatey/CHANGELOG.md b/vendor-cookbooks/chocolatey/CHANGELOG.md new file mode 100644 index 0000000..8323621 --- /dev/null +++ b/vendor-cookbooks/chocolatey/CHANGELOG.md @@ -0,0 +1,110 @@ +# Changelog for Chocolatey cookbook + +## v2.0.1 (2018-07-03) + +- Remove mentions of the package provider from the readme and metadata + +## v2.0.0 (2018-05-01) + +### Breaking Change + +The package LWRP has been removed from this cookbook. chocolatey_package was integrated into Chef 12.7, which was released in Feb 2016\. This cookbook now requires Chef 12.7 or later. + +### Other Changes + +- This cookbook no longer requires the Windows cookbook +- The install script has been updated to the latest Chocolatey install script +- Converted testing to use Delivery Local Mode from within ChefDK + +## v1.2.1 (2017-08-20) + +- Explicitly use the double-dash long option names for `--source` and `--installargs` + +## v1.2.0 (2017-05-04) + +- Change the default `['chocolatey']['upgrade']` attribute value to `false`. Preventing chocolatey from reinstalling every chef run + +## v1.1.1 (2017-04-22) + +- Fix chef 13 converges renaming conflicting `env_path` method + +## v1.1.0 (2017-01-09) + +- Update the chocolatey install script to match chocolatey.org. + +## v1.0.3 (2016-09-12) + +- Loosen windows-cookbook constraint + +## v1.0.2 (2016-08-29) + +- Ensure `chocolateyVersion` attribute is used and the correct version of chocolatey is installed. + +## v1.0.1 (2016-07-15) + +- Always execute chocolatey installer unless guard is satisfied to allow the install to retry on subsequent attempts if it fails. + +## v1.0.0 (2016-03-07) + +- No longer dependent on chocolatey.org for install script +- Removed deprecated overwriting of the current_resource and fixed visibility problem with `env_path` + +## v0.6.2 (2016-01-07) + +- Fix Chocolatey detection on chef clients older than 12.4.0 + +## v0.6.1 (2015-11-24) + +- Fix LocalJumpError on existing chocolatey package + +## v0.6.0 (2015-11-17) + +- Path Tracking. Tracking additions to the user and machine %PATH% environment and merging them into the current process. +- Downcase package name results from choco upgrade. + +## v0.5.1 (2015-11-10) + +- Prepend library include with :: in provder to fix 12.3.0 and likely other versions older than 12.5.1. +- Add backward compatibiliy to new metadata.rb attributes `source_url` and `issues_url`. + +## v0.5.0 (2015-11-09) + +- Refactored install script (and .kitchen.yml) to support installing Chocolatey in test-kitchen behind a proxy. +- Download `node['chocolatey']['Uri']` via `remote_file` resource instead of .net web client +- Set `chocolateyProxyLocation` environment variable to `Chef::Config['https_proxy']` if one is set before chocolatey install +- Changed helpers module namespacing from: `ChocolateyHelpers` to `Chocolatey::Helpers` +- Add ChefSpec unit tests +- Add ServerSpec integration tests +- Gemfile: bump foodcritic to 5.0 and Berkshelf to 4.0 +- Add ChefSpec matchers + +## v0.4.1 (2015-10-15) + +- Adds example how to install package with version +- use the vanilla script resource to bypass 64bit interpreter builder introduced in Chef 12.5 + +## v0.4.0 (2015-06-30) + +- Refactor script to download Chocolatey install script +- Chocolatey install: add proxy support +- fix for 64-bit chocolatey installs + +## v0.3.0 (2015-04-20) + +- Support for chocolatey >= 0.9.9 +- Make package name case insensitive + +## v0.2.0 (2014-09-24) + +- Allow spaces in the path to the "choco" command. +- Update tests to use Rakefile +- Support Chocolatey version 0.9.8.24+ +- Support custom command line options when installing packages + +## v0.1.0 (2014-02-20) + +- Fix and tests + +## v0.0.5 (2013-04-30) + +- Initial release diff --git a/vendor-cookbooks/chocolatey/README.md b/vendor-cookbooks/chocolatey/README.md new file mode 100644 index 0000000..12cb8d3 --- /dev/null +++ b/vendor-cookbooks/chocolatey/README.md @@ -0,0 +1,45 @@ +# chocolatey Cookbook + +[![Cookbook Version](https://img.shields.io/cookbook/v/chocolatey.svg)](https://supermarket.getchef.com/cookbooks/chocolatey) [![Build Status](http://img.shields.io/travis/chocolatey/chocolatey-cookbook/master.svg)](https://travis-ci.org/chocolatey/chocolatey-cookbook) + +Install Chocolatey with the default recipe. + +## Requirements + +### Platform + +- Windows + +### Chef + +- 12.7 or greater + +## Notes + +As of Chocolatey version [0.9.8.24](https://github.com/chocolatey/chocolatey/blob/master/CHANGELOG.md#09824-july-3-2014) the install directory for Chocolatey has changed from `C:\Chocolatey` to `C:\ProgramData\Chocolatey`. + +More information can be gotten from the [Chocolateywiki](https://github.com/chocolatey/chocolatey/wiki/DefaultChocolateyInstallReasoning). + +## Attributes + +All attributes below are pre-pended with `node['chocolatey']` + +Attribute | Description | Type | Default +---------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------- +`['upgrade']` | Whether to upgrade Chocolatey if it's already installed | Boolean | false +`['install_vars']['chocolateyProxyLocation']` | HTTPS proxy for Chocolatey install script | String | Chef::Config['https_proxy'] or ENV['https_proxy'] +`['install_vars']['chocolateyProxyUser']` | Proxy user for authenticating proxies | String | nil +`['install_vars']['chocolateyProxyPassword']` | Proxy user password | String | nil +`['install_vars']['chocolateyVersion']` | Version of Chocolatey to install, e.g. '0.9.9.11' | String | nil (download latest version) +`['install_vars']['chocolateyDownloadUrl']` | Chocolatey .nupkg file URL. Use this if you host an internal copy of the chocolatey.nupkg | String | (download from chocolatey.org) +`['install_vars']['chocolateyUseWindowsCompression']`| To use built-in compression instead of 7zip (requires additional download) set to `true` | String | nil (use 7zip) + +## Recipes + +- `chocolatey::default` - installs Chocolatey + +## License and Maintainer + +Maintainer:: Guilhem Lettron ([guilhem@lettron.fr](mailto:guilhem@lettron.fr)) + +License:: Apache 2.0 diff --git a/vendor-cookbooks/chocolatey/attributes/default.rb b/vendor-cookbooks/chocolatey/attributes/default.rb new file mode 100644 index 0000000..9ff8005 --- /dev/null +++ b/vendor-cookbooks/chocolatey/attributes/default.rb @@ -0,0 +1,11 @@ +default['chocolatey']['upgrade'] = false + +# Chocolatey install.ps1 env vars. See https://chocolatey.org/install.ps1 +default['chocolatey']['install_vars'].tap do |env| + env['chocolateyProxyLocation'] = Chef::Config['https_proxy'] || ENV['https_proxy'] + env['chocolateyProxyUser'] = nil + env['chocolateyProxyPassword'] = nil + env['chocolateyVersion'] = nil + env['chocolateyDownloadUrl'] = 'https://chocolatey.org/api/v2/package/chocolatey' + env['chocolateyUseWindowsCompression'] = nil +end diff --git a/vendor-cookbooks/chocolatey/files/install.ps1 b/vendor-cookbooks/chocolatey/files/install.ps1 new file mode 100644 index 0000000..5e65268 --- /dev/null +++ b/vendor-cookbooks/chocolatey/files/install.ps1 @@ -0,0 +1,345 @@ +# ===================================================================== +# Copyright 2017 Chocolatey Software, Inc, and the +# original authors/contributors from ChocolateyGallery +# Copyright 2011 - 2017 RealDimensions Software, LLC, and the +# original authors/contributors from ChocolateyGallery +# at https://github.com/chocolatey/chocolatey.org +# +# 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. +# ===================================================================== + +# Environment Variables, specified as $env:NAME in PowerShell.exe and %NAME% in cmd.exe. +# For explicit proxy, please set $env:chocolateyProxyLocation and optionally $env:chocolateyProxyUser and $env:chocolateyProxyPassword +# For an explicit version of Chocolatey, please set $env:chocolateyVersion = 'versionnumber' +# To target a different url for chocolatey.nupkg, please set $env:chocolateyDownloadUrl = 'full url to nupkg file' +# NOTE: $env:chocolateyDownloadUrl does not work with $env:chocolateyVersion. +# To use built-in compression instead of 7zip (requires additional download), please set $env:chocolateyUseWindowsCompression = 'true' +# To bypass the use of any proxy, please set $env:chocolateyIgnoreProxy = 'true' + +#specifically use the API to get the latest version (below) +$url = '' + +$chocolateyVersion = $env:chocolateyVersion +if (![string]::IsNullOrEmpty($chocolateyVersion)){ + Write-Output "Downloading specific version of Chocolatey: $chocolateyVersion" + $url = "https://chocolatey.org/api/v2/package/chocolatey/$chocolateyVersion" +} + +$chocolateyDownloadUrl = $env:chocolateyDownloadUrl +if (![string]::IsNullOrEmpty($chocolateyDownloadUrl)){ + Write-Output "Downloading Chocolatey from : $chocolateyDownloadUrl" + $url = "$chocolateyDownloadUrl" +} + +if ($env:TEMP -eq $null) { + $env:TEMP = Join-Path $env:SystemDrive 'temp' +} +$chocTempDir = Join-Path $env:TEMP "chocolatey" +$tempDir = Join-Path $chocTempDir "chocInstall" +if (![System.IO.Directory]::Exists($tempDir)) {[void][System.IO.Directory]::CreateDirectory($tempDir)} +$file = Join-Path $tempDir "chocolatey.zip" + +# PowerShell v2/3 caches the output stream. Then it throws errors due +# to the FileStream not being what is expected. Fixes "The OS handle's +# position is not what FileStream expected. Do not use a handle +# simultaneously in one FileStream and in Win32 code or another +# FileStream." +function Fix-PowerShellOutputRedirectionBug { + $poshMajorVerion = $PSVersionTable.PSVersion.Major + + if ($poshMajorVerion -lt 4) { + try{ + # http://www.leeholmes.com/blog/2008/07/30/workaround-the-os-handles-position-is-not-what-filestream-expected/ plus comments + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" + $objectRef = $host.GetType().GetField("externalHostRef", $bindingFlags).GetValue($host) + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetProperty" + $consoleHost = $objectRef.GetType().GetProperty("Value", $bindingFlags).GetValue($objectRef, @()) + [void] $consoleHost.GetType().GetProperty("IsStandardOutputRedirected", $bindingFlags).GetValue($consoleHost, @()) + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" + $field = $consoleHost.GetType().GetField("standardOutputWriter", $bindingFlags) + $field.SetValue($consoleHost, [Console]::Out) + [void] $consoleHost.GetType().GetProperty("IsStandardErrorRedirected", $bindingFlags).GetValue($consoleHost, @()) + $field2 = $consoleHost.GetType().GetField("standardErrorWriter", $bindingFlags) + $field2.SetValue($consoleHost, [Console]::Error) + } catch { + Write-Output "Unable to apply redirection fix." + } + } +} + +Fix-PowerShellOutputRedirectionBug + +# Attempt to set highest encryption available for SecurityProtocol. +# PowerShell will not set this by default (until maybe .NET 4.6.x). This +# will typically produce a message for PowerShell v2 (just an info +# message though) +try { + # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) + # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't + # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is + # installed (.NET 4.5 is an in-place upgrade). + [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 +} catch { + Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to do one or more of the following: (1) upgrade to .NET Framework 4.5+ and PowerShell v3, (2) specify internal Chocolatey package location (set $env:chocolateyDownloadUrl prior to install or host the package internally), (3) use the Download + PowerShell method of install. See https://chocolatey.org/install for all install options.' +} + +function Get-Downloader { +param ( + [string]$url + ) + + $downloader = new-object System.Net.WebClient + + $defaultCreds = [System.Net.CredentialCache]::DefaultCredentials + if ($defaultCreds -ne $null) { + $downloader.Credentials = $defaultCreds + } + + $ignoreProxy = $env:chocolateyIgnoreProxy + if ($ignoreProxy -ne $null -and $ignoreProxy -eq 'true') { + Write-Debug "Explicitly bypassing proxy due to user environment variable" + $downloader.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy() + } else { + # check if a proxy is required + $explicitProxy = $env:chocolateyProxyLocation + $explicitProxyUser = $env:chocolateyProxyUser + $explicitProxyPassword = $env:chocolateyProxyPassword + if ($explicitProxy -ne $null -and $explicitProxy -ne '') { + # explicit proxy + $proxy = New-Object System.Net.WebProxy($explicitProxy, $true) + if ($explicitProxyPassword -ne $null -and $explicitProxyPassword -ne '') { + $passwd = ConvertTo-SecureString $explicitProxyPassword -AsPlainText -Force + $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($explicitProxyUser, $passwd) + } + + Write-Debug "Using explicit proxy server '$explicitProxy'." + $downloader.Proxy = $proxy + + } elseif (!$downloader.Proxy.IsBypassed($url)) { + # system proxy (pass through) + $creds = $defaultCreds + if ($creds -eq $null) { + Write-Debug "Default credentials were null. Attempting backup method" + $cred = get-credential + $creds = $cred.GetNetworkCredential(); + } + + $proxyaddress = $downloader.Proxy.GetProxy($url).Authority + Write-Debug "Using system proxy server '$proxyaddress'." + $proxy = New-Object System.Net.WebProxy($proxyaddress) + $proxy.Credentials = $creds + $downloader.Proxy = $proxy + } + } + + return $downloader +} + +function Download-String { +param ( + [string]$url + ) + $downloader = Get-Downloader $url + + return $downloader.DownloadString($url) +} + +function Download-File { +param ( + [string]$url, + [string]$file + ) + #Write-Output "Downloading $url to $file" + $downloader = Get-Downloader $url + + $downloader.DownloadFile($url, $file) +} + +if ($url -eq $null -or $url -eq '') { + Write-Output "Getting latest version of the Chocolatey package for download." + $url = 'https://chocolatey.org/api/v2/Packages()?$filter=((Id%20eq%20%27chocolatey%27)%20and%20(not%20IsPrerelease))%20and%20IsLatestVersion' + [xml]$result = Download-String $url + $url = $result.feed.entry.content.src +} + +# Download the Chocolatey package + +Write-Output "Getting Chocolatey from $url." +Download-File $url $file + +# Determine unzipping method +# 7zip is the most compatible so use it by default +$7zaExe = Join-Path $tempDir '7za.exe' +$unzipMethod = '7zip' +$useWindowsCompression = $env:chocolateyUseWindowsCompression +if ($useWindowsCompression -ne $null -and $useWindowsCompression -eq 'true') { + Write-Output 'Using built-in compression to unzip' + $unzipMethod = 'builtin' +} elseif (-Not (Test-Path ($7zaExe))) { + Write-Output "Downloading 7-Zip commandline tool prior to extraction." + # download 7zip + Download-File 'https://chocolatey.org/7za.exe' "$7zaExe" +} + +#if ($useWindowsCompression -eq $null -or $windowsCompression -eq '') { +# Write-Output 'Using 7zip to unzip.' +# Write-Warning "The default is currently 7zip to better handle things like Server Core. This default will be changed to use built-in compression in December 2016. Please make sure if you need to use 7zip that you have adjusted your scripts to set `$env:chocolateyUseWindowsCompression = 'false' prior to calling the install." +# $unzipMethod = '7zip' +#} + +# unzip the package +Write-Output "Extracting $file to $tempDir..." +if ($unzipMethod -eq '7zip') { + $params = "x -o`"$tempDir`" -bd -y `"$file`"" + # use more robust Process as compared to Start-Process -Wait (which doesn't + # wait for the process to finish in PowerShell v3) + $process = New-Object System.Diagnostics.Process + $process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($7zaExe, $params) + $process.StartInfo.RedirectStandardOutput = $true + $process.StartInfo.UseShellExecute = $false + $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden + $process.Start() | Out-Null + $process.BeginOutputReadLine() + $process.WaitForExit() + $exitCode = $process.ExitCode + $process.Dispose() + + $errorMessage = "Unable to unzip package using 7zip. Perhaps try setting `$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:" + switch ($exitCode) { + 0 { break } + 1 { throw "$errorMessage Some files could not be extracted" } + 2 { throw "$errorMessage 7-Zip encountered a fatal error while extracting the files" } + 7 { throw "$errorMessage 7-Zip command line error" } + 8 { throw "$errorMessage 7-Zip out of memory" } + 255 { throw "$errorMessage Extraction cancelled by the user" } + default { throw "$errorMessage 7-Zip signalled an unknown error (code $exitCode)" } + } +} else { + if ($PSVersionTable.PSVersion.Major -lt 5) { + try { + $shellApplication = new-object -com shell.application + $zipPackage = $shellApplication.NameSpace($file) + $destinationFolder = $shellApplication.NameSpace($tempDir) + $destinationFolder.CopyHere($zipPackage.Items(),0x10) + } catch { + throw "Unable to unzip package using built-in compression. Set `$env:chocolateyUseWindowsCompression = 'false' and call install again to use 7zip to unzip. Error: `n $_" + } + } else { + Expand-Archive -Path "$file" -DestinationPath "$tempDir" -Force + } +} + +# Call chocolatey install +Write-Output "Installing chocolatey on this machine" +$toolsFolder = Join-Path $tempDir "tools" +$chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1" + +& $chocInstallPS1 + +Write-Output 'Ensuring chocolatey commands are on the path' +$chocInstallVariableName = "ChocolateyInstall" +$chocoPath = [Environment]::GetEnvironmentVariable($chocInstallVariableName) +if ($chocoPath -eq $null -or $chocoPath -eq '') { + $chocoPath = "$env:ALLUSERSPROFILE\Chocolatey" +} + +if (!(Test-Path ($chocoPath))) { + $chocoPath = "$env:SYSTEMDRIVE\ProgramData\Chocolatey" +} + +$chocoExePath = Join-Path $chocoPath 'bin' + +if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower()) -eq $false) { + $env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine); +} + +Write-Output 'Ensuring chocolatey.nupkg is in the lib folder' +$chocoPkgDir = Join-Path $chocoPath 'lib\chocolatey' +$nupkg = Join-Path $chocoPkgDir 'chocolatey.nupkg' +if (![System.IO.Directory]::Exists($chocoPkgDir)) { [System.IO.Directory]::CreateDirectory($chocoPkgDir); } +Copy-Item "$file" "$nupkg" -Force -ErrorAction SilentlyContinue + +# SIG # Begin signature block +# MIINVQYJKoZIhvcNAQcCoIINRjCCDUICAQExDzANBglghkgBZQMEAgEFADB5Bgor +# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBtI1XhNa+BTJDA +# Udd7cvDCY121zDB7LmEXLgQMpQmPnqCCCnIwggUwMIIEGKADAgECAhAECRgbX9W7 +# ZnVTQ7VvlVAIMA0GCSqGSIb3DQEBCwUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK +# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV +# BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0xMzEwMjIxMjAwMDBa +# Fw0yODEwMjIxMjAwMDBaMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2Vy +# dCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lD +# ZXJ0IFNIQTIgQXNzdXJlZCBJRCBDb2RlIFNpZ25pbmcgQ0EwggEiMA0GCSqGSIb3 +# DQEBAQUAA4IBDwAwggEKAoIBAQD407Mcfw4Rr2d3B9MLMUkZz9D7RZmxOttE9X/l +# qJ3bMtdx6nadBS63j/qSQ8Cl+YnUNxnXtqrwnIal2CWsDnkoOn7p0WfTxvspJ8fT +# eyOU5JEjlpB3gvmhhCNmElQzUHSxKCa7JGnCwlLyFGeKiUXULaGj6YgsIJWuHEqH +# CN8M9eJNYBi+qsSyrnAxZjNxPqxwoqvOf+l8y5Kh5TsxHM/q8grkV7tKtel05iv+ +# bMt+dDk2DZDv5LVOpKnqagqrhPOsZ061xPeM0SAlI+sIZD5SlsHyDxL0xY4PwaLo +# LFH3c7y9hbFig3NBggfkOItqcyDQD2RzPJ6fpjOp/RnfJZPRAgMBAAGjggHNMIIB +# yTASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjATBgNVHSUEDDAK +# BggrBgEFBQcDAzB5BggrBgEFBQcBAQRtMGswJAYIKwYBBQUHMAGGGGh0dHA6Ly9v +# Y3NwLmRpZ2ljZXJ0LmNvbTBDBggrBgEFBQcwAoY3aHR0cDovL2NhY2VydHMuZGln +# aWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJlZElEUm9vdENBLmNydDCBgQYDVR0fBHow +# eDA6oDigNoY0aHR0cDovL2NybDQuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJl +# ZElEUm9vdENBLmNybDA6oDigNoY0aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0Rp +# Z2lDZXJ0QXNzdXJlZElEUm9vdENBLmNybDBPBgNVHSAESDBGMDgGCmCGSAGG/WwA +# AgQwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzAK +# BghghkgBhv1sAzAdBgNVHQ4EFgQUWsS5eyoKo6XqcQPAYPkt9mV1DlgwHwYDVR0j +# BBgwFoAUReuir/SSy4IxLVGLp6chnfNtyA8wDQYJKoZIhvcNAQELBQADggEBAD7s +# DVoks/Mi0RXILHwlKXaoHV0cLToaxO8wYdd+C2D9wz0PxK+L/e8q3yBVN7Dh9tGS +# dQ9RtG6ljlriXiSBThCk7j9xjmMOE0ut119EefM2FAaK95xGTlz/kLEbBw6RFfu6 +# r7VRwo0kriTGxycqoSkoGjpxKAI8LpGjwCUR4pwUR6F6aGivm6dcIFzZcbEMj7uo +# +MUSaJ/PQMtARKUT8OZkDCUIQjKyNookAv4vcn4c10lFluhZHen6dGRrsutmQ9qz +# sIzV6Q3d9gEgzpkxYz0IGhizgZtPxpMQBvwHgfqL2vmCSfdibqFT+hKUGIUukpHq +# aGxEMrJmoecYpJpkUe8wggU6MIIEIqADAgECAhAGsBFbtfCQ0/DaDmIsYn1YMA0G +# CSqGSIb3DQEBCwUAMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJ +# bmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lDZXJ0 +# IFNIQTIgQXNzdXJlZCBJRCBDb2RlIFNpZ25pbmcgQ0EwHhcNMTcwMzI4MDAwMDAw +# WhcNMTgwNDAzMTIwMDAwWjB3MQswCQYDVQQGEwJVUzEPMA0GA1UECBMGS2Fuc2Fz +# MQ8wDQYDVQQHEwZUb3Bla2ExIjAgBgNVBAoTGUNob2NvbGF0ZXkgU29mdHdhcmUs +# IEluYy4xIjAgBgNVBAMTGUNob2NvbGF0ZXkgU29mdHdhcmUsIEluYy4wggEiMA0G +# CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLIWIaEiqkPbIMZi6jD6J8F3YIYPxG +# 3Vw2I8AsM5c63WUmV+bYZQGxY5AHHVFphy9mU6spXgAqVpzkcALjo1oArVscUU34 +# 8S4mokGbZVvHlO8ny1b1HzfR4ZPHpUL71btSqpcOElYOOL0wUnf5As/39VN+Wxef +# //D5KTDD17AA2DVvIaXMT+utERbo+c+leaPS4fKo/Q0KvpCt0sKr6LItAMNgaqL4 +# 9Z+Dg5n1oHjxAz4ZYhJYdHIPZPoqyeLQ8IuYiqCxKS07tkfvkwlgWxksHpliIKqf +# Jpv0YE2vqlZrcx0WYHNhgX3BIhQa21wxn/XAFNCpgrDgI0u0UupZfxAdAgMBAAGj +# ggHFMIIBwTAfBgNVHSMEGDAWgBRaxLl7KgqjpepxA8Bg+S32ZXUOWDAdBgNVHQ4E +# FgQUJqUaP1/S0OF1EG1dxC6UzM6w6T8wDgYDVR0PAQH/BAQDAgeAMBMGA1UdJQQM +# MAoGCCsGAQUFBwMDMHcGA1UdHwRwMG4wNaAzoDGGL2h0dHA6Ly9jcmwzLmRpZ2lj +# ZXJ0LmNvbS9zaGEyLWFzc3VyZWQtY3MtZzEuY3JsMDWgM6Axhi9odHRwOi8vY3Js +# NC5kaWdpY2VydC5jb20vc2hhMi1hc3N1cmVkLWNzLWcxLmNybDBMBgNVHSAERTBD +# MDcGCWCGSAGG/WwDATAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2Vy +# dC5jb20vQ1BTMAgGBmeBDAEEATCBhAYIKwYBBQUHAQEEeDB2MCQGCCsGAQUFBzAB +# hhhodHRwOi8vb2NzcC5kaWdpY2VydC5jb20wTgYIKwYBBQUHMAKGQmh0dHA6Ly9j +# YWNlcnRzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydFNIQTJBc3N1cmVkSURDb2RlU2ln +# bmluZ0NBLmNydDAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQCLBAE/ +# 2x4amEecDEoy9g+WmWMROiB4GnkPqj+IbiwftmwC5/7yL3/592HOFMJr0qOgUt51 +# moE8SuuLuOGw63c5+/48LJS4jP2XzbVNByRPIxPWorm4t/OzTJNziTowHQ+wLwwI +# 8U97+8DaHCNL7iLZNEiqbVlpF3j7SMWGgf2BVYADJyxluNzf0ZUO+lXN4gOkM8tl +# VDc7SjZEKvu6ckAaxXf7NPbCXVL/3+LvdmoLbT3vJlfzeXqduO3oieB10ic3ug5T +# XtoYmyEk/P3yR3x/TqUlg1x/xaolBxy5TyMeSLcBlYn42fnQL154bvMGwFiCsHWQ +# wY09I0xpEysOMiy8MYICOTCCAjUCAQEwgYYwcjELMAkGA1UEBhMCVVMxFTATBgNV +# BAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTExMC8G +# A1UEAxMoRGlnaUNlcnQgU0hBMiBBc3N1cmVkIElEIENvZGUgU2lnbmluZyBDQQIQ +# BrARW7XwkNPw2g5iLGJ9WDANBglghkgBZQMEAgEFAKCBhDAYBgorBgEEAYI3AgEM +# MQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQB +# gjcCAQsxDjAMBgorBgEEAYI3AgEVMC8GCSqGSIb3DQEJBDEiBCA30tiIkQr58z/E +# B7+e4qnBMyyqgtyBNCzS+4Lf0KDlwTANBgkqhkiG9w0BAQEFAASCAQB0y8X6HZlj +# VVxJY4s+6XYx/QM6a8KCe1oTwPt++jafTuOCZkv4LaFONT8jQO+ddPYhkeNv2D1v +# xjJu7oU2vsbwdHGdgOFdaCvjce+6j4FqJ6QvFT4CbIYgq5F+dJ6idy9i0f2Wa4N9 +# Ei8bJ2C5ruOwDbDtPeoGP5+H4ehHqHKY1ubVXdm5nOKrB0XRxroUykAZbzho7OHv +# UZ3uA7RX0CvDJ78hEAn5Zg3MsMB1e7B3B5m9DKbPTa/k6q65uVDDNZE66GEyzQ04 +# lqUJK2K9SNM7MmSJkCga40y02t0OTR8w+V8Ev4GPL47Ubu3fLetknY2Z5r+b1+eu +# camDGbsbstoG +# SIG # End signature block diff --git a/vendor-cookbooks/chocolatey/libraries/helpers.rb b/vendor-cookbooks/chocolatey/libraries/helpers.rb new file mode 100644 index 0000000..1d4b36c --- /dev/null +++ b/vendor-cookbooks/chocolatey/libraries/helpers.rb @@ -0,0 +1,55 @@ +module Chocolatey + module Helpers + # include the PowershellOut module from the windows cookbook + # in case we are running an older chef client + include Chef::Mixin::PowershellOut + + # Get the ChocolateyInstall directory from the environment. + def chocolatey_install + ENV.fetch('ChocolateyInstall') { |env_var| machine_env_var(env_var) } + end + + # The Chocolatey command. + # + # Reference: https://github.com/chocolatey/chocolatey-cookbook/pull/16#issuecomment-47975896 + def chocolatey_executable + "\"#{::File.join(chocolatey_install, 'bin', 'choco')}\"" + end + + def chocolatey_lib_dir + File.join(chocolatey_install, 'lib', 'chocolatey') + end + + # Check if Chocolatey is installed + def chocolatey_installed? + return @is_chocolatey_installed if @is_chocolatey_installed + return false if chocolatey_install.nil? + # choco /? returns an exit status of -1 with chocolatey 0.9.9 => use list + cmd = Mixlib::ShellOut.new("#{chocolatey_executable} list -l chocolatey") + cmd.run_command + @is_chocolatey_installed = cmd.exitstatus == 0 + end + + # combine the local path with the user and machine paths + def environment_path(local_path) + machine = env_var('PATH', 'MACHINE').split(';') + user = env_var('PATH', 'USER').split(';') + local = local_path.split(';') + combined = local.concat(machine).concat(user).uniq.compact + combined.join(';') + end + + private + + def machine_env_var(env_var) + env_var(env_var, 'MACHINE') + end + + def env_var(env_var, scope) + env_var = powershell_out!( + "[System.Environment]::GetEnvironmentVariable('#{env_var}', '#{scope}')" + ) + env_var.stdout.chomp + end + end +end diff --git a/vendor-cookbooks/chocolatey/metadata.json b/vendor-cookbooks/chocolatey/metadata.json new file mode 100644 index 0000000..fec3ac0 --- /dev/null +++ b/vendor-cookbooks/chocolatey/metadata.json @@ -0,0 +1 @@ +{"name":"chocolatey","version":"2.0.1","description":"Install Chocolatey on Windows","long_description":"Installs the Chocolatey package manager for Windows.","maintainer":"Guilhem Lettron","maintainer_email":"guilhem.lettron@youscribe.com","license":"Apache-2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chocolatey/chocolatey-cookbook","issues_url":"https://github.com/chocolatey/chocolatey-cookbook/issues","chef_version":[[">= 12.7"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/chocolatey/recipes/default.rb b/vendor-cookbooks/chocolatey/recipes/default.rb new file mode 100644 index 0000000..4593360 --- /dev/null +++ b/vendor-cookbooks/chocolatey/recipes/default.rb @@ -0,0 +1,40 @@ +# +# Cookbook Name:: chocolatey +# recipe:: default +# Author:: Guilhem Lettron +# +# Copyright 2012, Societe Publica. +# Copyright 2015, Doug Ireton +# +# 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. +# +unless platform_family?('windows') + return "Chocolatey install not supported on #{node['platform_family']}" +end + +Chef::Resource.send(:include, Chocolatey::Helpers) + +install_ps1 = File.join(Chef::Config['file_cache_path'], 'chocolatey-install.ps1') + +cookbook_file install_ps1 do + action :create + backup false + source 'install.ps1' +end + +powershell_script 'Install Chocolatey' do + environment node['chocolatey']['install_vars'] + cwd Chef::Config['file_cache_path'] + code install_ps1 + not_if { chocolatey_installed? && (node['chocolatey']['upgrade'] == false) } +end diff --git a/vendor-cookbooks/ohai/CHANGELOG.md b/vendor-cookbooks/ohai/CHANGELOG.md new file mode 100644 index 0000000..f0caadb --- /dev/null +++ b/vendor-cookbooks/ohai/CHANGELOG.md @@ -0,0 +1,205 @@ +# ohai Cookbook CHANGELOG + +This file is used to list changes made in each version of the ohai cookbook. + +## 5.3.0 (2019-08-29) + +- Add code owners file - [@tas50](https://github.com/tas50) +- Cookstyle fixes - [@tas50](https://github.com/tas50) +- Require Chef 13 or later - [@tas50](https://github.com/tas50) +- Remove the long_description metadata - [@tas50](https://github.com/tas50) +- Add the load_single_plugin option to the ohai_plugin resource - [@MarkGibbons](https://github.com/MarkGibbons) +- Update for Chef 15 license agreement and Chef Workstation - [@tas50](https://github.com/tas50) +- Update the platforms we test on in Travis / Test Kitchen - [@tas50](https://github.com/tas50) + +## 5.2.5 (2018-09-04) + +- Add note that ohai_hint will be removed April 2019 when Chef 13 goes EOL as this resource now ships in Chef 14+ + +## 5.2.4 (2018-08-28) + +- Avoid deprecation warnings in Chef 14.3+ by not loading resources already in Chef + +## 5.2.3 (2018-06-08) + +- Make sure we properly compare a provided plugin path to the path on disk by stripping trailing slashes from the provided directory +- Don't reload ohai when the plugin exists in a subdirectory of the config's set plugin path + +## 5.2.2 (2018-02-15) + +- Remove ChefSpec matchers we no longer need since they're auto generated + +## 5.2.1 (2018-01-25) + +- Switch from a .foodcritic file to an inline comments which resolve Supermarket warnings +- Remove unused helper method + +## 5.2.0 (2017-08-17) + +- Resolve multiple issues with Windows paths that caused the cookbook to converge on every run or fail +- Move maintainer information to the readme +- Add testing on Chef 12.7 in Travis +- Move helpers to their own modules and add testing framework + +## 5.1.0 (2017-05-06) + +- Workaround action_class bug by requiring Chef 12.7+ + +## 5.0.4 (2017-04-25) + +- Fix lack of .rb extension when deleting plugins. + +## 5.0.3 (2017-04-06) + +- Use class_eval again in the custom resource to provide Chef 12.5/12.6 compatibility +- Remove kind_of and use name_property not name_attribute +- Fix failures on Chef 13 + +## 5.0.2 (2017-03-24) + +- Remove class_eval + +## 5.0.1 (2017-03-14) + +- Test with Delivery Local Mode +- Bump the dependency to 12.7+ due to failures on 12.5-12.6 + +## 5.0.0 (2017-02-23) + +- Require Chef 12.5+ and remove compat_resource dependency + +## 4.2.3 (2016-12-02) +- Prevent chef_version metadata from failing runs in Opsworks +- Better explain how to resolve the plugin_path issue +- Add suse as a supported platform +- Require at least compat_resource 12.14.7 + +## 4.2.2 (2016-09-19) +- Ignore case in plugin path check on Windows + +## 4.2.1 (2016-09-08) +- Fix typo in compile warning text +- Depend on the latest compat_resource (12.14) +- Remove Chef 11 compat in the metadata +- Require Chef 12.1 not 12.0 +- Define ohai_plugin matcher for Chefspec + +## v4.2.0 (2016-07-19) + +- Added the ability to specify the source cookbook for the cookbook_file or template used in the ohai_plugin resource. +- Added chef_version to the metadata +- Added testing on openSUSE and switched from Rubocop to Cookstyle + +## v4.1.1 (2016-06-16) + +- Fixed error in notifies reload for the delete action +- Bump the compat_resource requirement from 12.9+ to 12.10+ to prevent random failures + +## v4.1.0 (2016-05-26) + +- Added the ability to use templates and pass in variables with the plugin custom resource + +## v4.0.2 (2016-05-23) + +- Resolve failures on Windows nodes + +## v4.0.1 (2016-05-19) + +- Added .rb to the name of the plugins so they actually load +- Added testing to ensure the plugins are being loaded in the chef run + +## v4.0.0 (2016-05-18) + +### BREAKING CHANGE: + +The 4.0 release of the Ohai cookbook removes the previous cookbook_file behavior that required forking the cookbook and adding your own plugins. Instead the cookbook ships with a new ohai_plugin custom resource for installing plugins. In addition to this new custom resource the cookbook now requires Chef 12+. See the readme and test recipe for examples. If you require Chef 11 support you'll need to pin to version 3.0 in your environment. + +## v3.0.1 (2016-03-14) + +- Fixed the Chefspec matchers + +## v3.0.0 (2016-03-14) + +- Change the default value for `node['ohai']['hints_path']` to use the Ohai config value. This should be the same value in most use cases, but if a custom path is specified in the chef client config this value will get used automatically by the cookbook. +- Removed backwards compatibility with Chefspec < 4.1 in the matchers library +- Fix bad link to the custom Ohai plugin documentation in the readme +- Improve documentation for `node['ohai']['plugin_path']` + +## v2.1.0 (2016-01-26) + +- Properly handle creating ohai hints without specifying the content. Previously if the content wasn't specified a deprecation notice would be thrown and the file would not be created +- Simplified the test suite and added inspec tests to ensure hints are created, especially if the content is not specified +- Added FreeBSD and Windows as supported platform in the metadata and add them to the Test Kitchen config +- Add Test Kitchen integration tests to Travis CI +- Updated testing Gems to the latest releases in the Gemfile + +## v2.0.4 (2015-10-30) + +- Resolved deprecation warnings with the Chefspec matchers + +## v2.0.3 (2015-10-21) + +- Validate the hints before loading them to avoid failures +- Added supported platforms to the metadata +- Updated .gitignore file +- Updated Test Kitchen config for the latest platforms +- Added Chef standard Rubocop config +- Added Travis CI testing +- Added Berksfile +- Updated contributing and testing docs +- Added maintainers.md and maintainers.toml files +- Added Travis and cookbook version badges to the readme +- Expanded the requirements section in the readme and clarify the minimum supported Chef release is 11 +- Updated Opscode -> Chef Software +- Added a Rakefile for simplified testing +- Added a Chefignore file +- Resolved Rubocop warnings +- Added source_url and issues_url to the metadata +- Added Chefspec matchers +- Added basic convergence Chefspec test + +## v2.0.1 (2014-06-07) + +- [COOK-4683] Remove warnings about reopening resource + +Please note, this changes the name of a remote_directory resource. It is not expected that anyone would be explicitly notifying this resource but, please review [PR #16](https://github.com/chef-cookbooks/ohai/pull/16/files) for more info. + +## v2.0.0 (2014-02-25) + +'[COOK-3865] - create lwrp ohai_hint' + +## v1.1.12 + +- Dummy release due to a Community Site upload failure + +## v1.1.10 + +### Bug + +- **[COOK-3091](https://tickets.chef.io/browse/COOK-3091)** - Fix checking `Chef::Config[:config_file]` + +## v1.1.8 + +- [COOK-1918] - Ohai cookbook to distribute plugins fails on windows +- [COOK-2096] - Ohai cookbook sets unix-only default path attribute + +## v1.1.6 + +- [COOK-2057] - distribution from another cookbok fails if ohai attributes are loaded after the other cookbook + +## v1.1.4 + +- [COOK-1128] - readme update, Replace reference to deprecated chef cookbook with one to chef-client + +## v1.1.2 + +- [COOK-1424] - prevent plugin_path growth to infinity + +## v1.1.0 + +- [COOK-1174] - custom_plugins is only conditionally available +- [COOK-1383] - allow plugins from other cookbooks + +## v1.0.2 + +- [COOK-463] ohai cookbook default recipe should only reload plugins if there were updates diff --git a/vendor-cookbooks/ohai/CONTRIBUTING.md b/vendor-cookbooks/ohai/CONTRIBUTING.md new file mode 100644 index 0000000..ef2f2b8 --- /dev/null +++ b/vendor-cookbooks/ohai/CONTRIBUTING.md @@ -0,0 +1,2 @@ +Please refer to +https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/ohai/README.md b/vendor-cookbooks/ohai/README.md new file mode 100644 index 0000000..0c061a7 --- /dev/null +++ b/vendor-cookbooks/ohai/README.md @@ -0,0 +1,139 @@ +# ohai Cookbook + +[![Build Status](https://travis-ci.org/chef-cookbooks/ohai.svg?branch=master)](https://travis-ci.org/chef-cookbooks/ohai) [![Build status](https://ci.appveyor.com/api/projects/status/lgok2kr6l007s8hf/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/ohai/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/ohai.svg)](https://supermarket.chef.io/cookbooks/ohai) + +Contains custom resources for adding Ohai hints and installing custom Ohai plugins. Handles path creation as well as the reloading of Ohai so that new data will be available during the same run. + +NOTE: The ohai_hint resource shipped in Chef 14.0 (April 2018). When Chef 15.0 is released (April 2019) and Chef 13 goes EOL the ohai_hint resource will be removed from this cookbook. + +## Requirements + +### Platforms + +- Debian/Ubuntu +- RHEL/CentOS/Scientific/Amazon/Oracle +- openSUSE / SUSE Enterprise Linux +- FreeBSD +- Windows + +### Chef + +- Chef 12.7+ + +### Cookbooks + +- none + +## Custom Resources + +### `ohai_hint` + +Creates Ohai hint files, which are consumed by Ohai plugins in order to determine if they should run or not. + +#### Resource Properties + +- `hint_name` - The name of hints file and key. Should be string, default is name of resource. +- `content` - Values of hints. It will be used as automatic attributes. Should be Hash, default is empty Hash +- `compile_time` - Should the resource run at compile time. This defaults to true + +#### Examples + +Hint file installed to the default directory: + +```ruby +ohai_hint 'ec2' +``` + +Hint file not installed at compile time: + +```ruby +ohai_hint 'ec2' do + compile_time false +end +``` + +Hint file installed with content: + +```ruby +ohai_hint 'raid_present' do + content Hash[:a, 'test_content'] +end +``` + +#### ChefSpec Matchers + +You can check for the creation or deletion of ohai hints with chefspec using these custom matches: + +- create_ohai_hint +- delete_ohai_hint + +### `ohai_plugin` + +Installs custom Ohai plugins. + +#### Resource Properties + +- `plugin_name` - The name to give the plugin on the filesystem. Should be string, default is name of resource. +- `path` - The path to your custom plugin directory. Defaults to a directory named 'plugins' under the directory 'ohai' in the Chef config dir. +- `source_file` - The source file for the plugin in your cookbook if not NAME.rb. +- `cookbook` - The cookbook where the source file exists if not the cookbook where the ohai_plugin resource is running from. +- `resource` - The resource type for the plugin file. Either `:cookbook_file` or `:template`. Defaults to `:cookbook_file`. +- `variables` - Usable only if `resource` is `:template`. Defines the template's variables. +- `compile_time` - Should the resource run at compile time. This defaults to `true`. +- `load_single_plugin` - Reload all plugins unless this value is set to true. Load only the named plugin. + +#### examples + +Simple Ohai plugin installation: + +```ruby +ohai_plugin 'my_custom_plugin' +``` + +Installation where the resource doesn't match the filename and you install to a custom plugins dir: + +```ruby +ohai_plugin 'My Ohai Plugin' do + name 'my_custom_plugin' + path '/my/custom/path/' +end +``` + +Installation using a template: + +```ruby +ohai_plugin 'My Templated Plugin' do + name 'templated_plugin' + resource :template + variables node_type: :web_server +end +``` + +#### ChefSpec Matchers + +You can check for the creation or deletion of ohai plugins with chefspec using these custom matches: + +- create_ohai_plugin +- delete_ohai_plugin + +## Maintainers + +This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/) + +## License + +**Copyright:** 2011-2016, Chef Software, Inc. + +``` +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. +``` diff --git a/vendor-cookbooks/ohai/libraries/hint_helpers.rb b/vendor-cookbooks/ohai/libraries/hint_helpers.rb new file mode 100644 index 0000000..a0e58ba --- /dev/null +++ b/vendor-cookbooks/ohai/libraries/hint_helpers.rb @@ -0,0 +1,35 @@ +# +# Cookbook:: ohai +# Library:: hint_helpers +# +# Author:: Tim Smith () +# +# Copyright:: 2017, Chef Software, Inc. +# +# 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. +# + +module OhaiCookbook + module HintHelpers + def ohai_hint_file_path(filename) + path = ::File.join(::Ohai::Config.ohai.hints_path.first, filename) + path << '.json' unless path.end_with?('.json') + path + end + + def format_content(content) + return '' if content.nil? || content.empty? + JSON.pretty_generate(content) + end + end +end diff --git a/vendor-cookbooks/ohai/libraries/plugin_helpers.rb b/vendor-cookbooks/ohai/libraries/plugin_helpers.rb new file mode 100644 index 0000000..218d550 --- /dev/null +++ b/vendor-cookbooks/ohai/libraries/plugin_helpers.rb @@ -0,0 +1,77 @@ +# +# Cookbook:: ohai +# Library:: plugin_helpers +# +# Author:: Tim Smith () +# +# Copyright:: 2017-2018, Chef Software, Inc. +# +# 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. +# + +module OhaiCookbook + module PluginHelpers + # return the path property if specified or + # CHEF_CONFIG_PATH/ohai/plugins if a path isn't specified + def desired_plugin_path + if new_resource.path + new_resource.path.chomp('/') # if the user gave us /foo/bar/ we need /foo/bar for later comparison + else + ::File.join(chef_config_path, 'ohai', 'plugins') + end + end + + # return the chef config files dir or fail hard + def chef_config_path + if Chef::Config['config_file'] + ::File.dirname(Chef::Config['config_file']) + else + Chef::Application.fatal!("No chef config file defined. Are you running \ + chef-solo? If so you will need to define a path for the ohai_plugin as the \ + path cannot be determined") + end + end + + # is the desired plugin dir in the ohai config plugin dir array? + def in_plugin_path?(path) + normalized_path = normalize_path(path) + # get the directory where we plan to stick the plugin (not the actual file path) + desired_dir = ::File.directory?(normalized_path) ? normalized_path : ::File.dirname(normalized_path) + ::Ohai::Config.ohai['plugin_path'].map { |x| normalize_path(x) }.any? do |d| + desired_dir.start_with?(d) + end + end + + # return path to lower and with forward slashes so we can compare it + # this works around the 3 different way we can represent windows paths + def normalize_path(path) + path.downcase.gsub(/\\+/, '/') + end + + def add_to_plugin_path(path) + ::Ohai::Config.ohai['plugin_path'] << path # new format + end + + # we need to warn the user that unless the path for this plugin is in Ohai's + # plugin path already we're going to have to reload Ohai on every Chef run. + # Ideally in future versions of Ohai /etc/chef/ohai/plugins is in the path. + def plugin_path_warning + Chef::Log.warn("The Ohai plugin_path does not include #{desired_plugin_path}. \ +Ohai will reload on each chef-client run in order to add this directory to the \ +path unless you modify your client.rb configuration to add this directory to \ +plugin_path. The plugin_path can be set via the chef-client::config recipe. \ +See 'Ohai Settings' at https://docs.chef.io/config_rb_client.html#ohai-settings \ +for more details.") + end + end +end diff --git a/vendor-cookbooks/ohai/metadata.json b/vendor-cookbooks/ohai/metadata.json new file mode 100644 index 0000000..627ba01 --- /dev/null +++ b/vendor-cookbooks/ohai/metadata.json @@ -0,0 +1 @@ +{"name":"ohai","version":"5.3.0","description":"Provides custom resources for installing Ohai hints and plugins","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0","centos":">= 0.0.0","redhat":">= 0.0.0","amazon":">= 0.0.0","scientific":">= 0.0.0","fedora":">= 0.0.0","oracle":">= 0.0.0","suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","freebsd":">= 0.0.0","windows":">= 0.0.0","zlinux":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/ohai","issues_url":"https://github.com/chef-cookbooks/ohai/issues","chef_version":[[">= 13"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/ohai/metadata.rb b/vendor-cookbooks/ohai/metadata.rb new file mode 100644 index 0000000..d1450d3 --- /dev/null +++ b/vendor-cookbooks/ohai/metadata.rb @@ -0,0 +1,15 @@ +name 'ohai' +maintainer 'Chef Software, Inc.' +maintainer_email 'cookbooks@chef.io' +license 'Apache-2.0' +description 'Provides custom resources for installing Ohai hints and plugins' + +version '5.3.0' + +%w(ubuntu debian centos redhat amazon scientific fedora oracle suse opensuse opensuseleap freebsd windows zlinux).each do |os| + supports os +end + +source_url 'https://github.com/chef-cookbooks/ohai' +issues_url 'https://github.com/chef-cookbooks/ohai/issues' +chef_version '>= 13' diff --git a/vendor-cookbooks/ohai/recipes/default.rb b/vendor-cookbooks/ohai/recipes/default.rb new file mode 100644 index 0000000..6f83639 --- /dev/null +++ b/vendor-cookbooks/ohai/recipes/default.rb @@ -0,0 +1,20 @@ +# +# Cookbook:: ohai +# Recipe:: default +# +# Copyright:: 2011-2017, Chef Software, Inc +# +# 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. +# + +Chef::Log.warn('The Ohai cookbook default recipe has no content as of the 4.0 release. See the readme for instructions on using the custom resources.') diff --git a/vendor-cookbooks/ohai/resources/hint.rb b/vendor-cookbooks/ohai/resources/hint.rb new file mode 100644 index 0000000..c11d245 --- /dev/null +++ b/vendor-cookbooks/ohai/resources/hint.rb @@ -0,0 +1,41 @@ +chef_version_for_provides '< 14.0' if respond_to?(:chef_version_for_provides) +resource_name :ohai_hint + +property :hint_name, String, name_property: true +property :content, Hash +property :compile_time, [true, false], default: true + +action :create do + directory ::Ohai::Config.ohai.hints_path.first do + action :create + recursive true + end + + file ohai_hint_file_path(new_resource.hint_name) do + action :create + content format_content(new_resource.content) + end +end + +action :delete do + file ohai_hint_file_path(new_resource.hint_name) do # ~FC009 + action :delete + notifies :reload, ohai[reload ohai post hint removal] + end + + ohai 'reload ohai post hint removal' do + action :nothing + end +end + +action_class do + include OhaiCookbook::HintHelpers +end + +# this resource forces itself to run at compile_time +def after_created + return unless compile_time + Array(action).each do |action| + run_action(action) + end +end diff --git a/vendor-cookbooks/ohai/resources/plugin.rb b/vendor-cookbooks/ohai/resources/plugin.rb new file mode 100644 index 0000000..46cdd8a --- /dev/null +++ b/vendor-cookbooks/ohai/resources/plugin.rb @@ -0,0 +1,71 @@ +property :plugin_name, String, name_property: true +property :path, String +property :source_file, String +property :cookbook, String +property :resource, [:cookbook_file, :template], default: :cookbook_file +property :variables, Hash +property :compile_time, [true, false], default: true +property :load_single_plugin, [true, false], default: false + +action :create do + # why create_if_missing you ask? + # no one can agree on perms and this allows them to manage the perms elsewhere + directory desired_plugin_path do + action :create + recursive true + not_if { ::File.exist?(desired_plugin_path) } + end + + if new_resource.resource.eql?(:cookbook_file) + cookbook_file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do + cookbook new_resource.cookbook + source new_resource.source_file || "#{new_resource.plugin_name}.rb" + notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately + end + elsif new_resource.resource.eql?(:template) + template ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do + cookbook new_resource.cookbook + source new_resource.source_file || "#{new_resource.plugin_name}.rb" + variables new_resource.variables + notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately + end + end + + # Add the plugin path to the ohai plugin path if need be and warn + # the user that this is going to result in a reload every run + unless in_plugin_path?(desired_plugin_path) + plugin_path_warning + Chef::Log.warn("Adding #{desired_plugin_path} to the Ohai plugin path for this chef-client run only") + add_to_plugin_path(desired_plugin_path) + reload_required = true + end + + ohai new_resource.plugin_name do + action :nothing + action :reload if reload_required + plugin new_resource.plugin_name if new_resource.load_single_plugin + end +end + +action :delete do + file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do + action :delete + notifies :reload, 'ohai[reload ohai post plugin removal]' + end + + ohai 'reload ohai post plugin removal' do + action :nothing + end +end + +action_class do + include OhaiCookbook::PluginHelpers +end + +# this resource forces itself to run at compile_time +def after_created + return unless compile_time + Array(action).each do |action| + run_action(action) + end +end diff --git a/vendor-cookbooks/seven_zip/.gitignore b/vendor-cookbooks/seven_zip/.gitignore new file mode 100644 index 0000000..6a9bd26 --- /dev/null +++ b/vendor-cookbooks/seven_zip/.gitignore @@ -0,0 +1,26 @@ +*# +*.un~ +*~ +.#* +.*.sw[a-z] +.vagrant +/cache/ +/cookbooks +\#*# +version.txt + +# Bundler +bin/* +.bundle/* +.vendor/* + +# Test Kitchen +.kitchen.local.yml +.kitchen/ +.kitchen/* +Berksfile.lock + +#IntelliJ IDEA +.idea +.idea/ +.idea/* diff --git a/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml b/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml new file mode 100644 index 0000000..b1eba2e --- /dev/null +++ b/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml @@ -0,0 +1,25 @@ +--- +driver: + name: proxy + host: localhost + reset_command: "exit 0" + port: 5985 + username: <%= ENV["machine_user"] %> + password: <%= ENV["machine_pass"] %> + elevated: false + elevated_username: <%= ENV["machine_user"] %> + elevated_password: <%= ENV["machine_pass"] %> + require_chef_omnibus: 13.8.5 + +provisioner: + name: chef_zero + +platforms: + - name: windows-2012R2 + driver: + box: mwrock/Windows2012R2 + +suites: + - name: default + run_list: + - recipe[test_archive] diff --git a/vendor-cookbooks/seven_zip/.kitchen.yml b/vendor-cookbooks/seven_zip/.kitchen.yml new file mode 100644 index 0000000..5018fa5 --- /dev/null +++ b/vendor-cookbooks/seven_zip/.kitchen.yml @@ -0,0 +1,28 @@ +--- +driver: + name: vagrant + provider: virtualbox + gui: true + username: vagrant + password: vagrant + elevated: false + elevated_username: vagrant + elevated_password: vagrant + require_chef_omnibus: 13.8.5 + +provisioner: + name: chef_zero + product_name: chef + product_version: 13.8.5 + +platforms: + - name: windows-2012R2 + transport: + name: winrm + driver: + box: mwrock/Windows2012R2 + +suites: + - name: default + run_list: + - recipe[test_archive] diff --git a/vendor-cookbooks/seven_zip/.rspec b/vendor-cookbooks/seven_zip/.rspec new file mode 100644 index 0000000..2559e39 --- /dev/null +++ b/vendor-cookbooks/seven_zip/.rspec @@ -0,0 +1,3 @@ +--color +--format progress +--require spec_helper diff --git a/vendor-cookbooks/seven_zip/.rubocop.yml b/vendor-cookbooks/seven_zip/.rubocop.yml new file mode 100644 index 0000000..f4acc5c --- /dev/null +++ b/vendor-cookbooks/seven_zip/.rubocop.yml @@ -0,0 +1,16 @@ +AllCops: + Exclude: + - 'Berksfile' + +Style/Encoding: + Enabled: true + +# Multiline block chains are needed for ChefSpec stubbing of libraries +Style/MultilineBlockChain: + Enabled: false + +Metrics/LineLength: + Max: 120 + +Metrics/AbcSize: + Max: 25 diff --git a/vendor-cookbooks/seven_zip/Berksfile b/vendor-cookbooks/seven_zip/Berksfile new file mode 100644 index 0000000..376e212 --- /dev/null +++ b/vendor-cookbooks/seven_zip/Berksfile @@ -0,0 +1,7 @@ +source 'https://supermarket.chef.io' + +metadata + +group :integration do + cookbook 'test_archive', path: 'test/fixtures/cookbooks/test_archive' +end diff --git a/vendor-cookbooks/seven_zip/CHANGELOG.md b/vendor-cookbooks/seven_zip/CHANGELOG.md new file mode 100644 index 0000000..5466593 --- /dev/null +++ b/vendor-cookbooks/seven_zip/CHANGELOG.md @@ -0,0 +1,52 @@ +# CHANGELOG for seven_zip + +This file is used to list changes made in each version of seven_zip. + +## 3.1.2 +* Update nokogiri from 1.8.2 to 1.8.5 (https://snyk.io/vuln/SNYK-RUBY-NOKOGIRI-72433) + +## 3.1.1 +* Fix deprecation warning regarding the use of win_friendly_path helper. + +## 3.1.0 + +* Having a simple resource to setup 7-zip allows other resources (since including a recipe inside a resource is not a good pattern) to use it to ensure that their prerequisites are installed before-hand. +* This resource leverage existing attributes as default values to keep backward compatibility. +* The seven_zip::default recipe's code has been refactored to just use this resource. + +## 3.0.0 + +* Support Chef 13, drop support for Chef 12. +* Upgrade to 7-Zip 18.05. +* Standardize testing environment across repos. (AppVeyor, Kitchen, Rake, etc.) +* Upgrade development dependencies. + +## 2.0.2 + +* Add timeout to extract action on seven\_zip resource and configurable default\_extract_timeout attribute. + +## 2.0.1 + +* [GH Issue 21 - NoMethodError: Undefined method or attribute `kernel' on `node'](https://github.com/daptiv/seven_zip/issues/21). + +## 2.0.0 + +* [Upgrade to 7-Zip 15.14](https://github.com/daptiv/seven_zip/pull/9). +* [7-Zip now installed to the default MSI location by default](https://github.com/daptiv/seven_zip/pull/11). +* [7z.exe is located using the Windows registry unless the home attribute is explicitly set](https://github.com/daptiv/seven_zip/pull/10). +* [7-Zip is only added to the Windows PATH if the syspath attribute is set](https://github.com/daptiv/seven_zip/pull/11). +* [Installation idempotence check was fixed](https://github.com/daptiv/seven_zip/pull/14), package name was corrected. +* [TravisCI build added](https://github.com/daptiv/seven_zip/pull/12). +* [ServerSpec tests added](https://github.com/daptiv/seven_zip/pull/9) +* [Document Archive LRWP](https://github.com/daptiv/seven_zip/pull/6) + +## 1.0.2 + +* [COOK-3476 - Upgrade to 7-zip 9.22](https://tickets.opscode.com/browse/COOK-3476) + +## 1.0.0 + +* initial release + +- - - +Refer to the [Markdown Syntax Guide](https://daringfireball.net/projects/markdown/syntax) for help with standard Markdown, and [Writing on GitHub](https://help.github.com/categories/writing-on-github/) for help with the GitHub dialect of Markdown. diff --git a/vendor-cookbooks/seven_zip/Gemfile b/vendor-cookbooks/seven_zip/Gemfile new file mode 100644 index 0000000..b6ba658 --- /dev/null +++ b/vendor-cookbooks/seven_zip/Gemfile @@ -0,0 +1,8 @@ +source 'http://rubygems.org' + +gem 'cookstyle' +gem 'foodcritic' +gem 'rspec-expectations' +gem 'rspec-mocks' +gem 'rubocop' +gem 'stove' diff --git a/vendor-cookbooks/seven_zip/Gemfile.lock b/vendor-cookbooks/seven_zip/Gemfile.lock new file mode 100644 index 0000000..877a1e3 --- /dev/null +++ b/vendor-cookbooks/seven_zip/Gemfile.lock @@ -0,0 +1,79 @@ +GEM + remote: http://rubygems.org/ + specs: + ast (2.4.0) + backports (3.11.3) + chef-api (0.8.0) + logify (~> 0.1) + mime-types + cookstyle (3.0.0) + rubocop (= 0.55.0) + cucumber-core (3.1.0) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (>= 5.0.0) + cucumber-tag_expressions (1.1.1) + diff-lcs (1.3) + erubis (2.7.0) + ffi-yajl (2.3.1) + libyajl2 (~> 1.2) + foodcritic (13.1.1) + cucumber-core (>= 1.3) + erubis + ffi-yajl (~> 2.0) + nokogiri (>= 1.5, < 2.0) + rake + rufus-lru (~> 1.0) + treetop (~> 1.4) + gherkin (5.0.0) + libyajl2 (1.2.0) + logify (0.2.0) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.4.0) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + parallel (1.12.1) + parser (2.5.1.0) + ast (~> 2.4.0) + polyglot (0.3.5) + powerpack (0.1.1) + rainbow (3.0.0) + rake (13.0.1) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-mocks (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.1) + rubocop (0.55.0) + parallel (~> 1.10) + parser (>= 2.5) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.9.0) + rufus-lru (1.1.0) + stove (6.0.0) + chef-api (~> 0.5) + logify (~> 0.2) + treetop (1.6.10) + polyglot (~> 0.3) + unicode-display_width (1.3.2) + +PLATFORMS + ruby + +DEPENDENCIES + cookstyle + foodcritic + rspec-expectations + rspec-mocks + rubocop + stove + +BUNDLED WITH + 1.16.1 diff --git a/vendor-cookbooks/seven_zip/LICENSE b/vendor-cookbooks/seven_zip/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/vendor-cookbooks/seven_zip/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +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. diff --git a/vendor-cookbooks/seven_zip/README.md b/vendor-cookbooks/seven_zip/README.md new file mode 100644 index 0000000..7e04831 --- /dev/null +++ b/vendor-cookbooks/seven_zip/README.md @@ -0,0 +1,114 @@ +[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip) +[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master) + +# seven_zip Cookbook +[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-Zip suite of tools (GUI and CLI). This cookbook replaces the older [7-Zip cookbook](https://github.com/sneal/7-zip). + +# Requirements +## Platforms +- Windows XP +- Windows Vista +- Windows 7 +- Windows 8, 8.1 +- Windows 10 +- Windows Server 2003 R2 +- Windows Server 2008 (R1, R2) +- Windows Server 2012 (R1, R2) + +## Chef +- Chef >= 13.0 + +## Cookbooks +- windows + +# Attributes +## Optional + +| Key | Type | Description | Default | +|-----|------|-------------|---------| +| `['seven_zip']['home']` | String | 7-Zip installation directory. | | +| `['seven_zip']['syspath']` | Boolean | If true, adds 7-Zip directory to system PATH environment variable. | | +| `['seven_zip']['default_extract_timeout']` | Integer | The default timeout for an extract operation in seconds. This can be overridden by a resource attribute. | `600` | + +# Usage +## default + +Add `seven_zip::default` to your run\_list which will download and install 7-Zip for the current Windows platform. + +# Resource/Provider +## seven_zip_archive +Extracts a 7-Zip compatible archive (iso, zip, 7z, etc.) to the specified destination directory. + +#### Actions +- `:extract` - Extract a 7-Zip compatible archive. + +#### Attribute Parameters +- `path` - Name attribute. The destination to extract to. +- `source` - The file path to the archive to extract. +- `overwrite` - Defaults to false. If true, the destination files will be overwritten. +- `checksum` - The archive file checksum. +- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`. + +#### Examples +Extract 7-Zip source files to `C:\seven_zip_source`. + +```ruby +seven_zip_archive 'seven_zip_source' do + path 'C:\seven_zip_source' + source 'https://www.7-zip.org/a/7z1805-src.7z' + overwrite true + checksum 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83' + timeout 30 +end +``` + +## seven_zip_tool +Download and install 7-zip for the current Windows platform. + +#### Actions +- `:install` - Installs 7-zip +- `:add_to_path` - Add 7-zip to the PATH + +#### Attribute Parameters +- `package` - The name of the package. +- `path` - The install directory of 7-zip. +- `source` - The source URL of the 7-zip package. +- `checksum` - The 7-zip package checksum. + +#### Examples +Install 7-zip in `C:\7z` and add it to the path. + +```ruby +seven_zip_tool '7z 15.14 install' do + action [:install, :add_to_path] + package '7-Zip 15.14' + path 'C:\7z' + source 'http://www.7-zip.org/a/7z1514.msi' + checksum 'eaf58e29941d8ca95045946949d75d9b5455fac167df979a7f8e4a6bf2d39680' +end +``` + +# Recipes +## default + +Installs 7-Zip and adds it to your system PATH. + +# License & Authors +- Author:: Seth Chisamore () +- Author:: Shawn Neal () + +```text +Copyright:: 2011-2016, Chef Software, Inc. + +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. +``` diff --git a/vendor-cookbooks/seven_zip/appveyor.yml b/vendor-cookbooks/seven_zip/appveyor.yml new file mode 100644 index 0000000..321b270 --- /dev/null +++ b/vendor-cookbooks/seven_zip/appveyor.yml @@ -0,0 +1,42 @@ +version: "3.1.1.{build}-{branch}" + +image: Visual Studio 2013 +platform: x64 + +environment: + machine_user: vagrant + machine_pass: vagrant + KITCHEN_YAML: .kitchen.appveyor.yml + +branches: + only: + - master + +# Do not build on tags (GitHub only) +skip_tags: true + +#faster cloning +clone_depth: 1 + +install: + - ps: (& cmd /c); iex (irm https://omnitruck.chef.io/install.ps1); Install-Project -Project chefdk -channel stable -version 3.10.1 + - ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version' + - ps: $PSVersionTable + - c:\opscode\chefdk\bin\chef.bat exec ruby --version + - ps: secedit /export /cfg $env:temp/export.cfg + - ps: ((get-content $env:temp/export.cfg) -replace ('PasswordComplexity = 1', 'PasswordComplexity = 0')) | Out-File $env:temp/export.cfg + - ps: ((get-content $env:temp/export.cfg) -replace ('MinimumPasswordLength = 8', 'MinimumPasswordLength = 0')) | Out-File $env:temp/export.cfg + - ps: secedit /configure /db $env:windir/security/new.sdb /cfg $env:temp/export.cfg /areas SECURITYPOLICY + - ps: net user /add $env:machine_user $env:machine_pass + - ps: net localgroup administrators $env:machine_user /add + +build_script: + - ps: c:\opscode\chefdk\bin\chef.bat shell-init powershell | iex; cmd /c c:\opscode\chefdk\bin\chef.bat --version + +test_script: + - c:\opscode\chefdk\bin\cookstyle --version + - c:\opscode\chefdk\bin\chef.bat exec foodcritic --version + - c:\opscode\chefdk\bin\chef.bat exec rake + - c:\opscode\chefdk\bin\chef.bat exec kitchen verify + +deploy: off diff --git a/vendor-cookbooks/seven_zip/attributes/default.rb b/vendor-cookbooks/seven_zip/attributes/default.rb new file mode 100644 index 0000000..443a28b --- /dev/null +++ b/vendor-cookbooks/seven_zip/attributes/default.rb @@ -0,0 +1,31 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: seven_zip +# Attribute:: default +# +# Copyright:: 2011-2017, Chef Software, Inc. +# +# 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. +# + +if node['kernel']['machine'] == 'x86_64' + default['seven_zip']['url'] = 'https://www.7-zip.org/a/7z1805-x64.msi' + default['seven_zip']['checksum'] = '898c1ca0015183fe2ba7d55cacf0a1dea35e873bf3f8090f362a6288c6ef08d7' + default['seven_zip']['package_name'] = '7-Zip 18.05 (x64 edition)' +else + default['seven_zip']['url'] = 'https://www.7-zip.org/a/7z1805.msi' + default['seven_zip']['checksum'] = 'c554238bee18a03d736525e06d9258c9ecf7f64ead7c6b0d1eb04db2c0de30d0' + default['seven_zip']['package_name'] = '7-Zip 18.05' +end + +default['seven_zip']['default_extract_timeout'] = 600 diff --git a/vendor-cookbooks/seven_zip/chefignore b/vendor-cookbooks/seven_zip/chefignore new file mode 100644 index 0000000..9c2bd55 --- /dev/null +++ b/vendor-cookbooks/seven_zip/chefignore @@ -0,0 +1,98 @@ +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +examples/* +Guardfile +Procfile +.kitchen* +.rubocop.yml +spec/* +Rakefile +.travis.yml +.foodcritic +.codeclimate.yml + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Cookbooks # +############# +CONTRIBUTING* +CHANGELOG* +TESTING* +MAINTAINERS.toml + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/vendor-cookbooks/seven_zip/libraries/matchers.rb b/vendor-cookbooks/seven_zip/libraries/matchers.rb new file mode 100644 index 0000000..6dd4dca --- /dev/null +++ b/vendor-cookbooks/seven_zip/libraries/matchers.rb @@ -0,0 +1,33 @@ +# +# Author:: Shawn Neal () +# Cookbook:: visualstudio +# +# Copyright:: 2015-2017, Shawn Neal +# +# 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. +# + +if defined?(ChefSpec) + chefspec_version = Gem.loaded_specs['chefspec'].version + define_method = if chefspec_version < Gem::Version.new('4.1.0') + ChefSpec::Runner.method(:define_runner_method) + else + ChefSpec.method(:define_matcher) + end + + define_method.call :seven_zip_archive + + def extract_seven_zip_archive(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:seven_zip_archive, :extract, resource_name) + end +end diff --git a/vendor-cookbooks/seven_zip/metadata.json b/vendor-cookbooks/seven_zip/metadata.json new file mode 100644 index 0000000..523109a --- /dev/null +++ b/vendor-cookbooks/seven_zip/metadata.json @@ -0,0 +1,35 @@ +{ + "name": "seven_zip", + "description": "Installs/Configures 7-Zip", + "long_description": "[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip)\n[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master)\n\n# seven_zip Cookbook\n[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-Zip suite of tools (GUI and CLI). This cookbook replaces the older [7-Zip cookbook](https://github.com/sneal/7-zip).\n\n# Requirements\n## Platforms\n- Windows XP\n- Windows Vista\n- Windows 7\n- Windows 8, 8.1\n- Windows 10\n- Windows Server 2003 R2\n- Windows Server 2008 (R1, R2)\n- Windows Server 2012 (R1, R2)\n\n## Chef\n- Chef >= 13.0\n\n## Cookbooks\n- windows\n\n# Attributes\n## Optional\n\n| Key | Type | Description | Default |\n|-----|------|-------------|---------|\n| `['seven_zip']['home']` | String | 7-Zip installation directory. | |\n| `['seven_zip']['syspath']` | Boolean | If true, adds 7-Zip directory to system PATH environment variable. | |\n| `['seven_zip']['default_extract_timeout']` | Integer | The default timeout for an extract operation in seconds. This can be overridden by a resource attribute. | `600` |\n\n# Usage\n## default\n\nAdd `seven_zip::default` to your run\\_list which will download and install 7-Zip for the current Windows platform.\n\n# Resource/Provider\n## seven_zip_archive\nExtracts a 7-Zip compatible archive (iso, zip, 7z, etc.) to the specified destination directory.\n\n#### Actions\n- `:extract` - Extract a 7-Zip compatible archive.\n\n#### Attribute Parameters\n- `path` - Name attribute. The destination to extract to.\n- `source` - The file path to the archive to extract.\n- `overwrite` - Defaults to false. If true, the destination files will be overwritten.\n- `checksum` - The archive file checksum.\n- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`.\n\n#### Examples\nExtract 7-Zip source files to `C:\\seven_zip_source`.\n\n```ruby\nseven_zip_archive 'seven_zip_source' do\n path 'C:\\seven_zip_source'\n source 'https://www.7-zip.org/a/7z1805-src.7z'\n overwrite true\n checksum 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83'\n timeout 30\nend\n```\n\n## seven_zip_tool\nDownload and install 7-zip for the current Windows platform.\n\n#### Actions\n- `:install` - Installs 7-zip\n- `:add_to_path` - Add 7-zip to the PATH\n\n#### Attribute Parameters\n- `package` - The name of the package.\n- `path` - The install directory of 7-zip.\n- `source` - The source URL of the 7-zip package.\n- `checksum` - The 7-zip package checksum.\n\n#### Examples\nInstall 7-zip in `C:\\7z` and add it to the path.\n\n```ruby\nseven_zip_tool '7z 15.14 install' do\n action [:install, :add_to_path]\n package '7-Zip 15.14'\n path 'C:\\7z'\n source 'http://www.7-zip.org/a/7z1514.msi'\n checksum 'eaf58e29941d8ca95045946949d75d9b5455fac167df979a7f8e4a6bf2d39680'\nend\n```\n\n# Recipes\n## default\n\nInstalls 7-Zip and adds it to your system PATH.\n\n# License & Authors\n- Author:: Seth Chisamore ()\n- Author:: Shawn Neal ()\n\n```text\nCopyright:: 2011-2016, Chef Software, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n", + "maintainer": "Shawn Neal", + "maintainer_email": "sneal@sneal.net", + "license": "Apache-2.0", + "platforms": { + "windows": ">= 0.0.0" + }, + "dependencies": { + "windows": ">= 0.0.0" + }, + "providing": { + + }, + "recipes": { + + }, + "version": "3.1.2", + "source_url": "https://github.com/windowschefcookbooks/seven_zip", + "issues_url": "https://github.com/windowschefcookbooks/seven_zip/issues", + "privacy": false, + "chef_versions": [ + [ + ">= 13.0" + ] + ], + "ohai_versions": [ + + ], + "gems": [ + + ] +} diff --git a/vendor-cookbooks/seven_zip/metadata.rb b/vendor-cookbooks/seven_zip/metadata.rb new file mode 100644 index 0000000..67cf09b --- /dev/null +++ b/vendor-cookbooks/seven_zip/metadata.rb @@ -0,0 +1,12 @@ +name 'seven_zip' +maintainer 'Shawn Neal' +maintainer_email 'sneal@sneal.net' +source_url 'https://github.com/windowschefcookbooks/seven_zip' +issues_url 'https://github.com/windowschefcookbooks/seven_zip/issues' +chef_version '>= 13.0' if respond_to?(:chef_version) +license 'Apache-2.0' +description 'Installs/Configures 7-Zip' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '3.1.2' +supports 'windows' +depends 'windows' diff --git a/vendor-cookbooks/seven_zip/providers/archive.rb b/vendor-cookbooks/seven_zip/providers/archive.rb new file mode 100644 index 0000000..c935569 --- /dev/null +++ b/vendor-cookbooks/seven_zip/providers/archive.rb @@ -0,0 +1,64 @@ +# +# Author:: Shawn Neal () +# Cookbook:: seven_zip +# Provider:: archive +# +# Copyright:: 2013-2017, Daptiv Solutions LLC +# +# 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. +# + +require 'fileutils' +require 'chef/mixin/shell_out' +require 'chef/util/path_helper' + +include Chef::Mixin::ShellOut +include Windows::Helper + +def whyrun_supported? + true +end + +action :extract do + converge_by("Extract #{@new_resource.source} => #{@new_resource.path} (overwrite=#{@new_resource.overwrite})") do + FileUtils.mkdir_p(@new_resource.path) unless Dir.exist?(@new_resource.path) + local_source = cached_file(@new_resource.source, @new_resource.checksum) + overwrite_file = @new_resource.overwrite ? ' -y' : ' -aos' + cmd = "\"#{seven_zip_exe}\" x" + cmd << overwrite_file + cmd << " -o\"#{Chef::Util::PathHelper.cleanpath(@new_resource.path)}\"" + cmd << " \"#{local_source}\"" + Chef::Log.debug(cmd) + shell_out!(cmd, timeout: extract_timeout) + end +end + +def seven_zip_exe + path = node['seven_zip']['home'] || seven_zip_exe_from_registry + Chef::Log.debug("Using 7-zip home: #{path}") + Chef::Util::PathHelper.cleanpath(::File.join(path, '7z.exe')) +end + +def seven_zip_exe_from_registry + require 'win32/registry' + # Read path from recommended Windows App Paths registry location + # docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 + ::Win32::Registry::HKEY_LOCAL_MACHINE.open( + 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe', + ::Win32::Registry::KEY_READ + ).read_s('Path') +end + +def extract_timeout + @new_resource.timeout || node['seven_zip']['default_extract_timeout'] +end diff --git a/vendor-cookbooks/seven_zip/rakefile.rb b/vendor-cookbooks/seven_zip/rakefile.rb new file mode 100644 index 0000000..6eab0cc --- /dev/null +++ b/vendor-cookbooks/seven_zip/rakefile.rb @@ -0,0 +1,27 @@ +require 'cookstyle' +require 'foodcritic' +require 'rspec/core/rake_task' +require 'rubocop/rake_task' + +task default: [:rubocop, :foodcritic, :spec] + +FoodCritic::Rake::LintTask.new do |t| + t.options = { + cookbook_paths: '.', + search_gems: true, + } +end + +RSpec::Core::RakeTask.new do |task| + task.pattern = 'spec/**/*_spec.rb' + task.rspec_opts = ['--color', '-f documentation', '-tunit'] +end + +RuboCop::RakeTask.new + +begin + require 'stove/rake_task' + Stove::RakeTask.new +rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] +end diff --git a/vendor-cookbooks/seven_zip/recipes/default.rb b/vendor-cookbooks/seven_zip/recipes/default.rb new file mode 100644 index 0000000..b013889 --- /dev/null +++ b/vendor-cookbooks/seven_zip/recipes/default.rb @@ -0,0 +1,24 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: seven_zip +# Recipe:: default +# +# Copyright:: 2011-2017, Chef Software, Inc. +# +# 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. +# + +# Install 7z and optionally add it to path +seven_zip_tool 'install seven_zip' do + action [:install, :add_to_path] if node['seven_zip']['syspath'] +end diff --git a/vendor-cookbooks/seven_zip/resources/archive.rb b/vendor-cookbooks/seven_zip/resources/archive.rb new file mode 100644 index 0000000..5558f14 --- /dev/null +++ b/vendor-cookbooks/seven_zip/resources/archive.rb @@ -0,0 +1,29 @@ +# +# Author:: Shawn Neal () +# Cookbook:: seven_zip +# Resource:: archive +# +# Copyright:: 2013-2017, Daptiv Solutions LLC +# +# 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. +# + +default_action :extract + +actions :extract + +attribute :path, kind_of: String, name_attribute: true +attribute :source, kind_of: String +attribute :overwrite, kind_of: [TrueClass, FalseClass], default: false +attribute :checksum, kind_of: String +attribute :timeout, kind_of: Integer diff --git a/vendor-cookbooks/seven_zip/resources/tool.rb b/vendor-cookbooks/seven_zip/resources/tool.rb new file mode 100644 index 0000000..4e27965 --- /dev/null +++ b/vendor-cookbooks/seven_zip/resources/tool.rb @@ -0,0 +1,47 @@ +# +# Author:: Annih () +# Cookbook:: seven_zip +# Resource:: tool +# +# Copyright:: 2018, Baptiste Courtois +# +# 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. +# +property :package, ::String, default: lazy { node['seven_zip']['package_name'] } +property :source, ::String, default: lazy { node['seven_zip']['url'] } +property :checksum, [::NilClass, ::String], default: lazy { node['seven_zip']['checksum'] } +property :path, [::NilClass, ::String], default: lazy { node['seven_zip']['home'] } + +action :install do + windows_package new_resource.package do + action :install + source new_resource.source + checksum new_resource.checksum unless new_resource.checksum.nil? + options "INSTALLDIR=\"#{new_resource.path}\"" unless new_resource.path.nil? + end +end + +action :add_to_path do + windows_path 'seven_zip' do + action :add + path new_resource.path || registry_path + end +end + +action_class do + REG_PATH = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe'.freeze + + def registry_path + ::Win32::Registry::HKEY_LOCAL_MACHINE.open(REG_PATH, ::Win32::Registry::KEY_READ).read_s('Path') + end +end diff --git a/vendor-cookbooks/seven_zip/spec/default_spec.rb b/vendor-cookbooks/seven_zip/spec/default_spec.rb new file mode 100644 index 0000000..e2bb248 --- /dev/null +++ b/vendor-cookbooks/seven_zip/spec/default_spec.rb @@ -0,0 +1,27 @@ +describe 'seven_zip::default' do + context 'with defaults' do + let(:chef_run) do + ChefSpec::ServerRunner.new(step_into: 'seven_zip_tool').converge(described_recipe) + end + it 'installs seven_zip package' do + expect(chef_run).to install_windows_package '7-Zip 18.05 (x64 edition)' + end + it 'updates the path to include seven_zip' do + expect(chef_run).to_not add_windows_path('seven_zip').with(path: 'C:\\\\7-zip') + end + end + context 'with syspath' do + let(:chef_run) do + ChefSpec::ServerRunner.new(step_into: 'seven_zip_tool') do |node| + node.override['seven_zip']['syspath'] = true + node.override['seven_zip']['home'] = 'C:\\\\7-zip' + end.converge(described_recipe) + end + it 'installs seven_zip package' do + expect(chef_run).to install_windows_package '7-Zip 18.05 (x64 edition)' + end + it 'updates the path to include seven_zip' do + expect(chef_run).to add_windows_path('seven_zip').with(path: 'C:\\\\7-zip') + end + end +end diff --git a/vendor-cookbooks/seven_zip/spec/spec_helper.rb b/vendor-cookbooks/seven_zip/spec/spec_helper.rb new file mode 100644 index 0000000..efb35f2 --- /dev/null +++ b/vendor-cookbooks/seven_zip/spec/spec_helper.rb @@ -0,0 +1,15 @@ +require 'rspec/expectations' +require 'chefspec' +require 'chefspec/berkshelf' + +RSpec.configure do |config| + config.run_all_when_everything_filtered = true + config.filter_run :focus + config.order = 'random' + config.platform = 'windows' + config.version = '2012R2' + ENV['ProgramFiles(x86)'] = 'C:\Program Files (x86)' # assume 64bit OS + ENV['ProgramFiles'] = 'C:\Program Files' + ENV['WINDIR'] = 'C:\Windows' + ENV['SYSTEMDRIVE'] = 'C:\\' +end diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb new file mode 100644 index 0000000..41b0706 --- /dev/null +++ b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb @@ -0,0 +1,3 @@ +default['test_archive']['source'] = 'https://www.7-zip.org/a/7z1805-src.7z' +default['test_archive']['overwrite'] = true +default['test_archive']['checksum'] = 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83' diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb new file mode 100644 index 0000000..893a7eb --- /dev/null +++ b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb @@ -0,0 +1,3 @@ +name 'test_archive' +version '1.0.0' +depends 'seven_zip' diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb new file mode 100644 index 0000000..d17f4f4 --- /dev/null +++ b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb @@ -0,0 +1,17 @@ +# This recipe is for testing the seven_zip archive provider +include_recipe 'seven_zip' + +seven_zip_archive 'test_archive' do + path 'C:\seven_zip_source' + source node['test_archive']['source'] + overwrite node['test_archive']['overwrite'] + checksum node['test_archive']['checksum'] + timeout 30 +end + +seven_zip_archive 'extract_with_spaces' do + path 'C:\Program Files\seven_zip_source' + source node['test_archive']['source'] + overwrite node['test_archive']['overwrite'] + checksum node['test_archive']['checksum'] +end diff --git a/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb b/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb new file mode 100644 index 0000000..f01aa14 --- /dev/null +++ b/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe package('7-zip 18.05 (x64 edition)') do + it 'is installed' do + expect(subject).to be_installed + end +end + +describe file('C:\seven_zip_source') do + it 'is a directory' do + expect(subject).to be_directory + end + + it 'should contain only extracted files' do + expect(Dir.entries(subject.name).sort).to eq %w(. .. Asm C CPP DOC) + end +end + +describe file('C:\Program Files\seven_zip_source') do + it 'is a directory' do + expect(subject).to be_directory + end + + it 'should contain only extracted files' do + expect(Dir.entries(subject.name).sort).to eq %w(. .. Asm C CPP DOC) + end +end diff --git a/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb b/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb new file mode 100644 index 0000000..4a32b7d --- /dev/null +++ b/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb @@ -0,0 +1,4 @@ +require 'serverspec' + +set :backend, :cmd +set :os, family: 'windows' diff --git a/vendor-cookbooks/windows/CHANGELOG.md b/vendor-cookbooks/windows/CHANGELOG.md new file mode 100644 index 0000000..bda8148 --- /dev/null +++ b/vendor-cookbooks/windows/CHANGELOG.md @@ -0,0 +1,870 @@ +# windows Cookbook CHANGELOG + +This file is used to list changes made in each version of the windows cookbook. + +## 7.0.0 (2020-03-26) + +### Breaking Changes + +- This cookbook now requires Chef Infra Client 14.7 and later as it no longer includes the `windows_share` and `windows_certificate` resources that are now built into Chef Infra Client. + +### Other Changes + +- Remove list of actions in the dns resource - [@tas50](https://github.com/tas50) +- Don't set the guard_interpreter in powershell_script - [@tas50](https://github.com/tas50) +- Add windows_schannel resource (#619) - [@Xorima](https://github.com/Xorima) +- Remove desired_state: true from resources - [@tas50](https://github.com/tas50) +- The host_name property in the dns resource doesn't need to be a name property - [@tas50](https://github.com/tas50) +- Remove unnecessary include of the powershell mixin - [@tas50](https://github.com/tas50) + +## Unreleased + +- Added windows_schannel to configure schannel (tls settings for dotnet apps and powershell) + +## 6.0.1 (2019-10-01) + +- Update README.md for Windows cookbook suggesting core dns resources (#616) - [@NAshwini](https://github.com/NAshwini) +- Add a warning when using windows_zipfile resource as users should migrate to archive_file (#617) - [@NAshwini](https://github.com/NAshwini) + +## 6.0.0 (2019-04-25) + +### Breaking Changes + +- This cookbook now requires Chef 14 or later. As of April 2019 Chef 13 is EOL. If you are still running Chef 13 we highly suggest you begin your migration. Chef 14 provides a greatly improved Windows experience with built in resources for Windows clients. +- Resources that are built into Chef 14 and later have been removed from this cookbook: + - windows_auto_run + - windows_feature + - windows_font + - windows_pagefile + - windows_printer_port + - windows_printer + - windows_shortcut + +## 5.3.1 (2019-04-25) + +- Resolved failures on Chef 14.11 or later +- Removed OS detectio support in the helpers for Windows 2003 + +## 5.3.0 (2019-03-06) + +- Expanded certificate testing to cover more scenarios - [@Xorima](https://github.com/Xorima) +- Updated windows_share to better compare the current and desired path in order to prevent converging on each Chef run - [@Xorima](https://github.com/Xorima) +- Backported all windows_certificate fixes from Chef 14.8 - 14.11 including improvements to importing the types of certificates that can be imported, suppport for nested certs, and support for importing private keys with certs. + +## 5.2.4 (2019-02-28) + +- Fix http_acl regex to properly capture SDDL - [@Annih](https://github.com/Annih) +- Updated windows_share to create share if the share is deleted, and to sanitize paths using Chef::Util::PathHelper.cleanpath (#607) - [@Xorima](https://github.com/Xorima) + +## 5.3.3 (2019-01-30) + +- Updated windows_certificate code to match that in Chef 14.10. This increases the requirement of the win32_certstore gem to the latest and resolves multiple issues with the previous implementation. + +## 5.2.2 (2018-11-20) + +- windows_share: Accounts to be revoked should be provided as an individually quoted string array + +## 5.2.1 (2018-11-19) + +- windows_share: Fix idempotency by not adding everyone by default + +## 5.2.0 (2018-11-14) + +- Support installing deleted features in windows_feature_dism + +## 5.1.6 (2018-11-13) + +- Add a warning to the readme regarding windows_share and windows_certificate now being included in Chef 14.7 +- Deprecated win_friendly_path helper in favor of built-in helpers + +## 5.1.5 (2018-11-07) + +- Avoid deprecation warnings in windows_share and windows_certificate on Chef 14.7+ as these are now included in the chef-client itself. + +## 5.1.4 (2018-10-30) + +- Note the :verify action for windows_certificate in the readme +- certificate resource: auto set sensitive is passing password + +## 5.1.3 (2018-10-11) + +- Remove docs and test suite for windows tasks +- Changed variable name in log message for retrieving SMB share access +- Don't load the windows helper in windows_certificate + +## 5.1.2 (2018-10-08) + +- Fix typo in windows_feature_dism resource name + +## 5.1.1 (2018-09-06) + +- Require the win32-certstore gem and upgrade the gem as the resource runs so we get the most up to date version +- Remove redundant helper methods from the windows_certificate resource + +## 5.1.0 (2018-08-29) + +- Add an action to windows_user_privilege to remove a privilege +- Fix failing appveyor tests +- Require win32-certstore 0.1.8 which resolves several issues with the windows_certificate resource +- Avoid deprecation warnings with Chef 14.3+ by not loading resources that are now built into Chef + +## 5.0.0 (2018-07-24) + +### Breaking Changes + +This release removes the windows_task and windows_path resources from this cookbook. This resources shipped in Chef 13.0 and 13.4 This raises the required version of chef-client for this cookbook to 13.4 or later. + +## 4.3.4 (2018-07-18) + +- Fix error message typo in windows_feature_powershell +- Use win32-certstore 0.1.7 for bugfixes + +## 4.3.3 (2018-07-05) + +- Fix failures on PS 3.0 in windows_feature_powershell + +## 4.3.2 (2018-06-13) + +- Don't error in windows_feature_dism when providing a source + +## 4.3.1 (2018-06-11) + +- Make sure to quote each individual user to grant share access to + +## 4.3.0 (2018-06-11) + +- Add the windows_user_privilege resource which can grant privileges like Logon As a Service +- Add windows_feature_powershell support for Windows 2008 R2 by not downcasing the feature names there and modifying the shell_out commands to make older output look like the 2012+ output +- windows_certificate resource has been reworked to use the new win32-certstore gem. This gem abstracts away much of the logic and will allow us to better support certificates on Windows, especially on non-english systems. +- Convert pester tests to InSpec for easier testing with ChefDK out of the box +- Added additional tests for better testing in AppVeyor +- Stop importing the servermanager module in windows_feature_powershell since we require PowerShell 3.0 and we don't need to do this there +- Improve the error messages in Windows feature to get the Windows versions right +- Increase readability in version logic with helpers in windows_feature resources + +## 4.2.5 (2018-05-28) + +- Add quoting to Path when creating new Share + +## 4.2.4 (2018-05-14) + +- Fix the platform version check in windows_share + +## 4.2.3 (2018-05-07) + +- Include the helper in the action class to prevent failures with the zipfile resource + +## 4.2.2 (2018-04-24) + +- Properly fail in windows_share on Windows 2008 R2 since we lack the cmdlets to manipulates shares on those systems. + +## 4.2.1 (2018-04-17) + +- Make sure shares can have spaces in the share name + +## 4.2.0 (2018-04-16) + +- Initial rewrite of windows_share to use PowerShell for share creation. This introduces multiple new properties and resolves a good number of longstanding issues. Please be sure to report any issues you see with this so we can stabilize this resource and include it in Chef 15! +- Resolve failures in windows_certificate + +## 4.1.4 (2018-03-29) + +- Raise in windows_feature_powershell if we're on PS < 3.0 + +## 4.1.3 (2018-03-28) + +- Restore support for Windows 2008 R2 in windows_feature_dism + +## 4.1.2 (2018-03-27) + +- Improve creation messaging for shares +- Allow feature names to be case insensitive in windows_feature + +## 4.1.1 (2018-03-23) + +- Simplify delete action slightly in windows_pagefile +- Don't use win_friendly_path helper in windows_pagefile since we already coerce the path value + +## 4.1.0 (2018-03-21) + +- Adds Caching for WIndows Feature Powershell resource using the same sort of logic we use on windows_feature_dism. This gives us a 3.5X speedup when no features need to be changed (subsequent runs after the change) +- Warn if we're on w2k12 and trying to use source/management properties in windows_feature_powershell since that doesn't work. +- Properly parse features into arrays so installing an array of features works in dism/powershell. This is the preferred way to install a number of features and will be faster than a large number of feature resources +- Fix description of properties for pagefile in the readme + +## 4.0.2 (2018-03-20) + +- Enable FC016 testing +- Enable FC059 testing +- Properly calculate available packages if source is passed in windows_feature_dism resource + +## 4.0.1 (2018-03-07) + +Fix the previous update to windows_feature_dism to use 'override' level of attributes not the normal level which persists to the node. Thanks to @Annih for pointing out the mistake here. + +## 4.0.0 (2018-03-05) + +### WARNING + +This release contains a complete rewrite to windows_feature_dism resource and includes several behavior changes to windows_feature resource. Make sure to read the complete list of changes below before deploying this to production systems. + +#### DISM feature caching Ohai plugin replacement + +In the 3.X cookbook we installed an Ohai plugin that cached the state of features on the node, and we reloaded that plugin anytime we installed/removed a feature from the system. This greatly sped up Chef runs where no features were actually installed/removed (2nd run and later). Without the caching each resource would take about 1 second longer while it queried current feature state. Using Ohai to cache this data was problematic though due to incompatibilities with Chef Solo, the reliance on the ohai cookbook, and the addition of extra node data which had to be stored on the Chef Server. + +In the 4.0 release instead of caching data via an Ohai plugin we just write directly to the node within the resource. This avoids the need to load in the ohai plugin and the various issues that come with that. In the end it's basically the exact same thing, but less impacting on end users and faster when the data needs to be updated. + +#### Fail when feature is missing in windows_feature_dism + +The windows_feature_dism resource had a rather un-Chef behavior in which it just warned you if a feature wasn't available on your platform and then continued on silently. This isn't how we handle missing packages in any of our package resource and because of that it's not going to be what anyone expects out of the box. If someone really wants SNMP installed and we can't install it we should fail instead of continuing on as if we did install it. So we'll now do the following things: + +- When installing a feature that doesn't exist: fail +- When removing a feature that doesn't exist: continue since it is technically removed +- When deleting a feature that doesn't exist: continue since it is technically deleted + +For some users, particularly those writing community cookbooks, this is going to be a breaking change. I'd highly recommend putting logic within your cookbooks to only install features on supported releases of Windows. If you'd just like it to continue even with a failure you can also use `ignore_failure true` on your resource although this produces a lot of failure messaging in logs. + +#### Properly support features as an array in windows_feature_dism + +We claimed to support installing features as an array in the windows_feature_dism resource previously, but it didn't actually work. The actual result was a warning that the array of features wasn't available on your platform since we compared the array to available features as if it was a string. We now properly support installation as a array and we do validation on each feature in the array to make sure the features are available on your Windows release. + +#### Install as the default action in windows_feature_powershell + +Due to some previous refactoring the :install action was not the default action for windows_feature_powershell. For all other package resources in Chef install is the default so this would likely lead to some unexpected behavior in cookbooks. This is technically a breaking change, but I suspect everyone assumed :install was always the default. + +#### servermanagercmd.exe Support Removal + +This cookbook previously supported servermanagercmd.exe, which was necessary for feature installation on Windows 2003 / 2008 (not R2) systems. Windows 2003 went full EOL in 2015 and 2008 went into extended support in 2015\. Neither releases are supported platforms for Chef or this cookbook so we've chosen to simplify the code and remove support entirely. + +#### Remove the undocumented node['windows']['rubyzipversion'] attribute + +This attribute was a workaround for a bug in the rubyzip gem YEARS ago that's just not necessary anymore. We also never documented this attribute and a resource shouldn't change behavior based on attributes. + +## 3.5.2 (2018-03-01) + +- Remove value_for_feature_provider helper which wasn't being used and was using deprecated methods +- Add all the Windows Core editions to the version helper +- Simplify / speedup how we find the font directory in windows_font +- Don't bother enabling why-run mode in the resources since it's enabled by default +- Don't include mixlib-shellout in the resources since it's included by default +- Fix installation messaging for windows_feature_powershell to properly show all features being installed +- Use powershell for the share creation / deletion in windows_share. This speeds up the runs and fixes some of the failures. + +## 3.5.1 (2018-02-23) + +- Add a new `shortcut_name` property to `windows_shortcut` +- Use Chef's built in registry_key_exists helper in `windows_printer_port` +- Fix the `source` coerce in `windows_font` + +## 3.5.0 (2018-02-23) + +- Add Windows 2016 to the supported releases in the readme +- Add Windows 10 detection to the version helper +- Remove the Chefspec matchers. These are auto generated by ChefSpec now. If this causes your specs to fail upgrade ChefDK +- In `certificate_binding` support `hostnameport` option if address is a hostname +- Convert several tests to InSpec tests and add additional test scenarios +- Remove `required: true` on the name_properties, which serves no purpose and will be a Foodcritic rule in the next Foodcritic release +- Fix `windows_feature` logging to work when the user provides an array of features +- Don't both coercing a symbol into a symbol in the `windows_auto_run` resource. +- Switch `windows_font` over to the built in path helper in Chef, which a much more robust +- Don't coerce forward slashes to backslashes in the `windows_font` `source` property if the source is a URI +- Add a new `path` property to `windows_pagefile` for properly overriding the resource name +- Coerce backslashes to forward slashes in `windows_pagefile`'s `path` property so we do the right thing even if a user gives bad input +- Add a new `program_name` property in windows_auto_run for overriding the resource name +- Rename `program` property to `path` in windows_auto_run. The legacy name will continue to work, but cookbooks should be updated +- Coerce the `path` property to use backslashes in `windows_auto_run` so it works no matter what format of path the user provides +- Avoid writing out an extra space in `windows_auto_run`'s registry entry when the user doesn't specify an arg +- Added yard comments to many of the helper methods + +## 3.4.4 (2018-01-19) + +- Fix undefined method for 'ipv4_address' in windows_printer_port + +## 3.4.3 (2018-01-04) + +- Added missing parentheses around PersistKeySet flag that was preventing PowerShell from creating X509Certificate2 object + +## 3.4.2 (2018-01-02) + +- Add deprecation warnings for windows_path and windows_task which are now included in Chef 13\. These will be removed from this cookbook in Sept 2018. + +## 3.4.1 (2017-12-06) + +- Fix long-running filtering by replace LIKE with equality sign in the share resource +- Use logical OR instead of AND when trying to detect share permissions changing in the share resource +- Remove extra new_resource.updated_by_last_action in the windows_task resource that resulted in a Foodcritic warning + +## 3.4.0 (2017-11-14) + +- Add a root key property for the auto_run resource +- Fix a resource typo where a name_property was still written name_attribute +- Resolve FC108 warnings + +## 3.3.0 (2017-11-06) + +- Add new dns resource. See readme for examples +- Add BUILTIN\Users to SYSTEM_USERS for windows_task + +## 3.2.0 (2017-10-17) + +- Add management_tools property to windows_feature powershell provider which installs the various management tools +- Fix deprecations_namespace_collisions +- Add additional certificate store names +- Add the ability to define a timeout on windows_feature +- Multiple improvements to the font resource + + - Improved logging, particularly debug logging + - Allow pulling the font from a remote location using remote_file + - Fix some failures in fetching local fonts + - Added a font_name property that allows you specify the local name of the font, which can be different from the name of the chef resource. This allows you to create more friendly resource names for your converge. + - Handle font resources with backslashes in their source + +- Remove source property from servermanagercmd provider as it does not support it. + +- Remove converge_by around inner powershell_script resource to stop it always reporting as changed + +- Change install feature guards to work on Windows 2008r2 + +- Allow dism feature installs to work on non-English systems + +## 3.1.3 (2017-09-18) + +### windows_task and windows_path deprecation + +s of chef-client 13.0+ and 13.4+ windows_task and windows_path are now included in the Chef client. windows_task underwent a full rewrite that greatly improved the functionality and idempotency of the resource. We highly recommend using these new resources by upgrading to Chef 13.4 or later. If you are running these more recent Chef releases the windows_task and windows_path resources within chef-client will take precedence over those in this cookbook. In September 2018 we will release a new major version of this cookbook that removes windows_task and windows_path. + +## 3.1.2 (2017-08-14) + +- Revert "Require path in the share resource instead of raising if it's missing" which was causing failures due to a bug in the chef-client + +## 3.1.1 (2017-06-13) + +- Replace Windows 7 testing with Windows 10 testing +- Expand debug logging in the pagefile resource +- Require path in the share resource instead of raising if it's missing +- Make pagefile properly fail the run if the command fails to run + +## 3.1.0 (2017-05-30) + +- Updated resource documentation for windows_pagefile +- Declare windows_feature as why-runnable +- Remove action_class.class_eval usage and require 12.7+ as class_eval is causing issues with later versions of Chef + +## 3.0.5 (2017-04-07) + +- Add support for windows_task resource to run on non-English editions of Windows +- Ensure chef-client 12.6 compatibility with action_class.class_eval + +## 3.0.4 (2017-03-29) + +- restoring the `cached_file` helper as downstream cookbooks use it. + +## 3.0.3 (2017-03-28) + +- Correct a typo in a Log message + +## 3.0.2 (2017-03-21) + +- Fix `windows_zipfile` resource to properly download and cache the zip archives + +## 3.0.1 (2017-03-17) + +- Fix `windows_share` to be fully idempotent. Fixes #447 + +## 3.0.0 (2017-03-15) + +**Warning** This release includes multiple breaking changes as we refactored all existing resources and resolved many longstanding bugs. We highly recommend exercising caution and fully testing this new version before rolling it out to a production environment. + +### Breaking changes + +- This cookbook now requires Chef 12.6 or later and we highly recommend even more recent Chef 12 releases as they resolve critical Windows bugs and include new Windows specific functionality. +- The windows_package resource has been removed as it is built into chef-client 12.6+ and the built in version is faster / more robust. +- The powershell out helper has been removed as it is now included in chef-client 12.6+ +- The default recipe no longer installs the various Windows rubygems required for non-omnibus chef-client installs. This was a leftover from Chef 10 and is no longer necessary, or desired, as we ship these gems in every Windows chef release. +- windows_feature has been heavily refactored and in doing so the method used to control the underlying providers has changed. You can no longer specify which windows_feature provider to use by setting `node['windows']['feature_provider']` or by setting the `provider` property on the resource itself. Instead you must set `install_method` to specify the correct underlying installation method. You can also now reference the resources directly by using `windows_feature_servermanagercmd`, `windows_feature_powershell` or `windows_feature_dism` instead of `windows_feature` + +- Windows_font's `file` property has been renamed to `name` to avoid collisions with the Chef file resource. + +### Other Changes + +- All LWRPs in this cookbook have been refactored to be custom resources +- windows_path, windows_shortcut, and windows_zipfile have been updated to be idempotent with support for why-run mode and proper notification when the resources actually update +- windows_pagefile now validates the name of the pagefile to avoid cryptic error messages +- A new `share` resource has been added for setting up Windows shares +- TrustedPeople certificate store has been added to the list of allowed store_names in the certificate resources +- version helper constant definitions has been improved +- A new `all` property has been added to the Windows feature resource to install all dependent features. See the windows feature test recipe for usage examples. +- Windows feature now accepts an array of features, which greatly speeds up feature installs and simplifies recipe code +- The path resource now accepts paths with either forward slashes or backslashes and correctly adds the path using Windows style backslash. +- The powershell provider for windows_feature resource has been fixed to properly import ServerManager in the :remove action +- Testing has been switched from a Rakefile to the new Delivery local mode +- Several issues with testing the resources on non-Windows hosts in ChefSpec have been resolved +- A new `source` property has been added to the windows_feature_powershell resource +- Additional test suites have been added to Test Kitchen to cover all resources and those test suites are now being executed in AppVeyer on every PR +- Travis CI testing has been removed and all testing is being performed in AppVeyer + +## 2.1.1 (2016-11-23) + +- Make sure the ohai plugin is available when installing features + +## 2.1.0 (2016-11-22) + +- Reduce expensive executions of dism in windows_feature by using a new Ohai plugin +- Add guard around chef_version metadata for Opsworks and older Chef 12 clients +- Update the rakefile to the latest +- Add deprecation dates for the windows_package and powershell functionality that has been moved to core Chef. These will be removed 4/17 when we release Chef 13 +- Provide helper method to get windows version info +- Allow defining http acl using SDDL + +## 2.0.2 (2016-09-07) + +- Added the powershell_out mixin back to allow for Chef 12.1-12.3 compatibility +- Set the dependency back to Chef 12.1 + +## 2.0.1 (2016-09-07) + +- Clarify the platforms we support in the readme +- Require Chef 12.4 which included powershell_out + +## 2.0.0 (2016-09-07) + +This cookbook now requires Chef 12.1+. Resources (lwrps) that have been moved into the chef-client have been removed from this cookbook. While the functionality in the chef-client is similar, and in many cases improved, the names and properties have changed in some cases. Make sure to check for full documentation on each of these resources, and as usual carefully test your cookbooks before upgrading to this new release. + +### Removed resources and helpers: + +- windows_reboot provider +- windows_batch provider +- windows_registry provider +- Powershell out for only_if / not_if statements +- Windows Architecture Helper +- Reboot handler and the dependency on the chef_handler cookbook + +#### Changes resource behavior + +- For Chef clients 12.6 and later the windows_package provider will no longer be used as windows_package logic is now included in Chef. Chef 12.1 - 12.5.1 clients will continue to default to the windows_package provider in this cookbook for full compatibility. + +#### Additional changes + +- Updated and expanded testing +- Fixed the windows_feature powershell provider to run on Windows 2008 / 2008 R2 +- Added TrustedPublisher as a valid cert store_name +- Updated the certificate_binding resource to respect the app_id property +- Added why-run support to the auto_run resource + +## 1.44.3 (2016-08-16) + +- Remove support for ChefSpec <4.1 in the matchers +- Add missing Chefspec matchers + +## 1.44.2 (2016-08-15) + +- Add missing windows_font matcher +- Add chef_version to the metadata +- Switch from Rubocop to Cookstyle and use our improved Rakefile +- Remove test deps from the Gemfile that are in ChefDK + +## v1.44.1 + +- [PR 375](https://github.com/chef-cookbooks/windows/pull/375) - Fix comparison of string to number in platform_version +- [PR 376](https://github.com/chef-cookbooks/windows/pull/376) - Switch to cookstyle, update gem deps and other minor stuff +- [PR 377](https://github.com/chef-cookbooks/windows/pull/377) - add test and check for feature installation through powershell + +## v1.44.0 + +- [PR 372](https://github.com/chef-cookbooks/windows/pull/372) - Support Server 2008 for feature installs via PowerShell + +## v1.43.0 + +- [PR 369](https://github.com/chef-cookbooks/windows/pull/369) - Add a enable_windows_task matcher + +## v1.42.0 + +- [PR 365](https://github.com/chef-cookbooks/windows/pull/365) - Escape command quotes when passing to schtasks + +## v1.41.0 + +- [PR 364](https://github.com/chef-cookbooks/windows/pull/364) - Configurable font source + +## v1.40.0 + +- [PR 357](https://github.com/chef-cookbooks/windows/pull/357) - Fixes for schtasks +- [PR 359](https://github.com/chef-cookbooks/windows/pull/359) - take bundler out of the appveyor build +- [PR 356](https://github.com/chef-cookbooks/windows/pull/356) - Misc fixes and updates +- [PR 355](https://github.com/chef-cookbooks/windows/pull/355) - bump and pin rubocop, fix broken cop +- [PR 348](https://github.com/chef-cookbooks/windows/pull/348) - Make notify work for `windows_task` + +## v1.39.2 + +- [PR 329](https://github.com/chef-cookbooks/windows/pull/329) - Silence `compile_time` warning for `chef_gem` +- [PR 338](https://github.com/chef-cookbooks/windows/pull/338) - ChefSpec matchers for `windows_certificate` +- [PR 341](https://github.com/chef-cookbooks/windows/pull/341) - Updated rubocop and FoodCritic compliance +- [PR 336](https://github.com/chef-cookbooks/windows/pull/336) - Fixed where clause compliance with PS v1/v2 + +## v1.39.1 + +- [PR 325](https://github.com/chef-cookbooks/windows/pull/325) - Raise an error if a bogus feature is given to the powershell `windows_feature` provider +- [PR 326](https://github.com/chef-cookbooks/windows/pull/326) - Fix `windows_font` and copy the font file before installation + +## v1.39.0 + +- [PR 305](https://github.com/chef-cookbooks/windows/pull/305) - Added `months` attribute to `windows_task` and allow `frequency_modifier` to accept values 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'LAST', and 'LASTDAY' for monthly frequency +- [PR 310](https://github.com/chef-cookbooks/windows/pull/310) - Fix `windows_task` breaks when there is a space in the user name +- [PR 314](https://github.com/chef-cookbooks/windows/pull/314) - fixes reboot handling on some chef versions below 11.12 +- [PR 317](https://github.com/chef-cookbooks/windows/pull/317) - Adds a `disable_windows_task` matcher +- [PR 311](https://github.com/chef-cookbooks/windows/pull/311) - Implements the `cwd` attribute of `windows_task` +- [PR 318](https://github.com/chef-cookbooks/windows/pull/318) - Use dsl instead of manual resource instanciation +- [PR 303](https://github.com/chef-cookbooks/windows/pull/303) - Fix `http_acl` idempotency when user name contains a space +- [PR 257](https://github.com/chef-cookbooks/windows/pull/257) - Speed up windows_feature dism provider +- [PR 319](https://github.com/chef-cookbooks/windows/pull/319) - Add a `.kitchen.cloud.yml` for kitchen testing on Azure +- [PR 315](https://github.com/chef-cookbooks/windows/pull/315) - Deprecate `windows_package` and forward to `Chef::Provider::Package::Windows` when running 12.6 or higher + +## v1.38.4 + +- [PR 295](https://github.com/chef-cookbooks/windows/pull/295) - Escape `http_acl` username +- [PR 293](https://github.com/chef-cookbooks/windows/pull/293) - Separating assignments to `code_script` and `guard_script` as they should be different scripts and not hold the same reference +- [Issue 298](https://github.com/chef-cookbooks/windows/issues/298) - `windows_certificate_binding` is ignoring `store_name` attribute and always saving to `MY` +- [Issue 296](https://github.com/chef-cookbooks/windows/pull/302) - Fixes `windows_certificate` idempotentcy on chef 11 clients + +## v1.38.3 + +- Make `windows_task` resource idempotent (double quotes need to be single when comparing) +- [Issue 245](https://github.com/chef-cookbooks/windows/issues/256) - Fix `No resource, method, or local variable named`password' for `Chef::Provider::WindowsTask'` when `interactive_enabled` is `true` + +## v1.38.2 + +- Lazy-load windows-pr gem library files. Chef 12.5 no longer includes the windows-pr gem. Earlier versions of this cookbook will not compile on Chef 12.5. + +## v1.38.1 (2015-07-28) + +- Publishing without extended metadata + +## v1.38.0 (2015-07-27) + +- Do not set new_resource.password to nil, Fixes #219, Fixes #220 +- Add `windows_certificate` resource #212 +- Add `windows_http_acl` resource #214 + +## v1.37.0 (2015-05-14) + +- fix `windows_package` `Chef.set_resource_priority_array` warning +- update `windows_task` to support tasks in folders +- fix `windows_task` delete action +- replace `windows_task` name attribute with 'task_name' +- add :end action to 'windows_task' +- Tasks created with the `windows_task` resource default to the SYSTEM account +- The force attribute for `windows_task` makes the :create action update the definition. +- `windows_task` :create action will force an update of the task if the user or command differs from the currently configured setting. +- add default provider for `windows_feature` +- add a helper to make sure `WindowsRebootHandler` works in ChefSpec +- added a source and issues url to the metadata for Supermarket +- updated the Gemfile and .kitchen.yml to reflect the latest test-kitchen windows guest support +- started tests using the kitchen-pester verifier + +## v1.36.6 (2014-12-18) + +- reverting all chef_gem compile_time work + +## v1.36.5 (2014-12-18) + +- Fix zipfile provider + +## v1.36.4 (2014-12-18) + +- Fix Chef chef_gem with Chef::Resource::ChefGem.method_defined?(:compile_time) + +## v1.36.3 (2014-12-18) + +- Fix Chef chef_gem below 12.1.0 + +## v1.36.2 (2014-12-17) + +- Being explicit about usage of the chef_gem's compile_time property. +- Eliminating future deprecation warnings in Chef 12.1.0 + +## v1.36.1 (2014-12-17) + +- [PR 160](https://github.com/chef-cookbooks/windows/pull/160) - Fix Chef 11.10 / versions without windows_package in core + +## v1.36.0 (2014-12-16) + +- [PR 145](https://github.com/chef-cookbooks/windows/pull/145) - do not fail on non-existant task +- [PR 144](https://github.com/chef-cookbooks/windows/pull/144) - Add a zip example to the README +- [PR 110](https://github.com/chef-cookbooks/windows/pull/110) - More zip documentation +- [PR 148](https://github.com/chef-cookbooks/windows/pull/148) - Add an LWRP for font installation +- [PR 151](https://github.com/chef-cookbooks/windows/pull/151) - Fix windows_package on Chef 12, add integration tests +- [PR 129](https://github.com/chef-cookbooks/windows/pull/129) - Add enable/disable actions to task LWRP +- [PR 115](https://github.com/chef-cookbooks/windows/pull/115) - require Chef::Mixin::PowershellOut before using it +- [PR 88](https://github.com/chef-cookbooks/windows/pull/88) - Code 1003 from servermanagercmd.exe is valid + +## v1.34.8 (2014-10-31) + +- [Issue 137](https://github.com/chef-cookbooks/windows/issues/137) - windows_path resource breaks with ruby 2.x + +## v1.34.6 (2014-09-22) + +- [Chef-2009](https://github.com/chef/chef/issues/2009) - Patch to work around a regression in [Chef](https://github.com/chef/chef) + +## v1.34.2 (2014-08-12) + +- [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Remove rubygems / Internet wmi-lite dependency (PR #108) + +## v1.34.0 (2014-08-04) + +- [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Use wmi-lite to fix Chef 11.14.2 break in rdp-ruby-wmi dependency + +## v1.32.1 (2014-07-15) + +- Fixes broken cookbook release + +## v1.32.0 (2014-07-11) + +- Add ChefSpec resource methods to allow notification testing (@sneal) +- Add use_inline_resources to providers (@micgo) +- [COOK-4728] - Allow reboot handler to be used as an exception handler +- [COOK-4620] - Ensure win_friendly_path doesn't error out when ALT_SEPARATOR is nil + +## v1.31.0 (2014-05-07) + +- [COOK-2934] - Add windows_feature support for 2 new DISM attributes: all, source + +## v1.30.2 (2014-04-02) + +- [COOK-4414] - Adding ChefSpec matchers + +## v1.30.0 (2014-02-14) + +- [COOK-3715] - Unable to create a startup task with no login +- [COOK-4188] - Add powershell_version method to return Powershell version + +## v1.12.8 (2014-01-21) + +- [COOK-3988] Don't unescape URI before constructing it. + +## v1.12.6 (2014-01-03) + +- [COOK-4168] Circular dep on powershell - moving powershell libraries into windows. removing dependency on powershell + +## v1.12.4 + +Fixing depend/depends typo in metadata.rb + +## v1.12.2 + +### Bug + +- **[COOK-4110](https://tickets.chef.io/browse/COOK-4110)** - feature_servermanager installed? method regex bug + +## v1.12.0 + +### Bug + +- **[COOK-3793](https://tickets.chef.io/browse/COOK-3793)** - parens inside parens of README.md don't render + +### New Feature + +- **[COOK-3714](https://tickets.chef.io/browse/COOK-3714)** - Powershell features provider and delete support. + +## v1.11.0 + +### Improvement + +- **[COOK-3724](https://tickets.chef.io/browse/COOK-3724)** - Rrecommend built-in resources over cookbook resources +- **[COOK-3515](https://tickets.chef.io/browse/COOK-3515)** - Remove unprofessional comment from library +- **[COOK-3455](https://tickets.chef.io/browse/COOK-3455)** - Add Windows Server 2012R2 to windows cookbook version helper + +### Bug + +- **[COOK-3542](https://tickets.chef.io/browse/COOK-3542)** - Fix an issue where `windows_zipfile` fails with LoadError +- **[COOK-3447](https://tickets.chef.io/browse/COOK-3447)** - Allow Overriding Of The Default Reboot Timeout In windows_reboot_handler +- **[COOK-3382](https://tickets.chef.io/browse/COOK-3382)** - Allow windows_task to create `on_logon` tasks +- **[COOK-2098](https://tickets.chef.io/browse/COOK-2098)** - Fix and issue where the `windows_reboot` handler is ignoring the reboot time + +### New Feature + +- **[COOK-3458](https://tickets.chef.io/browse/COOK-3458)** - Add support for `start_date` and `start_time` in `windows_task` + +## v1.10.0 + +### Improvement + +- [COOK-3126]: `windows_task` should support the on start frequency +- [COOK-3127]: Support the force option on task create and delete + +## v1.9.0 + +### Bug + +- [COOK-2899]: windows_feature fails when a feature install requires a reboot +- [COOK-2914]: Foodcritic failures in Cookbooks +- [COOK-2983]: windows cookbook has foodcritic failures + +### Improvement + +- [COOK-2686]: Add Windows Server 2012 to version.rb so other depending chef scripts can detect Windows Server 2012 + +## v1.8.10 + +When using Windows qualified filepaths (C:/foo), the #absolute? method for URI returns true, because "C" is the scheme. + +This change checks that the URI is http or https scheme, so it can be passed off to remote_file appropriately. + +- [COOK-2729] - allow only http, https URI schemes + +## v1.8.8 + +- [COOK-2729] - helper should use URI rather than regex and bare string + +## v1.8.6 + +- [COOK-968] - `windows_package` provider should gracefully handle paths with spaces +- [COOK-222] - `windows_task` resource does not declare :change action +- [COOK-241] - Windows cookbook should check for redefined constants +- [COOK-248] - Windows package install type is case sensitive + +## v1.8.4 + +- [COOK-2336] - MSI That requires reboot returns with RC 3010 and causes chef run failure +- [COOK-2368] - `version` attribute of the `windows_package` provider should be documented + +## v1.8.2 + +**Important**: Use powershell in nodes expanded run lists to ensure powershell is downloaded, as powershell has a dependency on this cookbook; v1.8.0 created a circular dependency. + +- [COOK-2301] - windows 1.8.0 has circular dependency on powershell + +## v1.8.0 + +- [COOK-2126] - Add checksum attribute to `windows_zipfile` +- [COOK-2142] - Add printer and `printer_port` LWRPs +- [COOK-2149] - Chef::Log.debug Windows Package command line +- [COOK-2155] -`windows_package` does not send checksum to `cached_file` in `installer_type` + +## v1.7.0 + +- [COOK-1745] - allow for newer versions of rubyzip + +## v1.6.0 + +- [COOK-2048] - undefined method for Falseclass on task :change when action is :nothing (and task doesn't exist) +- [COOK-2049] - Add `windows_pagefile` resource + +## v1.5.0 + +- [COOK-1251] - Fix LWRP "NotImplementedError" +- [COOK-1921] - Task LWRP will return true for resource exists when no other scheduled tasks exist +- [COOK-1932] - Include :change functionality to windows task lwrp + +## v1.4.0: + +- [COOK-1571] - `windows_package` resource (with msi provider) does not accept spaces in filename +- [COOK-1581] - Windows cookbook needs a scheduled tasks LWRP +- [COOK-1584] - `windows_registry` should support all registry types + +## v1.3.4 + +- [COOK-1173] - `windows_registry` throws Win32::Registry::Error for action :remove on a nonexistent key +- [COOK-1182] - windows package sets start window title instead of quoting a path +- [COOK-1476] - zipfile lwrp should support :zip action +- [COOK-1485] - package resource fails to perform install correctly when "source" contains quote +- [COOK-1519] - add action :remove for path lwrp + +## v1.3.2 + +- [COOK-1033] - remove the `libraries/ruby_19_patches.rb` file which causes havoc on non-Windows systems. +- [COOK-811] - add a timeout parameter attribute for `windows_package` + +## v1.3.0 + +- [COOK-1323] - Update for changes in Chef 0.10.10. + + - Setting file mode doesn't make sense on Windows (package provider + - and `reboot_handler` recipe) + - Prefix ::Win32 to avoid namespace collision with Chef::Win32 + - (`registry_helper` library) + - Use chef_gem instead of gem_package so gems get installed correctly under the Ruby environment Chef runs in (reboot_handler recipe, zipfile provider) + +## v1.2.12 + +- [COOK-1037] - specify version for rubyzip gem +- [COOK-1007] - `windows_feature` does not work to remove features with dism +- [COOK-667] - shortcut resource + provider for Windows platforms + +## v1.2.10 + +- [COOK-939] - add `type` parameter to `windows_registry` to allow binary registry keys. +- [COOK-940] - refactor logic so multiple values get created. + +## v1.2.8 + +- FIX: Older Windows (Windows Server 2003) sometimes return 127 on successful forked commands +- FIX: `windows_package`, ensure we pass the WOW* registry redirection flags into reg.open + +## v1.2.6 + +- patch to fix [CHEF-2684], Open4 is named Open3 in Ruby 1.9 +- Ruby 1.9's Open3 returns 0 and 42 for successful commands +- retry keyword can only be used in a rescue block in Ruby 1.9 + +## v1.2.4 + +- `windows_package` - catch Win32::Registry::Error that pops up when searching certain keys + +## v1.2.2 + +- combined numerous helper libarires for easier sharing across libaries/LWRPs +- renamed Chef::Provider::WindowsFeature::Base file to the more descriptive `feature_base.rb` +- refactored `windows_path` LWRP + + - :add action should MODIFY the the underlying ENV variable (vs CREATE) + - deleted greedy :remove action until it could be made more idempotent + +- added a `windows_batch` resource/provider for running batch scripts remotely + +## v1.2.0 + +- [COOK-745] gracefully handle required server restarts on Windows platform + + - WindowsRebootHandler for requested and pending reboots + - `windows_reboot` LWRP for requesting (receiving notifies) reboots + - `reboot_handler` recipe for enabling WindowsRebootHandler as a report handler + +- [COOK-714] Correct initialize misspelling + +- RegistryHelper - new `get_values` method which returns all values for a particular key. + +## v1.0.8 + +- [COOK-719] resource/provider for managing windows features +- [COOK-717] remove `windows_env_vars` resource as env resource exists in core chef +- new `Windows::Version` helper class +- refactored `Windows::Helper` mixin + +## v1.0.6 + +- added `force_modify` action to `windows_registry` resource +- add `win_friendly_path` helper +- re-purpose default recipe to install useful supporting windows related gems + +## v1.0.4 + +- [COOK-700] new resources and improvements to the `windows_registry` provider (thanks Paul Morton!) + + - Open the registry in the bitednes of the OS + - Provide convenience methods to check if keys and values exit + - Provide convenience method for reading registry values + - NEW - `windows_auto_run` resource/provider + - NEW - `windows_env_vars` resource/provider + - NEW - `windows_path` resource/provider + +- re-write of the `windows_package` logic for determining current installed packages + +- new checksum attribute for `windows_package` resource...useful for remote packages + +## v1.0.2 + +- [COOK-647] account for Wow6432Node registry redirecter +- [COOK-656] begin/rescue on win32/registry + +## v1.0.0 + +- [COOK-612] initial release diff --git a/vendor-cookbooks/windows/CONTRIBUTING.md b/vendor-cookbooks/windows/CONTRIBUTING.md new file mode 100644 index 0000000..ef2f2b8 --- /dev/null +++ b/vendor-cookbooks/windows/CONTRIBUTING.md @@ -0,0 +1,2 @@ +Please refer to +https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/windows/README.md b/vendor-cookbooks/windows/README.md new file mode 100644 index 0000000..eabdd9f --- /dev/null +++ b/vendor-cookbooks/windows/README.md @@ -0,0 +1,426 @@ +# Windows Cookbook + +[![Build status](https://ci.appveyor.com/api/projects/status/9x4uepmm1g4rktie/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/windows/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/windows.svg)](https://supermarket.chef.io/cookbooks/windows) + +Provides a set of Windows-specific resources to aid in the creation of cookbooks/recipes targeting the Windows platform. + +## Requirements + +### Platforms + +- Windows 7 +- Windows Server 2008 R2 +- Windows 8, 8.1 +- Windows Server 2012 (R1, R2) +- Windows Server 2016 + +### Chef + +- Chef 14.7+ + +## Resources + +### windows_certificate_binding + +Binds a certificate to an HTTP port to enable TLS communication. + +#### Actions + +- `:create` - creates or updates a binding. +- `:delete` - deletes a binding. + +#### Properties + +- `cert_name` - name attribute. The thumbprint(hash) or subject that identifies the certificate to be bound. +- `name_kind` - indicates the type of cert_name. One of :subject (default) or :hash. +- `address` - the address to bind against. Default is 0.0.0.0 (all IP addresses). One of: + - IP v4 address `1.2.3.4` + - IP v6 address `[::1]` + - Host name `www.foo.com` +- `port` - the port to bind against. Default is 443. +- `app_id` - the GUID that defines the application that owns the binding. Default is the values used by IIS. +- `store_name` - the store to locate the certificate in. One of: + - MY (Personal) + - CA (Intermediate Certification Authorities) + - ROOT (Trusted Root Certification Authorities) + - TRUSTEDPUBLISHER (Trusted Publishers) + - CLIENTAUTHISSUER (Client Authentication Issuers) + - REMOTE DESKTOP (Remote Desktop) + - TRUSTEDDEVICES (Trusted Devices) + - WEBHOSTING (Web Hosting) + - AUTHROOT (Third-Party Root Certification Authorities) + - TRUSTEDPEOPLE (Trusted People) + - SMARTCARDROOT (Smart Card Trusted Roots) + - TRUST (Enterprise Trust) + +#### Examples + +```ruby +# Bind the first certificate matching the subject to the default TLS port +windows_certificate_binding "me.acme.com" do +end +``` + +```ruby +# Bind a cert from the CA store with the given hash to port 4334 +windows_certificate_binding "me.acme.com" do + cert_name "d234567890a23f567c901e345bc8901d34567890" + name_kind :hash + store_name "CA" + port 4334 +end +``` + +### windows_dns + +`Note`: This resource is now included in Chef 15 and later. If you are using newer versions of [windows](https://devblogs.microsoft.com/powershell/configuration-in-a-devops-world-windows-powershell-desired-state-configuration/) then should use the core [resource](https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#windows_dns_record-resource) instead of windows_dns. + +Configures A and CNAME records in Windows DNS. This requires the DNSCMD to be installed, which is done by adding the DNS role to the server or installing the Remote Server Admin Tools. + +#### Actions + +- :create: creates/updates the DNS entry +- :delete: deletes the DNS entry + +#### Properties + +- host_name: name attribute. FQDN of the entry to act on. +- dns_server: the DNS server to update. Default is local machine (.) +- record_type: the type of record to create. One of A (default) or CNAME +- target: for A records an array of IP addresses to associate with the host; for CNAME records the FQDN of the host to alias +- ttl: if > 0 then set the time to live of the record + +#### Examples + +```ruby +# Create A record linked to 2 addresses with a 10 minute ttl +windows_dns "m1.chef.test" do + target ['10.9.8.7', '1.2.3.4'] + ttl 600 +end +``` + +```ruby +# Delete records. target is mandatory although not used +windows_dns "m1.chef.test" do + action :delete + target [] +end +``` + +```ruby +# Set an alias against the node in a role +nodes = search( :node, "role:my_service" ) +windows_dns "myservice.chef.test" do + record_type 'CNAME' + target nodes[0]['fqdn'] +end +``` + +### windows_http_acl + +Sets the Access Control List for an http URL to grant non-admin accounts permission to open HTTP endpoints. + +#### Actions + +- `:create` - creates or updates the ACL for a URL. +- `:delete` - deletes the ACL from a URL. + +#### Properties + +- `url` - the name of the url to be created/deleted. +- `sddl` - the DACL string configuring all permissions to URL. Mandatory for create if user is not provided. Can't be use with `user`. +- `user` - the name (domain\user) of the user or group to be granted permission to the URL. Mandatory for create if sddl is not provided. Can't be use with `sddl`. Only one user or group can be granted permission so this replaces any previously defined entry. If you receive a parameter error your user may not exist. + +#### Examples + +```ruby +windows_http_acl 'http://+:50051/' do + user 'pc\\fred' +end +``` + +```ruby +# Grant access to users "NT SERVICE\WinRM" and "NT SERVICE\Wecsvc" via sddl +windows_http_acl 'http://+:5985/' do + sddl 'D:(A;;GX;;;S-1-5-80-569256582-2953403351-2909559716-1301513147-412116970)(A;;GX;;;S-1-5-80-4059739203-877974739-1245631912-527174227-2996563517)' +end +``` + +```ruby +windows_http_acl 'http://+:50051/' do + action :delete +end +``` + +### windows_schannel + +Used to configure the schannel security settings in windows, this is used by dotnet apps and PowerShell to be able to speak to tls 1.2 endpoints + +#### Actions + +- `configure`: Configures the setting + +#### Properties + +property | type | default | description +------------------------ | ---------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- +`use_strong_crypto` | True, False | true | Enables or disables the setting + +### windows_user_privilege + +Adds the `principal` (User/Group) to the specified privileges (such as `Logon as a batch job` or `Logon as a Service`). + +#### Actions + +- `:add` - add the specified privileges to the `principal` +- `:remove` - remove the specified privilege of the `principal` + +#### Properties + +- `principal` - Name attribute, Required, String. The user or group to be granted privileges. +- `privilege` - Required, String/Array. The privilege(s) to be granted. + +#### Examples + +Grant the Administrator user the `Logon as a batch job` and `Logon as a service` privilege. + +```ruby +windows_user_privilege 'Administrator' do + privilege %w(SeBatchLogonRight SeServiceLogonRight) +end +``` + +Remove `Logon as a batch job` privilege of Administrator. + +```ruby +windows_user_privilege 'Administrator' do + privilege %w(SeBatchLogonRight) + action :remove +end +``` + +#### Available Privileges + +``` +SeTrustedCredManAccessPrivilege Access Credential Manager as a trusted caller +SeNetworkLogonRight Access this computer from the network +SeTcbPrivilege Act as part of the operating system +SeMachineAccountPrivilege Add workstations to domain +SeIncreaseQuotaPrivilege Adjust memory quotas for a process +SeInteractiveLogonRight Allow log on locally +SeRemoteInteractiveLogonRight Allow log on through Remote Desktop Services +SeBackupPrivilege Back up files and directories +SeChangeNotifyPrivilege Bypass traverse checking +SeSystemtimePrivilege Change the system time +SeTimeZonePrivilege Change the time zone +SeCreatePagefilePrivilege Create a pagefile +SeCreateTokenPrivilege Create a token object +SeCreateGlobalPrivilege Create global objects +SeCreatePermanentPrivilege Create permanent shared objects +SeCreateSymbolicLinkPrivilege Create symbolic links +SeDebugPrivilege Debug programs +SeDenyNetworkLogonRight Deny access this computer from the network +SeDenyBatchLogonRight Deny log on as a batch job +SeDenyServiceLogonRight Deny log on as a service +SeDenyInteractiveLogonRight Deny log on locally +SeDenyRemoteInteractiveLogonRight Deny log on through Remote Desktop Services +SeEnableDelegationPrivilege Enable computer and user accounts to be trusted for delegation +SeRemoteShutdownPrivilege Force shutdown from a remote system +SeAuditPrivilege Generate security audits +SeImpersonatePrivilege Impersonate a client after authentication +SeIncreaseWorkingSetPrivilege Increase a process working set +SeIncreaseBasePriorityPrivilege Increase scheduling priority +SeLoadDriverPrivilege Load and unload device drivers +SeLockMemoryPrivilege Lock pages in memory +SeBatchLogonRight Log on as a batch job +SeServiceLogonRight Log on as a service +SeSecurityPrivilege Manage auditing and security log +SeRelabelPrivilege Modify an object label +SeSystemEnvironmentPrivilege Modify firmware environment values +SeManageVolumePrivilege Perform volume maintenance tasks +SeProfileSingleProcessPrivilege Profile single process +SeSystemProfilePrivilege Profile system performance +SeUnsolicitedInputPrivilege "Read unsolicited input from a terminal device" +SeUndockPrivilege Remove computer from docking station +SeAssignPrimaryTokenPrivilege Replace a process level token +SeRestorePrivilege Restore files and directories +SeShutdownPrivilege Shut down the system +SeSyncAgentPrivilege Synchronize directory service data +SeTakeOwnershipPrivilege Take ownership of files or other objects +``` + +### windows_zipfile + +`Note`: This resource has been deprecated as Chef Infra Client 15.0 shipped with a new archive_file resource, which natively handles multiple archive formats. Please update any cookbooks using this resource to instead use the `archive_file` resource: https://docs.chef.io/resource_archive_file.html + +Most versions of Windows do not ship with native cli utility for managing compressed files. This resource provides a pure-ruby implementation for managing zip files. Be sure to use the `not_if` or `only_if` meta parameters to guard the resource for idempotence or action will be taken every Chef run. + +#### Actions + +- `:unzip` - unzip a compressed file +- `:zip` - zip a directory (recursively) + +#### Properties + +- `path` - name attribute. The path where files will be (un)zipped to. +- `source` - source of the zip file (either a URI or local path) for :unzip, or directory to be zipped for :zip. +- `overwrite` - force an overwrite of the files if they already exist. +- `checksum` - for :unzip, useful if source is remote, if the local file matches the SHA-256 checksum, Chef will not download it. + +#### Examples + +Unzip a remote zip file locally + +```ruby +windows_zipfile 'c:/bin' do + source 'http://download.sysinternals.com/Files/SysinternalsSuite.zip' + action :unzip + not_if {::File.exists?('c:/bin/PsExec.exe')} +end +``` + +Unzip a local zipfile + +```ruby +windows_zipfile 'c:/the_codez' do + source 'c:/foo/baz/the_codez.zip' + action :unzip +end +``` + +Create a local zipfile + +```ruby +windows_zipfile 'c:/foo/baz/the_codez.zip' do + source 'c:/the_codez' + action :zip +end +``` + +## Libraries + +### WindowsHelper + +Helper that allows you to use helpful functions in windows + +#### installed_packages + +Returns a hash of all DisplayNames installed + +```ruby +# usage in a recipe +::Chef::Recipe.send(:include, Windows::Helper) +hash_of_installed_packages = installed_packages +``` + +#### is_package_installed? + +- `package_name` - The name of the package you want to query to see if it is installed +- `returns` - true if the package is installed, false if it the package is not installed + +Download a file if a package isn't installed + +```ruby +# usage in a recipe to not download a file if package is already installed +::Chef::Recipe.send(:include, Windows::Helper) +is_win_sdk_installed = is_package_installed?('Windows Software Development Kit') + +remote_file 'C:\windows\temp\windows_sdk.zip' do + source 'http://url_to_download/windows_sdk.zip' + action :create_if_missing + not_if {is_win_sdk_installed} +end +``` + +Do something if a package is installed + +```ruby +# usage in a provider +include Windows::Helper +if is_package_installed?('Windows Software Development Kit') + # do something if package is installed +end +``` + +### Windows::VersionHelper + +Helper that allows you to get information on the windows version running on your node. It leverages windows ohai from kernel.os_info, easy to mock and to use even on Linux. + +#### core_version? + +Determines whether the given node is running on a Windows Core. + +```ruby +if ::Windows::VersionHelper.core_version? node + fail 'Windows Core is not supported' +end +``` + +#### workstation_version? + +Determines whether the given node is a windows workstation version (XP, Vista, 7, 8, 8.1, 10) + +```ruby +if ::Windows::VersionHelper.workstation_version? node + fail 'Only server version of windows are supported' +end +``` + +#### server_version? + +Determines whether the given node is a windows server version (Server 2003, Server 2008, Server 2012, Server 2016) + +```ruby +if ::Windows::VersionHelper.server_version? node + puts 'Server version of windows are cool' +end +``` + +#### nt_version + +Determines NT version of the given node + +```ruby +case ::Windows::VersionHelper.nt_version node + when '6.0' then 'Windows vista or Server 2008' + when '6.1' then 'Windows 7 or Server 2008R2' + when '6.2' then 'Windows 8 or Server 2012' + when '6.3' then 'Windows 8.1 or Server 2012R2' + when '10.0' then 'Windows 10' +end +``` + +## Usage + +Place an explicit dependency on this cookbook (using depends in the cookbook's metadata.rb) from any cookbook where you would like to use the Windows-specific resources/providers that ship with this cookbook. + +```ruby +depends 'windows' +``` + +## License & Authors + +- Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io)) +- Author:: Doug MacEachern ([dougm@vmware.com](mailto:dougm@vmware.com)) +- Author:: Paul Morton ([pmorton@biaprotect.com](mailto:pmorton@biaprotect.com)) +- Author:: Doug Ireton ([doug.ireton@nordstrom.com](mailto:doug.ireton@nordstrom.com)) + +```text +Copyright 2011-2018, Chef Software, Inc. +Copyright 2010, VMware, Inc. +Copyright 2011, Business Intelligence Associates, Inc +Copyright 2012, Nordstrom, Inc. + +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. +``` diff --git a/vendor-cookbooks/windows/libraries/powershell_helper.rb b/vendor-cookbooks/windows/libraries/powershell_helper.rb new file mode 100644 index 0000000..be021a3 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/powershell_helper.rb @@ -0,0 +1,53 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: windows +# Library:: powershell_helper +# +# Copyright:: 2011-2018, Chef Software, Inc. +# +# 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. +# + +require 'chef/mixin/shell_out' + +module Powershell + module Helper + include Chef::Mixin::ShellOut + + def powershell_installed? + !powershell_version.nil? + end + + def interpreter + # force 64-bit powershell from 32-bit ruby process + if ::File.exist?("#{ENV['WINDIR']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") + "#{ENV['WINDIR']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" + elsif ::File.exist?("#{ENV['WINDIR']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") + "#{ENV['WINDIR']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" + else + 'powershell.exe' + end + end + + def powershell_version + cmd = shell_out("#{interpreter} -InputFormat none -Command \"& echo $PSVersionTable.psversion.major\"") + if cmd.stdout.empty? # PowerShell 1.0 doesn't have a $PSVersionTable + 1 + else + Regexp.last_match(1).to_i if cmd.stdout =~ /^(\d+)/ + end + rescue Errno::ENOENT + nil + end + end +end diff --git a/vendor-cookbooks/windows/libraries/registry_helper.rb b/vendor-cookbooks/windows/libraries/registry_helper.rb new file mode 100644 index 0000000..3ca2254 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/registry_helper.rb @@ -0,0 +1,356 @@ +# +# Author:: Doug MacEachern () +# Author:: Seth Chisamore () +# Author:: Paul Morton () +# Cookbook:: windows +# Library:: registry_helper +# +# Copyright:: 2010-2017, VMware, Inc. +# Copyright:: 2011-2018, Chef Software, Inc. +# Copyright:: 2011-2017, Business Intelligence Associates, Inc +# +# 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. +# + +if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require 'win32/registry' + require_relative 'wmi_helper' +end + +module Windows + module RegistryHelper + @@native_registry_constant = if ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' || + ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' + 0x0100 + else + 0x0200 + end + + def get_hive_name(path) + Chef::Log.debug('Resolving registry shortcuts to full names') + + reg_path = path.split('\\') + hive_name = reg_path.shift + + hkey = { + 'HKLM' => 'HKEY_LOCAL_MACHINE', + 'HKCU' => 'HKEY_CURRENT_USER', + 'HKU' => 'HKEY_USERS', + }[hive_name] || hive_name + + Chef::Log.debug("Hive resolved to #{hkey}") + hkey + end + + def get_hive(path) + Chef::Log.debug("Getting hive for #{path}") + reg_path = path.split('\\') + hive_name = reg_path.shift + + hkey = get_hive_name(path) + + hive = { + 'HKEY_LOCAL_MACHINE' => ::Win32::Registry::HKEY_LOCAL_MACHINE, + 'HKEY_USERS' => ::Win32::Registry::HKEY_USERS, + 'HKEY_CURRENT_USER' => ::Win32::Registry::HKEY_CURRENT_USER, + }[hkey] + + unless hive + Chef::Application.fatal!("Unsupported registry hive '#{hive_name}'") + end + + Chef::Log.debug("Registry hive resolved to #{hkey}") + hive + end + + def unload_hive(path) + hive = get_hive(path) + if hive == ::Win32::Registry::HKEY_USERS + reg_path = path.split('\\') + priv = Chef::WindowsPrivileged.new + begin + priv.reg_unload_key(reg_path[1]) + rescue + end + end + end + + def set_value(mode, path, values, type = nil) + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key_name = reg_path.join('\\') + + Chef::Log.debug("Creating #{path}") + + create_key(path) unless key_exists?(path, true) + + hive.send(mode, key_name, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| + changed_something = false + values.each do |k, val| + key = k.to_s # wtf. avoid "can't modify frozen string" in win32/registry.rb + cur_val = nil + begin + cur_val = reg[key] + rescue + # subkey does not exist (ok) + end + + next unless cur_val != val + + Chef::Log.debug("setting #{key}=#{val}") + + type = :string if type.nil? + + reg_type = { + binary: ::Win32::Registry::REG_BINARY, + string: ::Win32::Registry::REG_SZ, + multi_string: ::Win32::Registry::REG_MULTI_SZ, + expand_string: ::Win32::Registry::REG_EXPAND_SZ, + dword: ::Win32::Registry::REG_DWORD, + dword_big_endian: ::Win32::Registry::REG_DWORD_BIG_ENDIAN, + qword: ::Win32::Registry::REG_QWORD, + }[type] + + reg.write(key, reg_type, val) + + ensure_hive_unloaded(hive_loaded) + + changed_something = true + end + return changed_something + end + false + end + + def get_value(path, value) + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + + hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| + begin + return reg[value] + rescue + return nil + ensure + ensure_hive_unloaded(hive_loaded) + end + end + end + + def get_values(path) + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| + values = [] + begin + reg.each_value do |name, type, data| + values << [name, type, data] + end + rescue + ensure + ensure_hive_unloaded(hive_loaded) + end + values + end + end + + def delete_value(path, values) + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + Chef::Log.debug("Deleting values in #{path}") + hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| + values.each_key do |key| + name = key.to_s + # Ensure delete operation is idempotent. + if value_exists?(path, key) + Chef::Log.debug("Deleting value #{name} in #{path}") + reg.delete_value(name) + else + Chef::Log.debug("Value #{name} in #{path} does not exist, skipping.") + end + end + end + end + + def create_key(path) + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + Chef::Log.debug("Creating registry key #{path}") + hive.create(key) + end + + def value_exists?(path, value) + if key_exists?(path, true) + + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + + Chef::Log.debug("Attempting to open #{key}") + Chef::Log.debug("Native Constant #{@@native_registry_constant}") + Chef::Log.debug("Hive #{hive}") + + hive.open(key, ::Win32::Registry::KEY_READ | @@native_registry_constant) do |reg| + begin + rtn_value = reg[value] + return true + rescue + return false + ensure + ensure_hive_unloaded(hive_loaded) + end + end + + end + false + end + + # TODO: Does not load user registry... + def key_exists?(path, load_hive = false) + if load_hive + hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) + key = reg_path.join('\\') + else + hive = get_hive(path) + reg_path = path.split('\\') + hive_name = reg_path.shift + root_key = reg_path[0] + key = reg_path.join('\\') + hive_loaded = false + end + + begin + hive.open(key, ::Win32::Registry::Constants::KEY_READ | @@native_registry_constant) + return true + rescue + return false + ensure + ensure_hive_unloaded(hive_loaded) + end + end + + def get_user_hive_location(sid) + reg_key = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\#{sid}" + Chef::Log.debug("Looking for profile at #{reg_key}") + if key_exists?(reg_key) + return get_value(reg_key, 'ProfileImagePath') + else + return nil + end + end + + def resolve_user_to_sid(username) + user_query = execute_wmi_query("select * from Win32_UserAccount where Name='#{username}'") + sid = nil + + user_query.each do |user| + sid = wmi_object_property(user, 'sid') + break + end + + Chef::Log.debug("Resolved user SID to #{sid}") + sid + rescue + nil + end + + def hive_loaded?(path) + hive = get_hive(path) + reg_path = path.split('\\') + hive_name = reg_path.shift + user_hive = path[0] + + if user_hive?(hive) + return key_exists?("#{hive_name}\\#{user_hive}") + else + return true + end + end + + def user_hive?(hive) + hive == ::Win32::Registry::HKEY_USERS + end + + def get_reg_path_info(path) + hive = get_hive(path) + reg_path = path.split('\\') + hive_name = reg_path.shift + root_key = reg_path[0] + hive_loaded = false + + if user_hive?(hive) && !key_exists?("#{hive_name}\\#{root_key}") + reg_path, hive_loaded = load_user_hive(hive, reg_path, root_key) + root_key = reg_path[0] + Chef::Log.debug("Resolved user (#{path}) to (#{reg_path.join('/')})") + end + + [hive, reg_path, hive_name, root_key, hive_loaded] + end + + def load_user_hive(hive, reg_path, user_hive) + Chef::Log.debug("Reg Path #{reg_path}") + # See if the hive is loaded. Logged in users will have a key that is named their SID + # if the user has specified the a path by SID and the user is logged in, this function + # should not be executed. + if user_hive?(hive) && !key_exists?("HKU\\#{user_hive}") + Chef::Log.debug('The user is not logged in and has not been specified by SID') + sid = resolve_user_to_sid(user_hive) + Chef::Log.debug("User SID resolved to (#{sid})") + # Now that the user has been resolved to a SID, check and see if the hive exists. + # If this exists by SID, the user is logged in and we should use that key. + # TODO: Replace the username with the sid and send it back because the username + # does not exist as the key location. + load_reg = false + if key_exists?("HKU\\#{sid}") + reg_path[0] = sid # use the active profile (user is logged on) + Chef::Log.debug("HKEY_USERS Mapped: #{user_hive} -> #{sid}") + else + Chef::Log.debug('User is not logged in') + load_reg = true + end + + # The user is not logged in, so we should load the registry from disk + if load_reg + profile_path = get_user_hive_location(sid) + unless profile_path.nil? + ntuser_dat = "#{profile_path}\\NTUSER.DAT" + if ::File.exist?(ntuser_dat) + priv = Chef::WindowsPrivileged.new + if priv.reg_load_key(sid, ntuser_dat) + Chef::Log.debug("RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})") + reg_path[0] = sid + else + Chef::Log.debug("Failed RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})") + end + end + end + end + end + + [reg_path, load_reg] + end + + private + + def ensure_hive_unloaded(hive_loaded = false) + if hive_loaded + Chef::Log.debug('Hive was loaded, we really should unload it') + unload_hive(path) + end + end + end +end + +module Registry + module_function # rubocop: disable Lint/UselessAccessModifier + + extend Windows::RegistryHelper +end diff --git a/vendor-cookbooks/windows/libraries/version.rb b/vendor-cookbooks/windows/libraries/version.rb new file mode 100644 index 0000000..48ff13f --- /dev/null +++ b/vendor-cookbooks/windows/libraries/version.rb @@ -0,0 +1,189 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: windows +# Library:: version +# +# Copyright:: 2011-2018, Chef Software, Inc. +# +# 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. +# + +if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require_relative 'wmi_helper' +end + +module Windows + class Version + # http://msdn.microsoft.com/en-us/library/ms724833(v=vs.85).aspx + + # Suite Masks + # Microsoft BackOffice components are installed. + VER_SUITE_BACKOFFICE = 0x00000004 unless defined?(VER_SUITE_BACKOFFICE) + # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed. + VER_SUITE_DATACENTER = 0x00000080 unless defined?(VER_SUITE_DATACENTER) + # Windows Server 2008 Enterprise, Windows Server 2003, Enterprise Edition, or Windows 2000 Advanced Server is installed. Refer to the Remarks section for more information about this bit flag. + VER_SUITE_ENTERPRISE = 0x00000002 unless defined?(VER_SUITE_ENTERPRISE) + # Windows XP Embedded is installed. + VER_SUITE_EMBEDDEDNT = 0x00000040 unless defined?(VER_SUITE_EMBEDDEDNT) + # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed. + VER_SUITE_PERSONAL = 0x00000200 unless defined?(VER_SUITE_PERSONAL) + # Remote Desktop is supported, but only one interactive session is supported. This value is set unless the system is running in application server mode. + VER_SUITE_SINGLEUSERTS = 0x00000100 unless defined?(VER_SUITE_SINGLEUSERTS) + # Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. Refer to the Remarks section for more information about this bit flag. + VER_SUITE_SMALLBUSINESS = 0x00000001 unless defined?(VER_SUITE_SMALLBUSINESS) + # Microsoft Small Business Server is installed with the restrictive client license in force. Refer to the Remarks section for more information about this bit flag. + VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020 unless defined?(VER_SUITE_SMALLBUSINESS_RESTRICTED) + # Terminal Services is installed. This value is always set. + # If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode. + VER_SUITE_TERMINAL = 0x00000010 unless defined?(VER_SUITE_TERMINAL) + # Windows Home Server is installed. + VER_SUITE_WH_SERVER = 0x00008000 unless defined?(VER_SUITE_WH_SERVER) + + # Product Type + # The system is a domain controller and the operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server. + VER_NT_DOMAIN_CONTROLLER = 0x0000002 unless defined?(VER_NT_DOMAIN_CONTROLLER) + # The operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server. + # Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER. + VER_NT_SERVER = 0x0000003 unless defined?(VER_NT_SERVER) + # The operating system is Windows 7, Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional. + VER_NT_WORKSTATION = 0x0000001 unless defined?(VER_NT_WORKSTATION) + + # http://msdn.microsoft.com/en-us/library/ms724358(v=vs.85).aspx + SKU = { + 0x00000006 => { ms_const: 'PRODUCT_BUSINESS', name: 'Business' }, + 0x00000010 => { ms_const: 'PRODUCT_BUSINESS_N', name: 'Business N' }, + 0x00000012 => { ms_const: 'PRODUCT_CLUSTER_SERVER', name: 'HPC Edition' }, + 0x00000008 => { ms_const: 'PRODUCT_DATACENTER_SERVER', name: 'Server Datacenter (full installation)' }, + 0x0000000C => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE', name: 'Server Datacenter (core installation)' }, + 0x00000027 => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE_V', name: 'Server Datacenter without Hyper-V (core installation)' }, + 0x00000025 => { ms_const: 'PRODUCT_DATACENTER_SERVER_V', name: 'Server Datacenter without Hyper-V (full installation)' }, + 0x00000004 => { ms_const: 'PRODUCT_ENTERPRISE', name: 'Enterprise' }, + 0x00000046 => { ms_const: 'PRODUCT_ENTERPRISE_E', name: 'Not supported' }, + 0x0000001B => { ms_const: 'PRODUCT_ENTERPRISE_N', name: 'Enterprise N' }, + 0x0000000A => { ms_const: 'PRODUCT_ENTERPRISE_SERVER', name: 'Server Enterprise (full installation)' }, + 0x0000000E => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE', name: 'Server Enterprise (core installation)' }, + 0x00000029 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE_V', name: 'Server Enterprise without Hyper-V (core installation)' }, + 0x0000000F => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_IA64', name: 'Server Enterprise for Itanium-based Systems' }, + 0x00000026 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_V', name: 'Server Enterprise without Hyper-V (full installation)' }, + 0x00000002 => { ms_const: 'PRODUCT_HOME_BASIC', name: 'Home Basic' }, + 0x00000043 => { ms_const: 'PRODUCT_HOME_BASIC_E', name: 'Not supported' }, + 0x00000005 => { ms_const: 'PRODUCT_HOME_BASIC_N', name: 'Home Basic N' }, + 0x00000003 => { ms_const: 'PRODUCT_HOME_PREMIUM', name: 'Home Premium' }, + 0x00000044 => { ms_const: 'PRODUCT_HOME_PREMIUM_E', name: 'Not supported' }, + 0x0000001A => { ms_const: 'PRODUCT_HOME_PREMIUM_N', name: 'Home Premium N' }, + 0x0000002A => { ms_const: 'PRODUCT_HYPERV', name: 'Microsoft Hyper-V Server' }, + 0x0000001E => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT', name: 'Windows Essential Business Server Management Server' }, + 0x00000020 => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING', name: 'Windows Essential Business Server Messaging Server' }, + 0x0000001F => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY', name: 'Windows Essential Business Server Security Server' }, + 0x00000030 => { ms_const: 'PRODUCT_PROFESSIONAL', name: 'Professional' }, + 0x00000045 => { ms_const: 'PRODUCT_PROFESSIONAL_E', name: 'Not supported' }, + 0x00000031 => { ms_const: 'PRODUCT_PROFESSIONAL_N', name: 'Professional N' }, + 0x00000067 => { ms_const: 'PRODUCT_PROFESSIONAL_WMC', name: 'Professional with Media Center' }, + 0x00000018 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS', name: 'Windows Server 2008 for Windows Essential Server Solutions' }, + 0x00000023 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS_V', name: 'Windows Server 2008 without Hyper-V for Windows Essential Server Solutions' }, + 0x00000021 => { ms_const: 'PRODUCT_SERVER_FOUNDATION', name: 'Server Foundation' }, + 0x00000022 => { ms_const: 'PRODUCT_HOME_PREMIUM_SERVER', name: 'Windows Home Server 2011' }, + 0x00000032 => { ms_const: 'PRODUCT_SB_SOLUTION_SERVER', name: 'Windows Small Business Server 2011 Essentials' }, + 0x00000013 => { ms_const: 'PRODUCT_HOME_SERVER', name: 'Windows Storage Server 2008 R2 Essentials' }, + 0x00000009 => { ms_const: 'PRODUCT_SMALLBUSINESS_SERVER', name: 'Windows Small Business Server' }, + 0x00000038 => { ms_const: 'PRODUCT_SOLUTION_EMBEDDEDSERVER', name: 'Windows MultiPoint Server' }, + 0x00000007 => { ms_const: 'PRODUCT_STANDARD_SERVER', name: 'Server Standard (full installation)' }, + 0x0000000D => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE', name: 'Server Standard (core installation)' }, + 0x00000028 => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE_V', name: 'Server Standard without Hyper-V (core installation)' }, + 0x00000024 => { ms_const: 'PRODUCT_STANDARD_SERVER_V', name: 'Server Standard without Hyper-V (full installation)' }, + 0x0000000B => { ms_const: 'PRODUCT_STARTER', name: 'Starter' }, + 0x00000042 => { ms_const: 'PRODUCT_STARTER_E', name: 'Not supported' }, + 0x0000002F => { ms_const: 'PRODUCT_STARTER_N', name: 'Starter N' }, + 0x00000017 => { ms_const: 'PRODUCT_STORAGE_ENTERPRISE_SERVER', name: 'Storage Server Enterprise' }, + 0x00000014 => { ms_const: 'PRODUCT_STORAGE_EXPRESS_SERVER', name: 'Storage Server Express' }, + 0x00000015 => { ms_const: 'PRODUCT_STORAGE_STANDARD_SERVER', name: 'Storage Server Standard' }, + 0x00000016 => { ms_const: 'PRODUCT_STORAGE_WORKGROUP_SERVER', name: 'Storage Server Workgroup' }, + 0x00000000 => { ms_const: 'PRODUCT_UNDEFINED', name: 'An unknown product' }, + 0x00000001 => { ms_const: 'PRODUCT_ULTIMATE', name: 'Ultimate' }, + 0x00000047 => { ms_const: 'PRODUCT_ULTIMATE_E', name: 'Not supported' }, + 0x0000001C => { ms_const: 'PRODUCT_ULTIMATE_N', name: 'Ultimate N' }, + 0x00000011 => { ms_const: 'PRODUCT_WEB_SERVER', name: 'Web Server (full installation)' }, + 0x0000001D => { ms_const: 'PRODUCT_WEB_SERVER_CORE', name: 'Web Server (core installation)' }, + }.freeze unless defined?(SKU) + + attr_reader :major_version, :minor_version, :build_number, :service_pack_major_version, :service_pack_minor_version + attr_reader :version, :product_type, :product_suite, :sku + + def initialize + unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ + raise NotImplementedError, 'only valid on Windows platform' + end + @version, @product_type, @product_suite, @sku, @service_pack_major_version, @service_pack_minor_version = get_os_info + @major_version, @minor_version, @build_number = version.split('.').map(&:to_i) + end + + WIN_VERSIONS = { + 'Windows 10' => { major: 10, minor: 0, callable: -> { @product_type != VER_NT_WORKSTATION } }, + 'Windows Server 2012 R2' => { major: 6, minor: 3, callable: -> { @product_type != VER_NT_WORKSTATION } }, + 'Windows 8' => { major: 6, minor: 2, callable: -> { @product_type == VER_NT_WORKSTATION } }, + 'Windows Server 2012' => { major: 6, minor: 2, callable: -> { @product_type != VER_NT_WORKSTATION } }, + 'Windows 7' => { major: 6, minor: 1, callable: -> { @product_type == VER_NT_WORKSTATION } }, + 'Windows Server 2008 R2' => { major: 6, minor: 1, callable: -> { @product_type != VER_NT_WORKSTATION } }, + 'Windows Server 2008' => { major: 6, minor: 0, callable: -> { @product_type != VER_NT_WORKSTATION } }, + 'Windows Vista' => { major: 6, minor: 0, callable: -> { @product_type == VER_NT_WORKSTATION } }, + 'Windows Home Server' => { major: 5, minor: 2, callable: -> { (@product_suite & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } }, + 'Windows XP' => { major: 5, minor: 1 }, + 'Windows 2000' => { major: 5, minor: 0 }, + }.freeze unless defined?(WIN_VERSIONS) + + marketing_names = [] + + # General Windows checks + WIN_VERSIONS.each do |k, v| + method_name = "#{k.gsub(/\s/, '_').downcase}?" + define_method(method_name) do + (@major_version == v[:major]) && + (@minor_version == v[:minor]) && + (v[:callable] ? v[:callable].call : true) + end + marketing_names << [k, method_name] + end + + define_method(:marketing_name) do + marketing_names.each do |mn| + break mn[0] if send(mn[1]) + end + end + + # Server Type checks + %w( core full datacenter ).each do |m| + define_method("server_#{m}?") do + if @sku + !(SKU[@sku][:name] =~ /#{m}/i).nil? + else + false + end + end + end + + private + + # query WMI Win32_OperatingSystem for required OS info + def get_os_info + cols = %w( Version ProductType OSProductSuite OperatingSystemSKU ServicePackMajorVersion ServicePackMinorVersion ) + os_info = execute_wmi_query('select * from Win32_OperatingSystem').each.next + cols.map do |c| + begin + wmi_object_property(os_info, c) + rescue # OperatingSystemSKU doesn't exist in all versions of Windows + nil + end + end + end + end +end diff --git a/vendor-cookbooks/windows/libraries/version_helper.rb b/vendor-cookbooks/windows/libraries/version_helper.rb new file mode 100644 index 0000000..fcb0aa7 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/version_helper.rb @@ -0,0 +1,93 @@ +# +# Cookbook:: windows +# Library:: version_helper +# Author:: Baptiste Courtois () +# +# Copyright:: 2015-2017, 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. +# +module Windows + # Module based on windows ohai kernel.cs_info providing version helpers + module VersionHelper + # Module referencing CORE SKU contants from product type + # see. https://msdn.microsoft.com/windows/desktop/ms724358#PRODUCT_DATACENTER_SERVER_CORE + # n.b. Prefix - PRODUCT_ - and suffix - _CORE- have been removed + module CoreSKU + # Server Datacenter Core + DATACENTER_SERVER = 0x0C unless constants.include?(:DATACENTER_SERVER) + # Server Datacenter without Hyper-V Core + DATACENTER_SERVER_V = 0x27 unless constants.include?(:DATACENTER_SERVER_V) + # Server Enterprise Core + ENTERPRISE_SERVER = 0x0E unless constants.include?(:ENTERPRISE_SERVER) + # Server Enterprise without Hyper-V Core + ENTERPRISE_SERVER_V = 0x29 unless constants.include?(:ENTERPRISE_SERVER_V) + # Server Standard Core + STANDARD_SERVER = 0x0D unless constants.include?(:STANDARD_SERVER) + # Server Standard without Hyper-V Core + STANDARD_SERVER_V = 0x28 unless constants.include?(:STANDARD_SERVER_V) + # Small Business Server Premium Core + PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = 0x3F unless constants.include?(:PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE) + # Server Solutions Premium Core + STANDARD_SERVER_SOLUTIONS = 0x35 unless constants.include?(:STANDARD_SERVER_SOLUTIONS) + # Storage Server Enterprise Core + STORAGE_ENTERPRISE_SERVER = 0x2E unless constants.include?(:STORAGE_ENTERPRISE_SERVER) + # Storage Server Express Core + STORAGE_EXPRESS_SERVER = 0x2B unless constants.include?(:STORAGE_EXPRESS_SERVER) + # Storage Server Standard Core + STORAGE_STANDARD_SERVER = 0x2C unless constants.include?(:STORAGE_STANDARD_SERVER) + # Storage Server Workgroup Core + STORAGE_WORKGROUP_SERVER = 0x2D unless constants.include?(:STORAGE_WORKGROUP_SERVER) + # Web Server Core + WEB_SERVER = 0x1D unless constants.include?(:WEB_SERVER) + end + + # Module referencing product type contants + # see. https://msdn.microsoft.com/windows/desktop/ms724833#VER_NT_SERVER + # n.b. Prefix - VER_NT_ - has been removed + module ProductType + WORKSTATION = 0x1 unless constants.include?(:WORKSTATION) + DOMAIN_CONTROLLER = 0x2 unless constants.include?(:DOMAIN_CONTROLLER) + SERVER = 0x3 unless constants.include?(:SERVER) + end + + # Determines whether current node is running a windows Core version + def self.core_version?(node) + validate_platform node + + CoreSKU.constants.any? { |c| CoreSKU.const_get(c) == node['kernel']['os_info']['operating_system_sku'] } + end + + # Determines whether current node is a workstation version + def self.workstation_version?(node) + validate_platform node + node['kernel']['os_info']['product_type'] == ProductType::WORKSTATION + end + + # Determines whether current node is a server version + def self.server_version?(node) + !workstation_version?(node) + end + + # Determines NT version of the current node + def self.nt_version(node) + validate_platform node + + node['platform_version'].to_f + end + + def self.validate_platform(node) + raise 'Windows helper are only supported on windows platform!' unless node['platform'] == 'windows' + end + end +end diff --git a/vendor-cookbooks/windows/libraries/windows_helper.rb b/vendor-cookbooks/windows/libraries/windows_helper.rb new file mode 100644 index 0000000..97ec431 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/windows_helper.rb @@ -0,0 +1,165 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: windows +# Library:: windows_helper +# +# Copyright:: 2011-2018, Chef Software, Inc. +# +# 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. + +require 'uri' +require 'chef/exceptions' +require 'openssl' +require 'chef/mixin/powershell_out' +require 'chef/mixin/windows_env_helper' +require 'chef/util/path_helper' + +module Windows + module Helper + AUTO_RUN_KEY = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'.freeze unless defined?(AUTO_RUN_KEY) + ENV_KEY = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'.freeze unless defined?(ENV_KEY) + include Chef::Mixin::WindowsEnvHelper + + # returns windows friendly version of the provided path, + # ensures backslashes are used everywhere + def win_friendly_path(path) + Chef::Log.warn('The win_friendly_path helper has been deprecated and will be removed from the next major release of the windows cookbook. Please update any cookbooks using this helper to instead require `chef/util/path_helper` and then use `Chef::Util::PathHelper.cleanpath`.') + path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path + end + + # account for Window's wacky File System Redirector + # http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx + # especially important for 32-bit processes (like Ruby) on a + # 64-bit instance of Windows. + def locate_sysnative_cmd(cmd) + if ::File.exist?("#{ENV['WINDIR']}\\sysnative\\#{cmd}") + "#{ENV['WINDIR']}\\sysnative\\#{cmd}" + elsif ::File.exist?("#{ENV['WINDIR']}\\system32\\#{cmd}") + "#{ENV['WINDIR']}\\system32\\#{cmd}" + else + cmd + end + end + + # singleton instance of the Windows Version checker + def win_version + @win_version ||= Windows::Version.new + end + + # Helper function to properly parse a URI + def as_uri(source) + URI.parse(source) + rescue URI::InvalidURIError + Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters") + URI.parse(URI.escape(source)) + end + + # if a file is local it returns a windows friendly path version + # if a file is remote it caches it locally + def cached_file(source, checksum = nil, windows_path = true) + @installer_file_path ||= begin + + if source =~ %r{^(file|ftp|http|https):\/\/} + uri = as_uri(source) + cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(::URI.unescape(uri.path))}" + Chef::Log.debug("Caching a copy of file #{source} at #{cache_file_path}") + remote_file cache_file_path do + source source + backup false + checksum checksum unless checksum.nil? + end.run_action(:create) + else + cache_file_path = source + end + + windows_path ? Chef::Util::PathHelper.cleanpath(cache_file_path) : cache_file_path + end + end + + # Expands the environment variables + def expand_env_vars(path) + # The windows Env provider does not correctly expand variables in + # the PATH environment variable. Ruby expects these to be expanded. + # Using Chef::Mixin::WindowsEnvHelper + expand_path(path) + end + + def is_package_installed?(package_name) # rubocop:disable Naming/PredicateName + installed_packages.include?(package_name) + end + + def installed_packages + @installed_packages || begin + installed_packages = {} + # Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall + installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE)) # rescue nil + # 64-bit registry view + # Computer\HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall + installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100))) # rescue nil + # 32-bit registry view + # Computer\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall + installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0200))) # rescue nil + # Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall + installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_CURRENT_USER)) # rescue nil + installed_packages + end + end + + # Returns an array + def to_array(var) + var = var.is_a?(Array) ? var : [var] + var.reject(&:nil?) + end + + private + + def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ) + uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall' + packages = {} + begin + ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg| + reg.each_key do |key, _wtime| + begin + k = reg.open(key, desired) + display_name = begin + k['DisplayName'] + rescue + nil + end + version = begin + k['DisplayVersion'] + rescue + 'NO VERSION' + end + uninstall_string = begin + k['UninstallString'] + rescue + nil + end + if display_name + packages[display_name] = { name: display_name, + version: version, + uninstall_string: uninstall_string } + end + rescue ::Win32::Registry::Error + end + end + end + rescue ::Win32::Registry::Error + end + packages + end + end +end + +Chef::Recipe.send(:include, Windows::Helper) diff --git a/vendor-cookbooks/windows/libraries/windows_privileged.rb b/vendor-cookbooks/windows/libraries/windows_privileged.rb new file mode 100644 index 0000000..68d96c3 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/windows_privileged.rb @@ -0,0 +1,103 @@ +# +# Author:: Doug MacEachern +# Author:: Paul Morton () +# Cookbook:: windows +# Library:: windows_privileged +# +# Copyright:: 2010-2017, VMware, Inc. +# Copyright:: 2011-2017, Business Intelligence Associates, Inc +# +# 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. +# + +# helpers for Windows API calls that require privilege adjustments +class Chef + class WindowsPrivileged + # File -> Load Hive... in regedit.exe + def reg_load_key(name, file) + load_deps + + run(SE_BACKUP_NAME, SE_RESTORE_NAME) do + rc = RegLoadKey(HKEY_USERS, name.to_s, file) + if rc == ERROR_SUCCESS + return true + elsif rc == ERROR_SHARING_VIOLATION + return false + else + raise get_last_error(rc) + end + end + end + + # File -> Unload Hive... in regedit.exe + def reg_unload_key(name) + load_deps + + run(SE_BACKUP_NAME, SE_RESTORE_NAME) do + rc = RegUnLoadKey(HKEY_USERS, name.to_s) + raise get_last_error(rc) if rc != ERROR_SUCCESS + end + end + + def run(*privileges) + load_deps + + token = [0].pack('L') + + unless OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, token) + raise get_last_error + end + token = token.unpack1('L') + + privileges.each do |name| + unless adjust_privilege(token, name, SE_PRIVILEGE_ENABLED) + raise get_last_error + end + end + + begin + yield + ensure # disable privs + privileges.each do |name| + adjust_privilege(token, name, 0) + end + end + end + + def adjust_privilege(token, priv, attr = 0) + load_deps + + luid = [0, 0].pack('Ll') + if LookupPrivilegeValue(nil, priv, luid) + new_state = [1, luid.unpack('Ll'), attr].flatten.pack('LLlL') + AdjustTokenPrivileges(token, 0, new_state, new_state.size, 0, 0) + end + end + + private + + def load_deps + if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require 'windows/error' + require 'windows/registry' + require 'windows/process' + require 'windows/security' + + include Windows::Error + include Windows::Registry + include Windows::Process + include Windows::Security + end + end + end +end diff --git a/vendor-cookbooks/windows/libraries/wmi_helper.rb b/vendor-cookbooks/windows/libraries/wmi_helper.rb new file mode 100644 index 0000000..2acdc38 --- /dev/null +++ b/vendor-cookbooks/windows/libraries/wmi_helper.rb @@ -0,0 +1,34 @@ +# +# Author:: Adam Edwards () +# Cookbook:: windows +# Library:: wmi_helper +# +# Copyright:: 2014-2018, Chef Software, Inc. +# +# 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. +# + +if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require 'win32ole' + + def execute_wmi_query(wmi_query) + wmi = ::WIN32OLE.connect('winmgmts://') + result = wmi.ExecQuery(wmi_query) + return nil unless result.each.count > 0 + result + end + + def wmi_object_property(wmi_object, wmi_property) + wmi_object.send(wmi_property) + end +end diff --git a/vendor-cookbooks/windows/metadata.json b/vendor-cookbooks/windows/metadata.json new file mode 100644 index 0000000..4f17644 --- /dev/null +++ b/vendor-cookbooks/windows/metadata.json @@ -0,0 +1 @@ +{"name":"windows","version":"7.0.0","description":"Provides a set of useful Windows-specific primitives.","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/windows","issues_url":"https://github.com/chef-cookbooks/windows/issues","chef_version":[[">= 14.7"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/windows/metadata.rb b/vendor-cookbooks/windows/metadata.rb new file mode 100644 index 0000000..7841d55 --- /dev/null +++ b/vendor-cookbooks/windows/metadata.rb @@ -0,0 +1,10 @@ +name 'windows' +maintainer 'Chef Software, Inc.' +maintainer_email 'cookbooks@chef.io' +license 'Apache-2.0' +description 'Provides a set of useful Windows-specific primitives.' +version '7.0.0' +supports 'windows' +source_url 'https://github.com/chef-cookbooks/windows' +issues_url 'https://github.com/chef-cookbooks/windows/issues' +chef_version '>= 14.7' diff --git a/vendor-cookbooks/windows/providers/dns.rb b/vendor-cookbooks/windows/providers/dns.rb new file mode 100644 index 0000000..fae9858 --- /dev/null +++ b/vendor-cookbooks/windows/providers/dns.rb @@ -0,0 +1,148 @@ +# +# Author:: Richard Lavey (richard.lavey@calastone.com) +# Cookbook:: windows +# Provider:: dns +# +# Copyright:: 2015, Calastone Ltd. +# +# 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. +# + +# See this for info on DNSCMD +# https://technet.microsoft.com/en-gb/library/cc772069.aspx#BKMK_10 + +include Windows::Helper + +action :create do + if @current_resource.exists + needs_change = (@new_resource.record_type != @current_resource.record_type) || + (@new_resource.ttl > 0 && @new_resource.ttl != @current_resource.ttl) || + (@new_resource.target.is_a?(String) && @new_resource.target != @current_resource.target) || + (@new_resource.target.is_a?(Array) && !(@new_resource.target - @current_resource.target).empty?) + + if needs_change + converge_by("Changing #{@new_resource.host_name}") do + update_dns + end + else + Chef::Log.debug("#{@new_resource.host_name} already exists - nothing to do") + end + else + converge_by("Creating #{@new_resource.host_name}") do + update_dns + end + end +end + +action :delete do + if @current_resource.exists + converge_by("Deleting #{@current_resource.host_name}") do + execute_command! 'recorddelete', "#{@current_resource.record_type} /f" + end + else + Chef::Log.debug("#{@new_resource.host_name} does not exist - nothing to do") + end +end + +def load_current_resource + # validate the new resource params : A records should be an array + if @new_resource.record_type == 'A' && @new_resource.target.is_a?(String) + raise 'target property must be an array for record_type A' + end + + @current_resource = Chef::Resource::WindowsDns.new(@new_resource.name) + @current_resource.host_name(@new_resource.host_name) + @current_resource.dns_server(@new_resource.dns_server) + + parts = @current_resource.host_name.scan(/(\w+)\.(.*)/) + @host = parts[0][0] + @domain = parts[0][1] + + fetch_attributes +end + +private + +def fetch_attributes + @command = locate_sysnative_cmd('dnscmd.exe') + cmd = shell_out("#{@command} #{@current_resource.dns_server} /enumrecords #{@domain} #{@host}") + Chef::Log.debug "dnscmd reports: #{cmd.stdout}" + + # extract values from returned text + if cmd.stdout.include?('DNS_ERROR_NAME_DOES_NOT_EXIST') + @current_resource.exists = false + @current_resource.target([]) + elsif cmd.exitstatus == 0 + @current_resource.exists = true + + m = cmd.stdout.scan(/(\d+)\s(A)\s+(\d+\.\d+\.\d+\.\d+)/) + if m.empty? + m = cmd.stdout.scan(/(\d+)\s(CNAME)\s+((?:\w+\.)+)/) + if m.empty? + @current_resource.exists = false + @current_resource.target([]) + else + # We have a cname record + @current_resource.record_type('CNAME') + @current_resource.ttl(m[0][0].to_i) + @current_resource.target(m[0][2].chomp('.')) + end + else + # we have A entries + @current_resource.record_type('A') + @current_resource.ttl(m[0][0].to_i) + addresses = [] + m.each do |match| + addresses.push(match[2]) + end + @current_resource.target(addresses) + end + else + raise "dnscmd returned error #{cmd.exitstatus} : #{cmd.stderr} #{cmd.stdout}" + end +end + +def update_dns + ttl = @new_resource.ttl if @new_resource.ttl > 0 + + if @current_resource.record_type != @new_resource.record_type + # delete current record(s) as we're changing the type + execute_command! 'recorddelete', "#{@current_resource.record_type} /f" + end + + if @new_resource.record_type == 'A' + # delete existing records that are no longer defined + (@current_resource.target - @new_resource.target).each do |address| + Chef::Log.info "Deleting #{address}" + execute_command! 'recorddelete', "A #{address} /f" + end + + # add new records that don't exist + # if ttl has changed then update all records + addresses = if @current_resource.ttl == @new_resource.ttl + (@new_resource.target - @current_resource.target) + else + @new_resource.target + end + addresses.each do |address| + Chef::Log.info "Adding/Changing #{address}" + execute_command! 'recordadd', "#{ttl} A #{address}" + end + else + execute_command! 'recordadd', "#{ttl} CNAME #{@new_resource.target}" + end +end + +def execute_command!(mode, options) + shell_out!("#{@command} #{@current_resource.dns_server} /#{mode} #{@domain} #{@host} #{options}") +end diff --git a/vendor-cookbooks/windows/recipes/default.rb b/vendor-cookbooks/windows/recipes/default.rb new file mode 100644 index 0000000..73845f6 --- /dev/null +++ b/vendor-cookbooks/windows/recipes/default.rb @@ -0,0 +1,21 @@ +# +# Author:: Seth Chisamore () +# Cookbook:: windows +# Recipe:: default +# +# Copyright:: 2011-2018, Chef Software, Inc. +# +# 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. +# + +Chef::Log.warn('The windows::default recipe has been deprecated. The gems previously installed in this recipe ship in the Chef MSI.') diff --git a/vendor-cookbooks/windows/resources/certificate_binding.rb b/vendor-cookbooks/windows/resources/certificate_binding.rb new file mode 100644 index 0000000..5d908ec --- /dev/null +++ b/vendor-cookbooks/windows/resources/certificate_binding.rb @@ -0,0 +1,134 @@ +# +# Author:: Richard Lavey (richard.lavey@calastone.com) +# Cookbook:: windows +# Resource:: certificate_binding +# +# Copyright:: 2015-2017, Calastone Ltd. +# Copyright:: 2018, Chef Software, Inc. +# +# 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. +# + +include Windows::Helper + +property :cert_name, String, name_property: true +property :name_kind, Symbol, equal_to: [:hash, :subject], default: :subject +property :address, String, default: '0.0.0.0' +property :port, Integer, default: 443 +property :app_id, String, default: '{4dc3e181-e14b-4a21-b022-59fc669b0914}' +property :store_name, String, default: 'MY', equal_to: ['TRUSTEDPUBLISHER', 'CLIENTAUTHISSUER', 'REMOTE DESKTOP', 'ROOT', 'TRUSTEDDEVICES', 'WEBHOSTING', 'CA', 'AUTHROOT', 'TRUSTEDPEOPLE', 'MY', 'SMARTCARDROOT', 'TRUST'] +property :exists, [true, false] + +load_current_value do |desired| + mode = desired.address.match(/(\d+\.){3}\d+|\[.+\]/).nil? ? 'hostnameport' : 'ipport' + cmd = shell_out("#{locate_sysnative_cmd('netsh.exe')} http show sslcert #{mode}=#{desired.address}:#{desired.port}") + Chef::Log.debug "netsh reports: #{cmd.stdout}" + + address desired.address + port desired.port + store_name desired.store_name + app_id desired.app_id + + if cmd.exitstatus == 0 + m = cmd.stdout.scan(/Certificate Hash\s+:\s?([A-Fa-f0-9]{40})/) + raise "Failed to extract hash from command output #{cmd.stdout}" if m.empty? + cert_name m[0][0] + name_kind :hash + exists true + else + exists false + end +end + +action :create do + hash = new_resource.name_kind == :subject ? hash_from_subject : new_resource.cert_name + + if current_resource.exists + needs_change = (hash.casecmp(current_resource.cert_name) != 0) + + if needs_change + converge_by("Changing #{current_resource.address}:#{current_resource.port}") do + delete_binding + add_binding hash + end + else + Chef::Log.debug("#{new_resource.address}:#{new_resource.port} already bound to #{hash} - nothing to do") + end + else + converge_by("Binding #{new_resource.address}:#{new_resource.port}") do + add_binding hash + end + end +end + +action :delete do + if current_resource.exists + converge_by("Deleting #{current_resource.address}:#{current_resource.port}") do + delete_binding + end + else + Chef::Log.debug("#{current_resource.address}:#{current_resource.port} not bound - nothing to do") + end +end + +action_class do + def netsh_command + locate_sysnative_cmd('netsh.exe') + end + + def add_binding(hash) + cmd = "#{netsh_command} http add sslcert" + mode = address_mode(current_resource.address) + cmd << " #{mode}=#{current_resource.address}:#{current_resource.port}" + cmd << " certhash=#{hash}" + cmd << " appid=#{current_resource.app_id}" + cmd << " certstorename=#{current_resource.store_name}" + check_hash hash + + shell_out!(cmd) + end + + def delete_binding + mode = address_mode(current_resource.address) + shell_out!("#{netsh_command} http delete sslcert #{mode}=#{current_resource.address}:#{current_resource.port}") + end + + def check_hash(hash) + p = powershell_out!("Test-Path \"cert:\\LocalMachine\\#{current_resource.store_name}\\#{hash}\"") + + unless p.stderr.empty? && p.stdout =~ /True/i + raise "A Cert with hash of #{hash} doesn't exist in keystore LocalMachine\\#{current_resource.store_name}" + end + nil + end + + def hash_from_subject + # escape wildcard subject name (*.acme.com) + subject = new_resource.cert_name.sub(/\*/, '`*') + ps_script = "& { gci cert:\\localmachine\\#{new_resource.store_name} | where { $_.subject -like '*#{subject}*' } | select -first 1 -expandproperty Thumbprint }" + + Chef::Log.debug "Running PS script #{ps_script}" + p = powershell_out!(ps_script) + + raise "#{ps_script} failed with #{p.stderr}" if !p.stderr.nil? && !p.stderr.empty? + raise "Couldn't find thumbprint for subject #{new_resource.cert_name}" if p.stdout.nil? || p.stdout.empty? + + # seem to get a UTF-8 string with BOM returned sometimes! Strip any such BOM + hash = p.stdout.strip + hash[0].ord == 239 ? hash.force_encoding('UTF-8').delete!("\xEF\xBB\xBF".force_encoding('UTF-8')) : hash + end + + def address_mode(address) + address.match(/(\d+\.){3}\d+|\[.+\]/).nil? ? 'hostnameport' : 'ipport' + end +end diff --git a/vendor-cookbooks/windows/resources/dns.rb b/vendor-cookbooks/windows/resources/dns.rb new file mode 100644 index 0000000..30149d4 --- /dev/null +++ b/vendor-cookbooks/windows/resources/dns.rb @@ -0,0 +1,29 @@ +# +# Author:: Richard Lavey (richard.lavey@calastone.com) +# Cookbook:: windows +# Resource:: dns +# +# Copyright:: 2015, Calastone Ltd. +# +# 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. +# + +default_action :create + +attribute :host_name, kind_of: String, required: true +attribute :record_type, kind_of: String, default: 'A', regex: /^(?:A|CNAME)$/ +attribute :dns_server, kind_of: String, default: '.' +attribute :target, kind_of: [Array, String], required: true +attribute :ttl, kind_of: Integer, required: false, default: 0 + +attr_accessor :exists diff --git a/vendor-cookbooks/windows/resources/http_acl.rb b/vendor-cookbooks/windows/resources/http_acl.rb new file mode 100644 index 0000000..b78f126 --- /dev/null +++ b/vendor-cookbooks/windows/resources/http_acl.rb @@ -0,0 +1,109 @@ +# +# Author:: Richard Lavey (richard.lavey@calastone.com) +# Cookbook:: windows +# Resource:: http_acl +# +# Copyright:: 2015-2017, Calastone Ltd. +# +# 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. +# + +include Windows::Helper + +property :url, String, name_property: true +property :user, String +property :sddl, String +property :exists, [true, false] + +# See https://msdn.microsoft.com/en-us/library/windows/desktop/cc307236%28v=vs.85%29.aspx for netsh info + +load_current_value do |desired| + cmd_out = shell_out!("#{locate_sysnative_cmd('netsh.exe')} http show urlacl url=#{desired.url}").stdout + Chef::Log.debug "netsh reports: #{cmd_out}" + + if cmd_out.include? desired.url + exists true + url desired.url + # Checks first for sddl, because it generates user(s) + sddl_match = cmd_out.match(/SDDL:\s*(?\S+)/) + if sddl_match + sddl sddl_match['sddl'] + else + # if no sddl, tries to find a single user + user_match = cmd_out.match(/User:\s*(?.+)/) + user user_match['user'] + end + else + exists false + end +end + +action :create do + raise '`user` xor `sddl` can\'t be used together' if new_resource.user && new_resource.sddl + raise 'When provided user property can\'t be empty' if new_resource.user && new_resource.user.empty? + raise 'When provided sddl property can\'t be empty' if new_resource.sddl && new_resource.sddl.empty? + + if current_resource.exists + sddl_changed = ( + new_resource.sddl && + current_resource.sddl && + current_resource.sddl.casecmp(new_resource.sddl) != 0 + ) + user_changed = ( + new_resource.user && + current_resource.user && + current_resource.user.casecmp(new_resource.user) != 0 + ) + + if sddl_changed || user_changed + converge_by("Changing #{new_resource.url}") do + delete_acl + apply_acl + end + else + Chef::Log.debug("#{new_resource.url} already set - nothing to do") + end + else + converge_by("Setting #{new_resource.url}") do + apply_acl + end + end +end + +action :delete do + if current_resource.exists + converge_by("Deleting #{new_resource.url}") do + delete_acl + end + else + Chef::Log.debug("#{new_resource.url} does not exist - nothing to do") + end +end + +action_class do + def netsh_command + locate_sysnative_cmd('netsh.exe') + end + + def apply_acl + if current_resource.sddl + shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} sddl=\"#{new_resource.sddl}\"") + else + shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} user=\"#{new_resource.user}\"") + end + end + + def delete_acl + shell_out!("#{netsh_command} http delete urlacl url=#{new_resource.url}") + end +end diff --git a/vendor-cookbooks/windows/resources/schannel.rb b/vendor-cookbooks/windows/resources/schannel.rb new file mode 100644 index 0000000..d608601 --- /dev/null +++ b/vendor-cookbooks/windows/resources/schannel.rb @@ -0,0 +1,39 @@ +# +# Author:: Jason Field (jason.field@calastone.com) +# Cookbook:: windows +# Resource:: schannel +# +# Copyright:: 2019, Calastone Ltd. +# +# 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. +# + +property :use_strong_crypto, [true, false], default: true + +action :configure do + registry_key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319' do + values [{ + name: 'SchUseStrongCrypto', + type: :dword, + data: new_resource.use_strong_crypto ? 1 : 0, + }] + end + + registry_key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\.NETFramework\\v4.0.30319' do + values [{ + name: 'SchUseStrongCrypto', + type: :dword, + data: new_resource.use_strong_crypto ? 1 : 0, + }] + end +end diff --git a/vendor-cookbooks/windows/resources/user_privilege.rb b/vendor-cookbooks/windows/resources/user_privilege.rb new file mode 100644 index 0000000..2264ded --- /dev/null +++ b/vendor-cookbooks/windows/resources/user_privilege.rb @@ -0,0 +1,40 @@ +# +# Author:: Jared Kauppila () +# Cookbook:: windows +# Resource:: user_privilege +# + +property :principal, String, name_property: true +property :privilege, [Array, String], required: true, coerce: proc { |v| [*v].sort } + +action :add do + ([*new_resource.privilege] - [*current_resource.privilege]).each do |user_right| + converge_by("adding user privilege #{user_right}") do + Chef::ReservedNames::Win32::Security.add_account_right(new_resource.principal, user_right) + end + end +end + +action :remove do + if Gem::Version.new(Chef::VERSION) < Gem::Version.new('14.4.10') + Chef::Log.warn('Chef 14.4.10 is required to use windows_privilege remove action') + else + curr_res_privilege = current_resource.privilege + new_res_privilege = new_resource.privilege + missing_res_privileges = (new_res_privilege - curr_res_privilege) + + if missing_res_privileges + Chef::Log.info("Privilege: #{missing_res_privileges.join(', ')} not present. Unable to delete") + end + + (new_res_privilege - missing_res_privileges).each do |user_right| + converge_by("removing user privilege #{user_right}") do + Chef::ReservedNames::Win32::Security.remove_account_right(new_resource.principal, user_right) + end + end + end +end + +load_current_value do |desired| + privilege Chef::ReservedNames::Win32::Security.get_account_right(desired.principal) +end diff --git a/vendor-cookbooks/windows/resources/zipfile.rb b/vendor-cookbooks/windows/resources/zipfile.rb new file mode 100644 index 0000000..f182b5a --- /dev/null +++ b/vendor-cookbooks/windows/resources/zipfile.rb @@ -0,0 +1,128 @@ +# +# Author:: Doug MacEachern () +# Author:: Seth Chisamore () +# Author:: Wade Peacock () +# Cookbook:: windows +# Resource:: zipfile +# +# Copyright:: 2010-2017, VMware, Inc. +# Copyright:: 2011-2018, Chef Software, Inc. +# +# 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. +# + +require 'chef/util/path_helper' + +property :path, String, name_property: true +property :source, String +property :overwrite, [true, false], default: false +property :checksum, String + +action :unzip do + ensure_rubyzip_gem_installed + Chef::Log.debug("unzip #{new_resource.source} => #{new_resource.path} (overwrite=#{new_resource.overwrite})") + + cache_file_path = if new_resource.source =~ %r{^(file|ftp|http|https):\/\/} # http://rubular.com/r/DGoIWjLfGI + uri = as_uri(new_resource.source) + local_cache_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(::URI.unescape(uri.path))}" + Chef::Log.debug("Caching a copy of file #{new_resource.source} at #{cache_file_path}") + + remote_file local_cache_path do + source new_resource.source + backup false + checksum new_resource.checksum unless new_resource.checksum.nil? + end + + local_cache_path + else + new_resource.source + end + + cache_file_path = Chef::Util::PathHelper.cleanpath(cache_file_path) + + converge_by("unzip #{new_resource.source}") do + ruby_block 'Unzipping' do + block do + Zip::File.open(cache_file_path) do |zip| + zip.each do |entry| + path = ::File.join(new_resource.path, entry.name) + FileUtils.mkdir_p(::File.dirname(path)) + if new_resource.overwrite && ::File.exist?(path) && !::File.directory?(path) + FileUtils.rm(path) + end + zip.extract(entry, path) unless ::File.exist?(path) + end + end + end + action :run + end + end +end + +action :zip do + ensure_rubyzip_gem_installed + # sanitize paths for windows. + new_resource.source.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) + new_resource.path.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) + Chef::Log.debug("zip #{new_resource.source} => #{new_resource.path} (overwrite=#{new_resource.overwrite})") + + if new_resource.overwrite == false && ::File.exist?(new_resource.path) + Chef::Log.info("file #{new_resource.path} already exists and overwrite is set to false, exiting") + else + # delete the archive if it already exists, because we are recreating it. + if ::File.exist?(new_resource.path) + converge_by("delete existing file at #{new_resource.path}") do + ::File.unlink(new_resource.path) + end + end + + # only supporting compression of a single directory (recursively). + if ::File.directory?(new_resource.source) + converge_by("zipping #{new_resource.source} to #{new_resource.path}") do + z = Zip::File.new(new_resource.path, true) + unless new_resource.source =~ /::File::ALT_SEPARATOR$/ + new_resource.source << ::File::ALT_SEPARATOR + end + Find.find(new_resource.source) do |f| + f.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) + # don't add root directory to the zipfile. + next if f == new_resource.source + # strip the root directory from the filename before adding it to the zipfile. + zip_fname = f.sub(new_resource.source, '') + Chef::Log.debug("adding #{zip_fname} to archive, sourcefile is: #{f}") + z.add(zip_fname, f) + end + z.close + end + else + Chef::Log.info("Single directory must be specified for compression, and #{new_resource.source} does not meet that criteria.") + end + end +end + +action_class do + include Windows::Helper + require 'find' + + def ensure_rubyzip_gem_installed + require 'zip' + Chef::Log.warn('The windows_zipfile resource has been deprecated as Chef Infra Client 15.0 shipped with a new archive_file resource, which natively handles multiple archive formats. Please update any cookbooks using this resource to instead use the `archive_file` resource: https://docs.chef.io/resource_archive_file.html') + rescue LoadError + Chef::Log.info("Missing gem 'rubyzip'...installing now.") + chef_gem 'rubyzip' do + action :install + compile_time true + end + require 'zip' + end +end From c091be0df8e1815f567cc62473534505ea7226bb Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Thu, 16 Apr 2020 14:27:16 -0700 Subject: [PATCH 2/9] Initial ros2 windows cookbook for development and binaries --- .chef-repo.txt | 6 + .chef/solo.rb | 6 + Berksfile | 7 + LICENSE | 202 +++++++++++++++ chefignore | 107 ++++++++ cookbooks/ros2_windows/README.md | 3 + cookbooks/ros2_windows/attributes/default.rb | 32 +++ .../ros2_windows/attributes/rti_connext.rb | 18 ++ cookbooks/ros2_windows/files/qt-installer.qs | 237 ++++++++++++++++++ .../ros2_windows/files/qt-maintenance.qs | 223 ++++++++++++++++ cookbooks/ros2_windows/metadata.rb | 22 ++ .../recipes/chocolatey_installs.rb | 48 ++++ cookbooks/ros2_windows/recipes/opencv.rb | 18 ++ cookbooks/ros2_windows/recipes/opensplice.rb | 11 + cookbooks/ros2_windows/recipes/openssl.rb | 17 ++ .../ros2_windows/recipes/pip_installs.rb | 51 ++++ cookbooks/ros2_windows/recipes/python.rb | 4 + cookbooks/ros2_windows/recipes/qt5.rb | 48 ++++ cookbooks/ros2_windows/recipes/ros2.rb | 47 ++++ .../ros2_windows/recipes/ros2_binaries.rb | 7 + cookbooks/ros2_windows/recipes/rti_connext.rb | 130 ++++++++++ .../ros2_windows/recipes/visual_studio.rb | 54 ++++ cookbooks/ros2_windows/recipes/xmllint.rb | 24 ++ roles/ros2-binaries.json | 19 ++ roles/ros2-debug-binaries.json | 14 ++ roles/ros2-development.json | 20 ++ 26 files changed, 1375 insertions(+) create mode 100644 .chef-repo.txt create mode 100644 .chef/solo.rb create mode 100644 Berksfile create mode 100644 LICENSE create mode 100644 chefignore create mode 100644 cookbooks/ros2_windows/README.md create mode 100644 cookbooks/ros2_windows/attributes/default.rb create mode 100644 cookbooks/ros2_windows/attributes/rti_connext.rb create mode 100644 cookbooks/ros2_windows/files/qt-installer.qs create mode 100644 cookbooks/ros2_windows/files/qt-maintenance.qs create mode 100644 cookbooks/ros2_windows/metadata.rb create mode 100644 cookbooks/ros2_windows/recipes/chocolatey_installs.rb create mode 100644 cookbooks/ros2_windows/recipes/opencv.rb create mode 100644 cookbooks/ros2_windows/recipes/opensplice.rb create mode 100644 cookbooks/ros2_windows/recipes/openssl.rb create mode 100644 cookbooks/ros2_windows/recipes/pip_installs.rb create mode 100644 cookbooks/ros2_windows/recipes/python.rb create mode 100644 cookbooks/ros2_windows/recipes/qt5.rb create mode 100644 cookbooks/ros2_windows/recipes/ros2.rb create mode 100644 cookbooks/ros2_windows/recipes/ros2_binaries.rb create mode 100644 cookbooks/ros2_windows/recipes/rti_connext.rb create mode 100644 cookbooks/ros2_windows/recipes/visual_studio.rb create mode 100644 cookbooks/ros2_windows/recipes/xmllint.rb create mode 100644 roles/ros2-binaries.json create mode 100644 roles/ros2-debug-binaries.json create mode 100644 roles/ros2-development.json diff --git a/.chef-repo.txt b/.chef-repo.txt new file mode 100644 index 0000000..7ee3446 --- /dev/null +++ b/.chef-repo.txt @@ -0,0 +1,6 @@ +.chef-repo.txt +============== + +This file gives ChefDK's generators a hint that you are using a Chef Repo and +this is the root directory of your Chef Repo. ChefDK's generators use this to +generate code that is designed to work with the Chef Repo workflow. diff --git a/.chef/solo.rb b/.chef/solo.rb new file mode 100644 index 0000000..e115936 --- /dev/null +++ b/.chef/solo.rb @@ -0,0 +1,6 @@ +a_repo_dir = File.expand_path("../..", __FILE__) +cookbook_path [File.join(a_repo_dir, "vendor-cookbooks"), File.join(a_repo_dir, "cookbooks")] +data_bag_path File.join(a_repo_dir, "data_bags") +role_path File.join(a_repo_dir, "roles") +environment_path File.join(a_repo_dir, "environments") +solo true diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..9e45f9d --- /dev/null +++ b/Berksfile @@ -0,0 +1,7 @@ +# frozen_string_literal: true +source 'https://supermarket.chef.io' + +metadata + +cookbook 'windows', '~> 7.0.0' +cookbook 'chocolatey', '2.0.1' diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/chefignore b/chefignore new file mode 100644 index 0000000..38e7379 --- /dev/null +++ b/chefignore @@ -0,0 +1,107 @@ +# Put files/directories that should be ignored in this file when uploading +# to a chef-server or supermarket. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +examples/* +Guardfile +Procfile +.kitchen* +.rubocop.yml +spec/* +Rakefile +.travis.yml +.foodcritic +.codeclimate.yml + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Policyfile # +############## +Policyfile.rb +Policyfile.lock.json + +# Cookbooks # +############# +CONTRIBUTING* +CHANGELOG* +TESTING* +MAINTAINERS.toml + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/cookbooks/ros2_windows/README.md b/cookbooks/ros2_windows/README.md new file mode 100644 index 0000000..67db4ca --- /dev/null +++ b/cookbooks/ros2_windows/README.md @@ -0,0 +1,3 @@ +# ros2_windows + +TODO: Enter the cookbook description here. diff --git a/cookbooks/ros2_windows/attributes/default.rb b/cookbooks/ros2_windows/attributes/default.rb new file mode 100644 index 0000000..1a05699 --- /dev/null +++ b/cookbooks/ros2_windows/attributes/default.rb @@ -0,0 +1,32 @@ +# True if setting up machine for ros2 development or false for binaries only +default['ros2_windows']['development'] = false + +# ROS 2 binary versions, dashing/eloquent/foxy etc +default['ros2_windows']['release_version'] = 'eloquent' + +# Binary build version, 'release' or 'debug' +default['ros2_windows']['build_type'] = 'release' + +# In development, also download ros2 sources +default['ros2_windows']['download_sources'] = true + +# Visual studio version, "buildtools" or "community" +default['ros2_windows']['vs_version'] = 'buildtools' + +# github.com/ros2/ros2 branch version, "master", "dashing", "dashing-release", etc. +# Only used if downloading sources +default['ros2_windows']['source']['ros2.repos'] = 'master' + +# Location of ros2 workspace, used for both development/binary configurations +default['ros2_windows']['ros2_ws'] = 'C:\\dev\\ros2_ws' + +# Current binary locations, update as new releases become available +default['ros2_windows']['eloquent']['release'] = 'https://github.com/ros2/ros2/releases/download/release-eloquent-20191122/ros2-eloquent-20191122-windows-release-amd64.zip' +default['ros2_windows']['eloquent']['debug'] = 'https://github.com/ros2/ros2/releases/download/release-eloquent-20191122/ros2-eloquent-20191122-windows-debug-amd64.zip' +default['ros2_windows']['dashing']['release'] = 'https://github.com/ros2/ros2/releases/download/release-dashing-20200319/ros2-dashing-20200319-windows-amd64.zip' +default['ros2_windows']['dashing']['debug'] = 'https://github.com/ros2/ros2/releases/download/release-dashing-20200319/ros2-dashing-20200319-windows-debug-amd64.zip' + +# Install additional DDS vendors +default['ros2_windows']['install_opensplice'] = false + +default['ros2_windows']['install_connext'] = false diff --git a/cookbooks/ros2_windows/attributes/rti_connext.rb b/cookbooks/ros2_windows/attributes/rti_connext.rb new file mode 100644 index 0000000..d7ee0a7 --- /dev/null +++ b/cookbooks/ros2_windows/attributes/rti_connext.rb @@ -0,0 +1,18 @@ +# MAJOR.MINOR.PATCH version of rti, match to your install package +default['ros2_windows']['rti_connext']['version'] = nil + +# Edition of your connext installer ('evaluation', 'pro') +default['ros2_windows']['rti_connext']['edition'] = nil + +# Match these to the values in your install package +default['ros2_windows']['rti_connext']['target_platform'] = 'x64Win64' +default['ros2_windows']['rti_connext']['min_vs_version'] = '2017' + +# Path to your rti_connext installer file +default['ros2_windows']['rti_connext']['license_file'] = nil + +# Path to the directory container your installer packages +default['ros2_windows']['rti_connext']['installer_dir'] = nil + +# Openssl version used specifically for rti-connext, match to the installer package +default['ros2_windows']['rti_connext']['openssl_version'] = nil diff --git a/cookbooks/ros2_windows/files/qt-installer.qs b/cookbooks/ros2_windows/files/qt-installer.qs new file mode 100644 index 0000000..120419b --- /dev/null +++ b/cookbooks/ros2_windows/files/qt-installer.qs @@ -0,0 +1,237 @@ +/* eslint-disable no-alert, no-console, no-var, linebreak-style, prefer-arrow-callback, + prefer-template, no-restricted-syntax, quote-props, prefer-destructuring */ +// eslint disables were chosen because they are incompatible with the Qt JavaScript Engine + +// Copyright 2016 Ben Lau +// +// 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. + +// File adapted and modified from the following examples +// https://github.com/benlau/qtci/blob/master/bin/extract-qt-installer +// Modified from shell script to .qs file, and adapted to specific ros2/ci use + +// Command line usage +// qt-unified-windows-x86-3.1.1-online.exe --verbose --script qt-installer.qs [Option=Value] +// Options: +// MsvcVersion=[2015,2017,2019,...] +// ErrorLogArgName='C:\Path\To\Writeable\Logfile' + +/* global installer:writeable, gui:writeable, buttons, QMessageBox */ + +var DefaultMsvcVersion = '2019'; +var BuildToolsPrefix = 'win64_msvc'; +var BuildToolsSuffix = '_64'; +var Qt5ComponentPrefix = 'qt.qt5.'; +var ErrorLogArgName = 'ErrorLogname'; +var MsvcVersionArgName = 'MsvcVersion'; + +var CheckCategory = function CheckCategory(gui, category, shouldCheck) { + var page = gui.pageWidgetByObjectName('ComponentSelectionPage'); + var checkBox = gui.findChild(page, category); + if (checkBox) { + if (checkBox.checked !== shouldCheck) { + checkBox.click(); + } + } +}; + +var FindLatestCompatibleVersion = function FindLatestCompatibleVersion(regex, filterFn) { + var versions = []; + var components = installer.components(); + var id; + var matchResult; + + for (id in components) { + if (Object.prototype.hasOwnProperty.call(components, id)) { + // Documentation about QtQmL regex https://doc.qt.io/qt-5/qregexp.html + matchResult = components[id].name.match(regex); + if (matchResult && filterFn(matchResult[1])) { + console.log('Match result: ' + matchResult[1]); + versions.push(matchResult[1]); + } + } + } + if (versions.length === 0) { + return null; + } + // We want latest, so sort in descending order + versions.sort(function DescendingOrder(a, b) { return b - a; }); + return versions[0]; +}; + +var FindMostRecentLTS = function FindMostRecentLTS() { + var regex = '(?:qt.qt5.)(\\d+)$'; + // Match component names of the form qt.qt5.5xyz and capture just the 5xyz + return FindLatestCompatibleVersion(regex, function IncludeAll() { return true; }); +}; + +var FindMostRecentBuildTools = function FindMostRecentBuildTools(prefix, desiredMsvcYear) { + var regex = '(?:' + prefix + '.' + BuildToolsPrefix + ')(\\d{4})(?:' + BuildToolsSuffix + ')$'; + var filter = function LessThanOrEqualTo(value) { return Number(value) <= desiredMsvcYear; }; + return FindLatestCompatibleVersion(regex, filter); +}; + +var SelectQtComponent = function SelectQtComponent() { + var widget = gui.currentPageWidget(); + + var latestVersion = FindMostRecentLTS(); + var targetBuildVersion = installer.value(MsvcVersionArgName, DefaultMsvcVersion); + + var prefix; + var buildToolsVersion; + var componentId; + var emptyDiskSpace; + + if (!latestVersion) { + throw new Error('Finding latest version failed'); + } + prefix = Qt5ComponentPrefix + latestVersion; + + console.log('Target MSVC Version ' + targetBuildVersion); + buildToolsVersion = FindMostRecentBuildTools(prefix, targetBuildVersion); + if (!buildToolsVersion) { + throw new Error('Finding a component compatibile with the desired buildtools version (' + targetBuildVersion + '}) failed'); + } + console.log('Available Buildtools version: ' + buildToolsVersion); + + // Should be of the form qt.qt5.5126.win64_msvc2017_64 + componentId = prefix + '.' + BuildToolsPrefix + buildToolsVersion + BuildToolsSuffix; + console.log('Attempting to check ' + componentId); + widget.deselectAll(); + emptyDiskSpace = installer.requiredDiskSpace(); + widget.selectComponent(componentId); + if (emptyDiskSpace === installer.requiredDiskSpace()) { + throw new Error('Selecting component ' + componentId + ' failed'); + } + return { 'latestVersion': latestVersion, 'buildToolsVersion': buildToolsVersion }; +}; + +var GetDirectoryFromVersion = function GetDirectoryFromVersion(version) { + // The versions are of the form 5123, where the first character is the 4/5 version + // and the last character is the minor version (even if 0), and the middle characters + // are the major version + var versionString = String(version); + var length = version.length; + if (length < 3 || length > 4) { + throw new Error('Assertion failed: (version.length < 3 || version.length > 4)'); + } + return versionString[0] + '.' + versionString.slice(1, length - 1) + '.' + versionString[length - 1]; +}; + + +function Controller() { + installer.installationFinished.connect(function ClickNext() { + gui.clickButton(buttons.NextButton); + }); + // If any message boxes need to be rejected, they'll need custom callbacks + installer.autoAcceptMessageBoxes(); + installer.setMessageBoxAutomaticAnswer('OverwriteTargetDirectory', QMessageBox.Yes); + installer.setMessageBoxAutomaticAnswer('installationErrorWithRetry', QMessageBox.Ignore); +} + +Controller.prototype.WelcomePageCallback = function WelcomePageCallback() { + // Connects with Qt over internet + gui.clickButton(buttons.NextButton, 3000); +}; + +Controller.prototype.CredentialsPageCallback = function CredentialsPageCallback() { + gui.clickButton(buttons.CommitButton); +}; + +Controller.prototype.ComponentSelectionPageCallback = function ComponentSelectionPageCallback() { + var page = gui.pageWidgetByObjectName('ComponentSelectionPage'); + var fetchButton = gui.findChild(page, 'FetchCategoryButton'); + var path = installer.value(ErrorLogArgName, '%temp%\\installer.err'); + var qt5Path; + // These should be the defaults, but just in case... + CheckCategory(gui, 'LTS', false); + CheckCategory(gui, 'Archive', false); + CheckCategory(gui, 'Latest releases', true); + CheckCategory(gui, 'Preview', false); + if (fetchButton) { + // Refresh components if any of the checkboxes above changed + fetchButton.click(); + } + + try { + this.installedVersion = SelectQtComponent(); + if (typeof this.installedVersion !== 'undefined') { + qt5Path = '@TargetDir@\\' + GetDirectoryFromVersion(this.installedVersion.latestVersion) + + '\\msvc' + this.installedVersion.buildToolsVersion + '_64'; + console.log('Setting Qt5_DIR Environment Variable to ' + qt5Path); + installer.performOperation('EnvironmentVariable', ['Qt5_DIR', qt5Path, true, false]); + } + } catch (err) { + // Cancel install if any error is encountered + console.log(err.fileName + ':' + err.lineNumber + ' ' + err.message); + console.log('Writing error to file ' + path); + installer.performOperation('AppendFile', [path, err.message]); + gui.clickButton(buttons.CancelButton, 5000); + throw err; + } + + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.IntroductionPageCallback = function IntroductionPageCallback() { + console.log('Retrieving meta information from remote repository'); + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.TargetDirectoryPageCallback = function TargetDirectoryPageCallback() { + // Default location is C:\Qt\Qt5.12.6 + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.ObligationsPageCallback = function ObligationsPageCallback() { + var widget = gui.currentPageWidget(); + widget.obligationsAgreement.click(); + for (var id in widget.obligationsAgreement) { + console.log(id); + } + + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.LicenseAgreementPageCallback = function LicenseAgreementPageCallback() { + var widget = gui.currentPageWidget(); + if (widget != null) { + widget.AcceptLicenseRadioButton.setChecked(true); + } + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.ReadyForInstallationPageCallback = function ReadyForInstallPageCallback() { + gui.clickButton(buttons.CommitButton); +}; + +Controller.prototype.FinishedPageCallback = function FinishedPageCallback() { + var widget = gui.currentPageWidget(); + if (widget.LaunchQtCreatorCheckBoxForm) { + // No this form for minimal platform + widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false); + } + + gui.clickButton(buttons.FinishButton); +}; + +// Telemetry disabled +Controller.prototype.DynamicTelemetryPluginFormCallback = function DynamicTelemetryFormCallback() { + var page = gui.pageWidgetByObjectName('DynamicTelemetryPluginForm'); + page.statisticGroupBox.disableStatisticRadioButton.setChecked(true); + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.StartMenuDirectoryPageCallback = function StartMenuDirectoryPageCallback() { + gui.clickButton(buttons.NextButton); +}; diff --git a/cookbooks/ros2_windows/files/qt-maintenance.qs b/cookbooks/ros2_windows/files/qt-maintenance.qs new file mode 100644 index 0000000..ddf2431 --- /dev/null +++ b/cookbooks/ros2_windows/files/qt-maintenance.qs @@ -0,0 +1,223 @@ +/* eslint-disable no-alert, no-console, no-var, linebreak-style, prefer-arrow-callback, + prefer-template, no-restricted-syntax, quote-props, prefer-destructuring */ +// eslint disables were chosen because they are incompatible with the Qt JavaScript Engine + +// Copyright 2016 Ben Lau +// +// 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. + +// File adapted and modified from the following examples +// https://github.com/benlau/qtci/blob/master/bin/extract-qt-installer +// Modified from shell script to .qs file, and adapted to specific ros2/ci use + +// Command line usage +// qt-unified-windows-x86-3.1.1-online.exe --verbose --script qt-installer.qs [Option=Value] +// Options: +// MsvcVersion=[2015,2017,2019,...] +// ErrorLogArgName='C:\Path\To\Writeable\Logfile' + +/* global installer:writeable, gui:writeable, buttons, QMessageBox */ + +var DefaultMsvcVersion = '2019'; +var BuildToolsPrefix = 'win64_msvc'; +var BuildToolsSuffix = '_64'; +var Qt5ComponentPrefix = 'qt.qt5.'; +var ErrorLogArgName = 'ErrorLogname'; +var MsvcVersionArgName = 'MsvcVersion'; + +var CheckCategory = function CheckCategory(gui, category, shouldCheck) { + var page = gui.pageWidgetByObjectName('ComponentSelectionPage'); + var checkBox = gui.findChild(page, category); + if (checkBox) { + if (checkBox.checked !== shouldCheck) { + checkBox.click(); + } + } +}; + +var FindLatestCompatibleVersion = function FindLatestCompatibleVersion(regex, filterFn) { + var versions = []; + var components = installer.components(); + var id; + var matchResult; + + for (id in components) { + if (Object.prototype.hasOwnProperty.call(components, id)) { + // Documentation about QtQmL regex https://doc.qt.io/qt-5/qregexp.html + matchResult = components[id].name.match(regex); + if (matchResult && filterFn(matchResult[1])) { + console.log('Match result: ' + matchResult[1]); + versions.push(matchResult[1]); + } + } + } + if (versions.length === 0) { + return null; + } + // We want latest, so sort in descending order + versions.sort(function DescendingOrder(a, b) { return b - a; }); + return versions[0]; +}; + +var FindMostRecentLTS = function FindMostRecentLTS() { + var regex = '(?:qt.qt5.)(\\d+)$'; + // Match component names of the form qt.qt5.5xyz and capture just the 5xyz + return FindLatestCompatibleVersion(regex, function IncludeAll() { return true; }); +}; + +var FindMostRecentBuildTools = function FindMostRecentBuildTools(prefix, desiredMsvcYear) { + var regex = '(?:' + prefix + '.' + BuildToolsPrefix + ')(\\d{4})(?:' + BuildToolsSuffix + ')$'; + var filter = function LessThanOrEqualTo(value) { return Number(value) <= desiredMsvcYear; }; + return FindLatestCompatibleVersion(regex, filter); +}; + +var SelectQtComponent = function SelectQtComponent() { + var widget = gui.currentPageWidget(); + + var latestVersion = FindMostRecentLTS(); + var targetBuildVersion = installer.value(MsvcVersionArgName, DefaultMsvcVersion); + + var prefix; + var buildToolsVersion; + var componentId; + var beforeDiskSpace; + var selectedComponent; + + if (!latestVersion) { + throw new Error('Finding latest version failed'); + } + prefix = Qt5ComponentPrefix + latestVersion; + + console.log('Target MSVC Version ' + targetBuildVersion); + buildToolsVersion = FindMostRecentBuildTools(prefix, targetBuildVersion); + if (!buildToolsVersion) { + throw new Error('Finding a component compatibile with the desired buildtools version (' + targetBuildVersion + '}) failed'); + } + console.log('Available Buildtools version: ' + buildToolsVersion); + + // Should be of the form qt.qt5.5126.win64_msvc2017_64 + componentId = prefix + '.' + BuildToolsPrefix + buildToolsVersion + BuildToolsSuffix; + console.log('Attempting to check ' + componentId); + + // We're only installing one component, deselecting will cause everything else to be uninstalled. + // If this gets run on systems that need more Qt stuff installed, this logic should be adjusted to + // just uninstall older msvc components. + beforeDiskSpace = installer.requiredDiskSpace(); + widget.deselectAll(); + widget.selectComponent(componentId); + selectedNewComponent = (beforeDiskSpace !== installer.requiredDiskSpace()); + return { + 'selectedNewComponent': selectedNewComponent, + 'latestVersion': latestVersion, + 'buildToolsVersion': buildToolsVersion + }; +}; + +var GetDirectoryFromVersion = function GetDirectoryFromVersion(version) { + // The versions are of the form 5123, where the first character is the 4/5 version + // and the last character is the minor version (even if 0), and the middle characters + // are the major version + var versionString = String(version); + var length = version.length; + if (length < 3 || length > 4) { + throw new Error('Assertion failed: (version.length < 3 || version.length > 4)'); + } + return versionString[0] + '.' + versionString.slice(1, length - 1) + '.' + versionString[length - 1]; +}; + + +function Controller() { + installer.installationFinished.connect(function ClickNext() { + // gui.clickButton(buttons.NextButton); + }); + // If any message boxes need to be rejected, they'll need custom callbacks + installer.autoAcceptMessageBoxes(); + installer.setMessageBoxAutomaticAnswer('OverwriteTargetDirectory', QMessageBox.Yes); + installer.setMessageBoxAutomaticAnswer('installationErrorWithRetry', QMessageBox.Ignore); +} + +Controller.prototype.WelcomePageCallback = function WelcomePageCallback() { + // Connects with Qt over internet + gui.clickButton(buttons.NextButton, 3000); +}; + +Controller.prototype.CredentialsPageCallback = function CredentialsPageCallback() { + gui.clickButton(buttons.CommitButton); +}; + +Controller.prototype.IntroductionPageCallback = function IntroductionPageCallback() { + console.log('Retrieving meta information from remote repository'); + var widget = gui.currentPageWidget(); + widget.findChild('PackageManagerRadioButton').checked = true; + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.ComponentSelectionPageCallback = function ComponentSelectionPageCallback() { + var page = gui.pageWidgetByObjectName('ComponentSelectionPage'); + var fetchButton = gui.findChild(page, 'FetchCategoryButton'); + var path = installer.value(ErrorLogArgName, '%temp%\\installer.err'); + var qt5Path; + // Check archive so deselection works + CheckCategory(gui, 'LTS', false); + CheckCategory(gui, 'Archive', true); + CheckCategory(gui, 'Latest releases', true); + CheckCategory(gui, 'Preview', false); + if (fetchButton) { + // Refresh components if any of the checkboxes above changed + fetchButton.click(); + } + + try { + this.installedVersion = SelectQtComponent(); + if (typeof this.installedVersion !== 'undefined') { + if (this.installedVersion.selectedNewComponent) { + qt5Path = '@TargetDir@\\' + GetDirectoryFromVersion(this.installedVersion.latestVersion) + + '\\msvc' + this.installedVersion.buildToolsVersion + '_64'; + console.log('Setting Qt5_DIR Environment Variable to ' + qt5Path); + installer.performOperation('EnvironmentVariable', ['Qt5_DIR', qt5Path, true, false]); + } else { + // Installer won't let us do anything if component selections don't change. + + gui.clickButton(buttons.CancelButton); + } + } + } catch (err) { + // Cancel install if any error is encountered + console.log(err.fileName + ':' + err.lineNumber + ' ' + err.message); + console.log('Writing error to file ' + path); + installer.performOperation('AppendFile', [path, err.message]); + throw err; + } + + gui.clickButton(buttons.NextButton); +}; + +Controller.prototype.ReadyForInstallationPageCallback = function ReadyForInstallPageCallback() { + console.log('ReadyForInstallPageCallback'); + gui.clickButton(buttons.CommitButton); +}; + +Controller.prototype.FinishedPageCallback = function FinishedPageCallback() { + var widget = gui.currentPageWidget(); + if (widget.LaunchQtCreatorCheckBoxForm) { + widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false); + } + + gui.clickButton(buttons.FinishButton); +}; + +Controller.prototype.PerformInstallationPageCallback = function PerformInstallationPageCallback() { + console.log('In perform installation callback'); + var page = gui.currentPageWidget(); + page.setAutomatedPageSwitchEnabled(true); +}; diff --git a/cookbooks/ros2_windows/metadata.rb b/cookbooks/ros2_windows/metadata.rb new file mode 100644 index 0000000..6f0a400 --- /dev/null +++ b/cookbooks/ros2_windows/metadata.rb @@ -0,0 +1,22 @@ +name 'ros2_windows' +maintainer 'Stephen Brawner' +maintainer_email 'brawner@gmail.com' +license 'All Rights Reserved' +description 'Installs/Configures ros2_windows' +long_description 'Installs/Configures ros2_windows' +version '0.1.0' +chef_version '>= 12.1' if respond_to?(:chef_version) + +# The `issues_url` points to the location where issues for this cookbook are +# tracked. A `View Issues` link will be displayed on this cookbook's page when +# uploaded to a Supermarket. +# +# issues_url 'https://github.com/osrf/chef-osrf/issues' + +# The `source_url` points to the development repository for this cookbook. A +# `View Source` link will be displayed on this cookbook's page when uploaded to +# a Supermarket. +# +# source_url 'https://github.com/osrf/chef-osrf' +depends 'chocolatey' +depends 'seven_zip' diff --git a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb new file mode 100644 index 0000000..685b14b --- /dev/null +++ b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb @@ -0,0 +1,48 @@ +chocolatey_package 'choco_packages' do + package_name ['git', 'cmake', 'curl', 'vcredist2013', 'vcredist140', 'cppcheck', 'patch'] + # Installs if not installed, otherwise it will upgrade + action :upgrade +end + +windows_env 'PATH' do + key_name 'PATH' + value 'C:\\Program Files\\Git\\cmd;C:\\Program Files\\CMake\\bin' + delim ';' + action :modify +end + +# Custom choco packages +remote_file 'asio.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/asio.1.12.1.nupkg' + action :create +end + +remote_file 'cunit.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/cunit.2.1.3.nupkg' + action :create +end + +remote_file 'eigen.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/eigen.3.3.4.nupkg' + action :create +end + +remote_file 'log4cxx.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/log4cxx.0.10.0.nupkg' + action :create +end + +remote_file 'tinyxml-usestl.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/tinyxml-usestl.2.6.2.nupkg' + action :create +end + +remote_file 'tinyxml2.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/tinyxml2.6.0.0.nupkg' + action :create +end + +chocolatey_package 'custom_packages' do + package_name ['asio', 'cunit', 'eigen', 'tinyxml-usestl', 'tinyxml2', 'log4cxx'] + source '.\\' +end diff --git a/cookbooks/ros2_windows/recipes/opencv.rb b/cookbooks/ros2_windows/recipes/opencv.rb new file mode 100644 index 0000000..7c208fc --- /dev/null +++ b/cookbooks/ros2_windows/recipes/opencv.rb @@ -0,0 +1,18 @@ +seven_zip_archive 'open_cv_zip' do + path 'C:\\opencv' + source 'https://github.com/ros2/ros2/releases/download/opencv-archives/opencv-3.4.6-vc16.VS2019.zip' + overwrite true +end + +windows_env 'OpenCV_DIR' do + key_name 'OpenCV_DIR' + value 'C:\\opencv' + action :create +end + +windows_env 'PATH' do + key_name 'PATH' + value 'C:\\opencv' + delim ';' + action :modify +end diff --git a/cookbooks/ros2_windows/recipes/opensplice.rb b/cookbooks/ros2_windows/recipes/opensplice.rb new file mode 100644 index 0000000..97a7303 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/opensplice.rb @@ -0,0 +1,11 @@ +seven_zip_archive 'opensplice' do + path 'C:\opensplice' + source 'https://github.com/ADLINK-IST/opensplice/releases/download/OSPL_V6_9_190925OSS_RELEASE/PXXX-VortexOpenSplice-6.9.190925OSS-HDE-x86_64.win-vs2019-installer.zip' + overwrite true +end + +windows_env 'OSPL_HOME' do + key_name 'OSPL_HOME' + value 'C:\\opensplice\\HDE\\x86_64.win64' + action :create +end diff --git a/cookbooks/ros2_windows/recipes/openssl.rb b/cookbooks/ros2_windows/recipes/openssl.rb new file mode 100644 index 0000000..282df66 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/openssl.rb @@ -0,0 +1,17 @@ +windows_package 'openssl' do + source 'https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe' + options '/VERYSILENT' +end + +windows_env 'OPENSSL_CONF' do + key_name 'OPENSSL_CONF' + value 'C:\\OpenSSL-Win64\\bin\\openssl.cfg' + action :create +end + +windows_env 'PATH' do + key_name 'PATH' + value 'C:\\OpenSSL-Win64\\bin' + delim ';' + action :modify +end diff --git a/cookbooks/ros2_windows/recipes/pip_installs.rb b/cookbooks/ros2_windows/recipes/pip_installs.rb new file mode 100644 index 0000000..4a22892 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/pip_installs.rb @@ -0,0 +1,51 @@ +required_pip_packages = [ + 'pydot', + 'PyQt5', + 'vcstool', + 'colcon-common-extensions', + 'catkin_pkg', + 'cryptography', + 'EmPy', + 'ifcfg', + 'lark-parser', + 'lxml', + 'netifaces', + 'numpy', + 'opencv-python', + 'pyparsing', + 'pyyaml', + 'pytest', + 'pytest-mock', + 'coverage', + 'mock' +] + +development_pip_packages = [ + 'flake8', + 'flake8-blind-except', + 'flake8-builtins', + 'flake8-class-newline', + 'flake8-comprehensions', + 'flake8-deprecated', + 'flake8-docstrings', + 'flake8-import-order', + 'flake8-quotes', + 'mypy', + 'pep8', + 'pydocstyle' +] + +# Use explicit location because python may not be on the PATH if chef-solo has not been run before +execute 'pip_update' do + command 'C:\Python37\python.exe -m pip install -U pip setuptools' +end + +execute 'pip_required' do + command 'C:\Python37\python.exe -m pip install -U ' + required_pip_packages.join(' ') +end + +if node['ros2_windows']['development'] == true + execute 'pip_additional' do + command 'C:\Python37\python.exe -m pip install -U ' + development_pip_packages.join(' ') + end +end diff --git a/cookbooks/ros2_windows/recipes/python.rb b/cookbooks/ros2_windows/recipes/python.rb new file mode 100644 index 0000000..3712ccf --- /dev/null +++ b/cookbooks/ros2_windows/recipes/python.rb @@ -0,0 +1,4 @@ +windows_package 'python' do + source 'https://www.python.org/ftp/python/3.7.6/python-3.7.6-amd64.exe' + options '/quiet TargetDir=C:\\Python37 PrependPath=1 Include_debug=1 Include_symbols=1' +end diff --git a/cookbooks/ros2_windows/recipes/qt5.rb b/cookbooks/ros2_windows/recipes/qt5.rb new file mode 100644 index 0000000..05d2b77 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/qt5.rb @@ -0,0 +1,48 @@ +directory 'AppData_Qt' do +path File.join(Dir.home(), "AppData\\Roaming\\Qt") +end + +# Installing Qt5 requires an account. This file contains a username and secret account token +cookbook_file 'qtaccount.ini' do + path File.join(Dir.home(), "AppData\\Roaming\\Qt\\qtaccount.ini") + source 'qtaccount.ini' + action :create_if_missing +end + +cookbook_file 'qt-installer.qs' do + source 'qt-installer.qs' +end + +cookbook_file 'qt-maintenance.qs' do + source 'qt-maintenance.qs' +end + +# Install Qt5 with automated install script, no msvc2019 version exists but 2017 is compatible +# Updater/silentUpdate options did not work for me. Install scripts finds and installs the most recent LTS version +error_filename = File.join(Dir.home(), "qt_install.err") + +windows_package 'Qt Maintenance' do + source 'c:\\Qt\\MaintenanceTool.exe' + installer_type :custom + returns [0, 1, 3] + options '--script qt-maintenance.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' + timeout 2000 + only_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} +end + +windows_package 'Qt Install' do + source 'http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe' + installer_type :custom + returns [0, 1] + options '--script qt-installer.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' + timeout 2000 + not_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} +end + +ruby_block 'error_exist?' do + block do + if ::File.exist?(error_filename) + raise 'Error install Qt5, see ' + error_filename + end + end +end diff --git a/cookbooks/ros2_windows/recipes/ros2.rb b/cookbooks/ros2_windows/recipes/ros2.rb new file mode 100644 index 0000000..08a0af8 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/ros2.rb @@ -0,0 +1,47 @@ + +include_recipe 'chocolatey' +include_recipe 'seven_zip' +include_recipe 'ros2_windows::rti_connext' if node['ros2_windows']['install_connext'] == true + +include_recipe 'ros2_windows::python' +include_recipe 'ros2_windows::pip_installs' +include_recipe 'ros2_windows::opencv' +include_recipe 'ros2_windows::openssl' +include_recipe 'ros2_windows::chocolatey_installs' +include_recipe 'ros2_windows::visual_studio' +include_recipe 'ros2_windows::qt5' + +include_recipe 'ros2_windows::opensplice' if node['ros2_windows']['install_opensplice'] == true + +include_recipe 'ros2_windows::ros2_binaries' if node['ros2_windows']['development'] == false + +if node['ros2_windows']['download_sources'] == false then + return +end + +include_recipe 'ros2_windows::xmllint' + +directory 'ros2_ws' do + path node['ros2_windows']['ros2_ws'] + action :create + recursive true +end + +ros2_src_dir = File.join(node['ros2_windows']['ros2_ws'], 'src') +directory 'ros2_ws_src' do + path ros2_src_dir + action :create + recursive true +end + +ros2_repos_path = File.join(node['ros2_windows']['ros2_ws'], 'ros2.repos') +print('https://raw.githubusercontent.com/ros2/ros2/%s/ros2.repos', node['ros2_windows']['source']['ros2.repos']) +remote_file 'ros2.repos' do + source sprintf('https://raw.githubusercontent.com/ros2/ros2/%s/ros2.repos', node['ros2_windows']['source']['ros2.repos']) + path ros2_repos_path + action :create +end + +execute 'vcs_import' do + command sprintf('C:\Python37\Scripts\vcs.exe import --input %s %s', ros2_repos_path, ros2_src_dir) +end diff --git a/cookbooks/ros2_windows/recipes/ros2_binaries.rb b/cookbooks/ros2_windows/recipes/ros2_binaries.rb new file mode 100644 index 0000000..2dd3d68 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/ros2_binaries.rb @@ -0,0 +1,7 @@ +release_version = node['ros2_windows']['release_version'] +build_type = node['ros2_windows']['build_type'] + +seven_zip_archive 'ros2' do + source node['ros2_windows'][release_version][build_type] + path node['ros2_windows']['ros2_ws'] +end diff --git a/cookbooks/ros2_windows/recipes/rti_connext.rb b/cookbooks/ros2_windows/recipes/rti_connext.rb new file mode 100644 index 0000000..54f8775 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/rti_connext.rb @@ -0,0 +1,130 @@ +connext_params = node['ros2_windows']['rti_connext'] + +# These will fail if the rti_connext parameters have not been specified because the defaults are 'nil' +assert(File.exists?(connext_params['license_file']), + sprintf('License file location does not exist: %s', + connext_params['license_file'])) + +assert(Dir.exists?(connext_params['installer_dir']), + sprintf('Installer directory does not exist: %s', + connext_params['installer_dir'])) +assert_not_nil(connext_params['version'], "Version is nil, requires MAJOR.MINOR.PATCH (e.g. '5.3.1')") +assert_not_nil(connext_params['edition'], "Edition is nil, requires one of ('evaluation', 'pro')") + +assert_not_nil(connext_params['min_vs_version'], "Minimum Visual Studio version is required (e.g. '2017')") + +assert_not_nil(connext_params['openssl_version'], "OpenSSL version is required (e.g. '1.0.2n')") + +host_installer_filename = sprintf('rti_connext_dds-%s-%s-host-%s.exe', + connext_params['version'], + connext_params['edition'], + connext_params['target_platform']) +host_installer_path = File.join(connext_params['installer_dir'], host_installer_filename) + +target_platform_vs_version = connext_params['target_platform'] + 'VS' + connext_params['min_vs_version'] + +openssl_installer_path = File.join(connext_params['installer_dir'], + sprintf('openssl-%s-target-%s.zip', + connext_params['openssl_version'], + target_platform_vs_version)) + +target_installer_filename = sprintf('rti_connext_dds-%s-%s-target-%s.rtipkg', + connext_params['version'], + connext_params['edition'], + target_platform_vs_version) +target_installer_path = File.join(connext_params['installer_dir'], + target_installer_filename) + +rtipkginstall_bat = File.join('%ProgramFiles%', + sprintf('rti_connext_dds-%s', connext_params['version']), + 'bin', + 'rtipkginstall.bat') + +security_plugins_host_filename = sprintf('rti_security_plugins-%s-host-%s.rtipkg', + connext_params['version'], + connext_params['target_platform']) +security_plugins_host_path = File.join(connext_params['installer_dir'], security_plugins_host_filename) + +security_plugins_target_filename = sprintf('rti_security_plugins-%s-target-%s.rtipkg', + connext_params['version'], + target_platform_vs_version) + +security_plugins_target_path = File.join(connext_params['installer_dir'], security_plugins_target_filename) + +rti_openssl_base_dir = File.join('C:\\connext', + sprintf('openssl-%s', connext_params['openssl_version']), + target_platform_vs_version, + 'release') + +print "--------------------------RTI Connext Install params--------------------------" +print 'License file: ' + connext_params['license_file'] +print 'Host installer: ' + host_installer_path +print 'Target installer: ' + target_installer_path +print 'Openssl installer: ' + openssl_installer_path +print 'Host security plugins installer: ' + security_plugins_host_path +print 'Target security plugins installer: ' + security_plugins_target_path +print 'Installed openssl dir: ' + rti_openssl_base_dir +print 'rtipkg batch script: ' + rtipkginstall_bat +print "------------------------------------------------------------------------------" + +directory "C:\\connext" do + path "C:\\connext" + action :create +end + +execute 'copy_license_file' do + command sprintf('copy %s C:\\connext\\', connext_params['license_file']) +end + +execute 'copy_connextdds_host' do + command sprintf('copy /b %s.??? %s', host_installer_path, host_installer_path) +end + +seven_zip_archive 'openssl_zip' do + path 'C:\\connext\\' + source openssl_installer_path + overwrite true +end + +execute 'copy_connextdds_target' do + command sprintf('copy /b %s.??? %s', target_installer_filename, target_installer_filename) +end + +windows_env 'RTI_LICENSE_FILE' do + key_name 'RTI_LICENSE_FILE' + value 'C:\\connext\\rti_license.dat' + action :create +end + +windows_package 'rti_connext' do + source host_installer_path + options '--mode unattended --unattendedmodeui minimalWithDialogs --prefix "%ProgramFiles%"' +end + +execute 'rtipkginstall_openssl' do + command rtipkginstall_bat + ' ' + openssl_installer_path +end + +execute 'rtipkginstall_rti_connext_dds_target' do + command rtipkginstall_bat + ' ' + target_installer_path +end + +execute 'rtipkginstall_rti_security_plugins_host' do + command rtipkginstall_bat + ' ' + security_plugins_host_path +end + +execute 'rtipkginstall_rti_security_plugins_target' do + command rtipkginstall_bat + ' ' + security_plugins_target_path +end + +windows_env 'RTI_OPENSSL_BIN' do + key_name 'RTI_OPENSSL_BIN' + value File.join(rti_openssl_base_dir, 'bin') + action :create +end + +windows_env 'RTI_OPENSSL_LIB' do + key_name 'RTI_OPENSSL_LIB' + value File.join(rti_openssl_base_dir, 'lib') + action :create +end diff --git a/cookbooks/ros2_windows/recipes/visual_studio.rb b/cookbooks/ros2_windows/recipes/visual_studio.rb new file mode 100644 index 0000000..9d64741 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/visual_studio.rb @@ -0,0 +1,54 @@ +# For more information about command line arguments, see: +# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 + +# If BuildTools is not already installed, install it +packages_to_install = [ + 'Microsoft.Net.Component.4.8.SDK', + 'Microsoft.VisualStudio.Workload.VCTools', + 'Microsoft.Component.MSBuild', + 'Microsoft.VisualStudio.Component.VC.CLI.Support' +] + +if node['ros2_windows']['vs_version'] != 'buildtools' then + packages_to_install += ['Microsoft.VisualStudio.Workload.NativeDesktop',] +end + +package_arguments = packages_to_install.map{ |pkg| '--add ' + pkg}.join(' ') +base_options = '--quiet --wait --norestart --includeRecommended ' + +installer_options = base_options + package_arguments + +visual_studio_source = 'https://aka.ms/vs/16/release/vs_%s.exe' % node['ros2_windows']['vs_version'] + +vs_version_camel_case = { + 'buildtools' => 'BuildTools', + 'community' => 'Community', + 'professional' => 'Professional', + 'enterprise' => 'Enterprise' +}[node['ros2_windows']['vs_version']] + +visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\%s' % vs_version_camel_case +windows_package 'Update VS' do + source visual_studio_source + installer_type :custom + returns [0, 3010] + options 'update ' + installer_options + timeout 1200 + only_if {::Dir.exist?(visual_studio_path)} +end + +windows_package 'Install vs_buildtools' do + source visual_studio_source + installer_type :custom + action :install + returns [0, 1605, 1614, 1641, 3010] + options installer_options + timeout 1200 + not_if {::Dir.exist?(visual_studio_path)} +end + +windows_env 'VCTargetsPath' do + key_name 'VCTargetsPath' + value File.join(visual_studio_path, 'MSBuild\\Microsoft\\VC\\v160\\') + action :create +end diff --git a/cookbooks/ros2_windows/recipes/xmllint.rb b/cookbooks/ros2_windows/recipes/xmllint.rb new file mode 100644 index 0000000..55ee445 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/xmllint.rb @@ -0,0 +1,24 @@ +seven_zip_archive 'libxml2' do + path 'C:\\xmllint' + source 'https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z' + overwrite true +end + +seven_zip_archive 'zlib' do + path 'C:\\xmllint' + source 'https://www.zlatkovic.com/pub/libxml/64bit/zlib-1.2.8-win32-x86_64.7z' + overwrite true +end + +seven_zip_archive 'iconv' do + path 'C:\\xmllint' + source 'https://www.zlatkovic.com/pub/libxml/64bit/iconv-1.14-win32-x86_64.7z' + overwrite true +end + +windows_env 'PATH' do + key_name 'PATH' + value 'C:\\xmllint\\bin' + delim ';' + action :modify +end diff --git a/roles/ros2-binaries.json b/roles/ros2-binaries.json new file mode 100644 index 0000000..c9c07de --- /dev/null +++ b/roles/ros2-binaries.json @@ -0,0 +1,19 @@ +{ + "name": "ros2-binaries", + "description": "Install necessary ROS 2 dependencies and ROS 2 binaries", + "json_class": "Chef::Role", + "default_attributes": { + "ros2_windows": { + "development": false, + "release_version": "eloquent", + "vs_version": "buildtools", + "ros2_ws": "C:\\dev\\ros2_eloquent", + "install_connext": false, + "install_opensplice": false, + } + }, + "chef_type": "role", + "run_list": [ + "recipe[ros2_windows::ros2]" + ], +} diff --git a/roles/ros2-debug-binaries.json b/roles/ros2-debug-binaries.json new file mode 100644 index 0000000..f0d2abf --- /dev/null +++ b/roles/ros2-debug-binaries.json @@ -0,0 +1,14 @@ +{ + "name": "ros2-binaries", + "description": "Install necessary ROS 2 dependencies and ROS 2 debug binaries", + "json_class": "Chef::Role", + "default_attributes": { + "ros2_windows": { + "build_type": "debug", + } + }, + "chef_type": "role", + "run_list": [ + "role[ros2-binaries]" + ], +} diff --git a/roles/ros2-development.json b/roles/ros2-development.json new file mode 100644 index 0000000..df7254b --- /dev/null +++ b/roles/ros2-development.json @@ -0,0 +1,20 @@ +{ + "name": "ros2-development", + "description": "Install necessary dependencies and set up a machine for ROS 2 development", + "json_class": "Chef::Role", + "default_attributes": { + "ros2_windows": { + "development": "true", + "download_sources": "true", + "vs_version": "buildtools", + "source": { + "ros2.repos": "master" + }, + "ros2_ws": "C:/dev/ros2_ws", + "install_connext": "false", + "install_opensplice": "true" + } + }, + "chef_type": "role", + "run_list": [ "recipe[ros2_windows::ros2]" ] +} From f5897119c667680ba7a34b034c324bc0d5bd4c9d Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 21 Apr 2020 12:32:45 -0700 Subject: [PATCH 3/9] Add readme documentation --- README.md | 8 ++- cookbooks/ros2_windows/README.md | 80 ++++++++++++++++++++++++++- cookbooks/ros2_windows/recipes/qt5.rb | 8 ++- ros2_windows.json | 1 + 4 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 ros2_windows.json diff --git a/README.md b/README.md index 4a81012..9c01a71 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# ROS 2 Coobooks \ No newline at end of file +# ROS 2 Cookbooks + +Currently, this repo hosts the chef cookbook for setting up a Windows machine for ROS 2 development or binaries, but it may be home to more soon! + +## ROS 2 Windows + +See the cookbook level [README.md](cookbooks/ros2_windows/README.md) diff --git a/cookbooks/ros2_windows/README.md b/cookbooks/ros2_windows/README.md index 67db4ca..e9f46a9 100644 --- a/cookbooks/ros2_windows/README.md +++ b/cookbooks/ros2_windows/README.md @@ -1,3 +1,79 @@ -# ros2_windows +# ROS 2 Windows Cookbook -TODO: Enter the cookbook description here. +This cookbook configures a host machine for ROS 2 development or binary installation. + +## Windows Install + +This walkthrough will install the following: +* chef/chef-solo +* chocolatey +* git + +In powershell, install chef: +``` +> . { iwr -useb https://omnitruck.cinc.sh/install.ps1 } | iex; install +``` + +In same shell, install chocolatey and git +``` +> Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://chocolatey.org/install.ps1 } | iex +> choco install -y git +> restart-computer +``` + +After the computer restarts, in the cmd shell (not powershell) run the following: + +This will open a GUI to input your github credentials +``` +> git clone https://github.com/ros-infrastructure/ros2-cookbooks +``` + +Run chef-solo to configure machine. +``` +> c:\cinc-project\cinc\bin\cinc-solo -c ros2-cookbooks\.chef\solo.rb -j ros2_windows.json +``` + +Type yes to accept the standard Chef licenses. + +Debug any issues that arise until running chef-solo completes successfully. + +## Configuration options + +The file `ros2_windows.json` may be modified for your own installation. +Please check the available attributes in [cookbooks/ros2_windows/attributes](cookbooks/ros2_windows/attributes) + +For example, the following will configure the installation to setup the machine for development with connext and opensplice. + +Adjust the `rti_connext` parameters to match your installation files. + +```json +{ + "default_attributes": { + "ros2_windows": { + "download_sources": "false", + "vs_version": "buildtools", + "ros2_ws": "C:/ci", + "install_connext": "true", + "install_opensplice": "true", + "rti_connext": { + "target_platform": "x64Win64", + "min_vs_version": "2017", + "license_file": "C:\\TEMP\\rticonnextdds-license\\rti_license.dat", + "installer_dir": "C:\\TEMP\\rticonnextdds-src", + "version": "5.3.1", + "edition": "pro", + "openssl_version": "1.0.2n" + } + } + }, + "run_list": ["role[ros2-development]"] +} +``` + +## Automating Qt installation + +For the most part the Qt installation is fully automated. +However, downloading Qt binaries requires creating a login. +If you already have a login and would like this process to complete successfully on a fresh machine, add the file at `${HOME}\AppData\Roaming\Qt\qtaccount.ini` from a previously setup Windows machine to the files directory, before deploying this to a new machine. +If you skip this step, the Qt installer will pause and require you to create a login before continuing. +Importantly, on a headless setup, you will not be able to see this GUI feedback and your installation will pause indefinitely. diff --git a/cookbooks/ros2_windows/recipes/qt5.rb b/cookbooks/ros2_windows/recipes/qt5.rb index 05d2b77..b892163 100644 --- a/cookbooks/ros2_windows/recipes/qt5.rb +++ b/cookbooks/ros2_windows/recipes/qt5.rb @@ -1,5 +1,5 @@ directory 'AppData_Qt' do -path File.join(Dir.home(), "AppData\\Roaming\\Qt") + path File.join(Dir.home(), "AppData\\Roaming\\Qt") end # Installing Qt5 requires an account. This file contains a username and secret account token @@ -7,6 +7,9 @@ path File.join(Dir.home(), "AppData\\Roaming\\Qt\\qtaccount.ini") source 'qtaccount.ini' action :create_if_missing + + # If the deploying user did not add this file to `files` continue anyway. + ignore_failure true end cookbook_file 'qt-installer.qs' do @@ -18,7 +21,8 @@ end # Install Qt5 with automated install script, no msvc2019 version exists but 2017 is compatible -# Updater/silentUpdate options did not work for me. Install scripts finds and installs the most recent LTS version +# Updater/silentUpdate options did not work for me. +# Install scripts finds and installs the most recent LTS version error_filename = File.join(Dir.home(), "qt_install.err") windows_package 'Qt Maintenance' do diff --git a/ros2_windows.json b/ros2_windows.json new file mode 100644 index 0000000..b1eba06 --- /dev/null +++ b/ros2_windows.json @@ -0,0 +1 @@ +{ "run_list": ["role[ros2-development]"]} From f0e6a231e583d61581d79b8f31a80b3f6b20c457 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Fri, 24 Apr 2020 00:35:14 -0700 Subject: [PATCH 4/9] Removing vendor-cookbooks --- Berksfile => cookbooks/ros2_windows/Berksfile | 4 +- cookbooks/ros2_windows/README.md | 6 + cookbooks/ros2_windows/metadata.rb | 1 + .../recipes/chocolatey_installs.rb | 7 +- vendor-cookbooks/chocolatey/CHANGELOG.md | 110 --- vendor-cookbooks/chocolatey/README.md | 45 - .../chocolatey/attributes/default.rb | 11 - vendor-cookbooks/chocolatey/files/install.ps1 | 345 ------- .../chocolatey/libraries/helpers.rb | 55 -- vendor-cookbooks/chocolatey/metadata.json | 1 - .../chocolatey/recipes/default.rb | 40 - vendor-cookbooks/ohai/CHANGELOG.md | 205 ----- vendor-cookbooks/ohai/CONTRIBUTING.md | 2 - vendor-cookbooks/ohai/README.md | 139 --- .../ohai/libraries/hint_helpers.rb | 35 - .../ohai/libraries/plugin_helpers.rb | 77 -- vendor-cookbooks/ohai/metadata.json | 1 - vendor-cookbooks/ohai/metadata.rb | 15 - vendor-cookbooks/ohai/recipes/default.rb | 20 - vendor-cookbooks/ohai/resources/hint.rb | 41 - vendor-cookbooks/ohai/resources/plugin.rb | 71 -- vendor-cookbooks/seven_zip/.gitignore | 26 - .../seven_zip/.kitchen.appveyor.yml | 25 - vendor-cookbooks/seven_zip/.kitchen.yml | 28 - vendor-cookbooks/seven_zip/.rspec | 3 - vendor-cookbooks/seven_zip/.rubocop.yml | 16 - vendor-cookbooks/seven_zip/Berksfile | 7 - vendor-cookbooks/seven_zip/CHANGELOG.md | 52 -- vendor-cookbooks/seven_zip/Gemfile | 8 - vendor-cookbooks/seven_zip/Gemfile.lock | 79 -- vendor-cookbooks/seven_zip/LICENSE | 201 ---- vendor-cookbooks/seven_zip/README.md | 114 --- vendor-cookbooks/seven_zip/appveyor.yml | 42 - .../seven_zip/attributes/default.rb | 31 - vendor-cookbooks/seven_zip/chefignore | 98 -- .../seven_zip/libraries/matchers.rb | 33 - vendor-cookbooks/seven_zip/metadata.json | 35 - vendor-cookbooks/seven_zip/metadata.rb | 12 - .../seven_zip/providers/archive.rb | 64 -- vendor-cookbooks/seven_zip/rakefile.rb | 27 - vendor-cookbooks/seven_zip/recipes/default.rb | 24 - .../seven_zip/resources/archive.rb | 29 - vendor-cookbooks/seven_zip/resources/tool.rb | 47 - .../seven_zip/spec/default_spec.rb | 27 - .../seven_zip/spec/spec_helper.rb | 15 - .../test_archive/attributes/default.rb | 3 - .../cookbooks/test_archive/metadata.rb | 3 - .../cookbooks/test_archive/recipes/default.rb | 17 - .../default/serverspec/default_spec.rb | 27 - .../helpers/serverspec/spec_helper.rb | 4 - vendor-cookbooks/windows/CHANGELOG.md | 870 ------------------ vendor-cookbooks/windows/CONTRIBUTING.md | 2 - vendor-cookbooks/windows/README.md | 426 --------- .../windows/libraries/powershell_helper.rb | 53 -- .../windows/libraries/registry_helper.rb | 356 ------- vendor-cookbooks/windows/libraries/version.rb | 189 ---- .../windows/libraries/version_helper.rb | 93 -- .../windows/libraries/windows_helper.rb | 165 ---- .../windows/libraries/windows_privileged.rb | 103 --- .../windows/libraries/wmi_helper.rb | 34 - vendor-cookbooks/windows/metadata.json | 1 - vendor-cookbooks/windows/metadata.rb | 10 - vendor-cookbooks/windows/providers/dns.rb | 148 --- vendor-cookbooks/windows/recipes/default.rb | 21 - .../windows/resources/certificate_binding.rb | 134 --- vendor-cookbooks/windows/resources/dns.rb | 29 - .../windows/resources/http_acl.rb | 109 --- .../windows/resources/schannel.rb | 39 - .../windows/resources/user_privilege.rb | 40 - vendor-cookbooks/windows/resources/zipfile.rb | 128 --- 70 files changed, 14 insertions(+), 5264 deletions(-) rename Berksfile => cookbooks/ros2_windows/Berksfile (55%) delete mode 100644 vendor-cookbooks/chocolatey/CHANGELOG.md delete mode 100644 vendor-cookbooks/chocolatey/README.md delete mode 100644 vendor-cookbooks/chocolatey/attributes/default.rb delete mode 100644 vendor-cookbooks/chocolatey/files/install.ps1 delete mode 100644 vendor-cookbooks/chocolatey/libraries/helpers.rb delete mode 100644 vendor-cookbooks/chocolatey/metadata.json delete mode 100644 vendor-cookbooks/chocolatey/recipes/default.rb delete mode 100644 vendor-cookbooks/ohai/CHANGELOG.md delete mode 100644 vendor-cookbooks/ohai/CONTRIBUTING.md delete mode 100644 vendor-cookbooks/ohai/README.md delete mode 100644 vendor-cookbooks/ohai/libraries/hint_helpers.rb delete mode 100644 vendor-cookbooks/ohai/libraries/plugin_helpers.rb delete mode 100644 vendor-cookbooks/ohai/metadata.json delete mode 100644 vendor-cookbooks/ohai/metadata.rb delete mode 100644 vendor-cookbooks/ohai/recipes/default.rb delete mode 100644 vendor-cookbooks/ohai/resources/hint.rb delete mode 100644 vendor-cookbooks/ohai/resources/plugin.rb delete mode 100644 vendor-cookbooks/seven_zip/.gitignore delete mode 100644 vendor-cookbooks/seven_zip/.kitchen.appveyor.yml delete mode 100644 vendor-cookbooks/seven_zip/.kitchen.yml delete mode 100644 vendor-cookbooks/seven_zip/.rspec delete mode 100644 vendor-cookbooks/seven_zip/.rubocop.yml delete mode 100644 vendor-cookbooks/seven_zip/Berksfile delete mode 100644 vendor-cookbooks/seven_zip/CHANGELOG.md delete mode 100644 vendor-cookbooks/seven_zip/Gemfile delete mode 100644 vendor-cookbooks/seven_zip/Gemfile.lock delete mode 100644 vendor-cookbooks/seven_zip/LICENSE delete mode 100644 vendor-cookbooks/seven_zip/README.md delete mode 100644 vendor-cookbooks/seven_zip/appveyor.yml delete mode 100644 vendor-cookbooks/seven_zip/attributes/default.rb delete mode 100644 vendor-cookbooks/seven_zip/chefignore delete mode 100644 vendor-cookbooks/seven_zip/libraries/matchers.rb delete mode 100644 vendor-cookbooks/seven_zip/metadata.json delete mode 100644 vendor-cookbooks/seven_zip/metadata.rb delete mode 100644 vendor-cookbooks/seven_zip/providers/archive.rb delete mode 100644 vendor-cookbooks/seven_zip/rakefile.rb delete mode 100644 vendor-cookbooks/seven_zip/recipes/default.rb delete mode 100644 vendor-cookbooks/seven_zip/resources/archive.rb delete mode 100644 vendor-cookbooks/seven_zip/resources/tool.rb delete mode 100644 vendor-cookbooks/seven_zip/spec/default_spec.rb delete mode 100644 vendor-cookbooks/seven_zip/spec/spec_helper.rb delete mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb delete mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb delete mode 100644 vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb delete mode 100644 vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb delete mode 100644 vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb delete mode 100644 vendor-cookbooks/windows/CHANGELOG.md delete mode 100644 vendor-cookbooks/windows/CONTRIBUTING.md delete mode 100644 vendor-cookbooks/windows/README.md delete mode 100644 vendor-cookbooks/windows/libraries/powershell_helper.rb delete mode 100644 vendor-cookbooks/windows/libraries/registry_helper.rb delete mode 100644 vendor-cookbooks/windows/libraries/version.rb delete mode 100644 vendor-cookbooks/windows/libraries/version_helper.rb delete mode 100644 vendor-cookbooks/windows/libraries/windows_helper.rb delete mode 100644 vendor-cookbooks/windows/libraries/windows_privileged.rb delete mode 100644 vendor-cookbooks/windows/libraries/wmi_helper.rb delete mode 100644 vendor-cookbooks/windows/metadata.json delete mode 100644 vendor-cookbooks/windows/metadata.rb delete mode 100644 vendor-cookbooks/windows/providers/dns.rb delete mode 100644 vendor-cookbooks/windows/recipes/default.rb delete mode 100644 vendor-cookbooks/windows/resources/certificate_binding.rb delete mode 100644 vendor-cookbooks/windows/resources/dns.rb delete mode 100644 vendor-cookbooks/windows/resources/http_acl.rb delete mode 100644 vendor-cookbooks/windows/resources/schannel.rb delete mode 100644 vendor-cookbooks/windows/resources/user_privilege.rb delete mode 100644 vendor-cookbooks/windows/resources/zipfile.rb diff --git a/Berksfile b/cookbooks/ros2_windows/Berksfile similarity index 55% rename from Berksfile rename to cookbooks/ros2_windows/Berksfile index 9e45f9d..60446bf 100644 --- a/Berksfile +++ b/cookbooks/ros2_windows/Berksfile @@ -1,7 +1,5 @@ # frozen_string_literal: true source 'https://supermarket.chef.io' +# Checks metadata.rb for dependencies metadata - -cookbook 'windows', '~> 7.0.0' -cookbook 'chocolatey', '2.0.1' diff --git a/cookbooks/ros2_windows/README.md b/cookbooks/ros2_windows/README.md index e9f46a9..05b3a85 100644 --- a/cookbooks/ros2_windows/README.md +++ b/cookbooks/ros2_windows/README.md @@ -28,6 +28,12 @@ This will open a GUI to input your github credentials > git clone https://github.com/ros-infrastructure/ros2-cookbooks ``` +Run `berks` to get the cookbook dependencies +``` +cd ros2-cookbooks/coobooks/ros2_windows +berks vendor .. +``` + Run chef-solo to configure machine. ``` > c:\cinc-project\cinc\bin\cinc-solo -c ros2-cookbooks\.chef\solo.rb -j ros2_windows.json diff --git a/cookbooks/ros2_windows/metadata.rb b/cookbooks/ros2_windows/metadata.rb index 6f0a400..58b6486 100644 --- a/cookbooks/ros2_windows/metadata.rb +++ b/cookbooks/ros2_windows/metadata.rb @@ -20,3 +20,4 @@ # source_url 'https://github.com/osrf/chef-osrf' depends 'chocolatey' depends 'seven_zip' +depend 'windows' diff --git a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb index 685b14b..8528e01 100644 --- a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb +++ b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb @@ -17,6 +17,11 @@ action :create end +remote_file 'bullet.nupkg' do + source 'https://github.com/ros2/choco-packages/releases/download/2020-02-24/bullet.2.89.0.nupkg' + action :create +end + remote_file 'cunit.nupkg' do source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/cunit.2.1.3.nupkg' action :create @@ -43,6 +48,6 @@ end chocolatey_package 'custom_packages' do - package_name ['asio', 'cunit', 'eigen', 'tinyxml-usestl', 'tinyxml2', 'log4cxx'] + package_name ['asio', 'bullet', 'cunit', 'eigen', 'tinyxml-usestl', 'tinyxml2', 'log4cxx'] source '.\\' end diff --git a/vendor-cookbooks/chocolatey/CHANGELOG.md b/vendor-cookbooks/chocolatey/CHANGELOG.md deleted file mode 100644 index 8323621..0000000 --- a/vendor-cookbooks/chocolatey/CHANGELOG.md +++ /dev/null @@ -1,110 +0,0 @@ -# Changelog for Chocolatey cookbook - -## v2.0.1 (2018-07-03) - -- Remove mentions of the package provider from the readme and metadata - -## v2.0.0 (2018-05-01) - -### Breaking Change - -The package LWRP has been removed from this cookbook. chocolatey_package was integrated into Chef 12.7, which was released in Feb 2016\. This cookbook now requires Chef 12.7 or later. - -### Other Changes - -- This cookbook no longer requires the Windows cookbook -- The install script has been updated to the latest Chocolatey install script -- Converted testing to use Delivery Local Mode from within ChefDK - -## v1.2.1 (2017-08-20) - -- Explicitly use the double-dash long option names for `--source` and `--installargs` - -## v1.2.0 (2017-05-04) - -- Change the default `['chocolatey']['upgrade']` attribute value to `false`. Preventing chocolatey from reinstalling every chef run - -## v1.1.1 (2017-04-22) - -- Fix chef 13 converges renaming conflicting `env_path` method - -## v1.1.0 (2017-01-09) - -- Update the chocolatey install script to match chocolatey.org. - -## v1.0.3 (2016-09-12) - -- Loosen windows-cookbook constraint - -## v1.0.2 (2016-08-29) - -- Ensure `chocolateyVersion` attribute is used and the correct version of chocolatey is installed. - -## v1.0.1 (2016-07-15) - -- Always execute chocolatey installer unless guard is satisfied to allow the install to retry on subsequent attempts if it fails. - -## v1.0.0 (2016-03-07) - -- No longer dependent on chocolatey.org for install script -- Removed deprecated overwriting of the current_resource and fixed visibility problem with `env_path` - -## v0.6.2 (2016-01-07) - -- Fix Chocolatey detection on chef clients older than 12.4.0 - -## v0.6.1 (2015-11-24) - -- Fix LocalJumpError on existing chocolatey package - -## v0.6.0 (2015-11-17) - -- Path Tracking. Tracking additions to the user and machine %PATH% environment and merging them into the current process. -- Downcase package name results from choco upgrade. - -## v0.5.1 (2015-11-10) - -- Prepend library include with :: in provder to fix 12.3.0 and likely other versions older than 12.5.1. -- Add backward compatibiliy to new metadata.rb attributes `source_url` and `issues_url`. - -## v0.5.0 (2015-11-09) - -- Refactored install script (and .kitchen.yml) to support installing Chocolatey in test-kitchen behind a proxy. -- Download `node['chocolatey']['Uri']` via `remote_file` resource instead of .net web client -- Set `chocolateyProxyLocation` environment variable to `Chef::Config['https_proxy']` if one is set before chocolatey install -- Changed helpers module namespacing from: `ChocolateyHelpers` to `Chocolatey::Helpers` -- Add ChefSpec unit tests -- Add ServerSpec integration tests -- Gemfile: bump foodcritic to 5.0 and Berkshelf to 4.0 -- Add ChefSpec matchers - -## v0.4.1 (2015-10-15) - -- Adds example how to install package with version -- use the vanilla script resource to bypass 64bit interpreter builder introduced in Chef 12.5 - -## v0.4.0 (2015-06-30) - -- Refactor script to download Chocolatey install script -- Chocolatey install: add proxy support -- fix for 64-bit chocolatey installs - -## v0.3.0 (2015-04-20) - -- Support for chocolatey >= 0.9.9 -- Make package name case insensitive - -## v0.2.0 (2014-09-24) - -- Allow spaces in the path to the "choco" command. -- Update tests to use Rakefile -- Support Chocolatey version 0.9.8.24+ -- Support custom command line options when installing packages - -## v0.1.0 (2014-02-20) - -- Fix and tests - -## v0.0.5 (2013-04-30) - -- Initial release diff --git a/vendor-cookbooks/chocolatey/README.md b/vendor-cookbooks/chocolatey/README.md deleted file mode 100644 index 12cb8d3..0000000 --- a/vendor-cookbooks/chocolatey/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# chocolatey Cookbook - -[![Cookbook Version](https://img.shields.io/cookbook/v/chocolatey.svg)](https://supermarket.getchef.com/cookbooks/chocolatey) [![Build Status](http://img.shields.io/travis/chocolatey/chocolatey-cookbook/master.svg)](https://travis-ci.org/chocolatey/chocolatey-cookbook) - -Install Chocolatey with the default recipe. - -## Requirements - -### Platform - -- Windows - -### Chef - -- 12.7 or greater - -## Notes - -As of Chocolatey version [0.9.8.24](https://github.com/chocolatey/chocolatey/blob/master/CHANGELOG.md#09824-july-3-2014) the install directory for Chocolatey has changed from `C:\Chocolatey` to `C:\ProgramData\Chocolatey`. - -More information can be gotten from the [Chocolateywiki](https://github.com/chocolatey/chocolatey/wiki/DefaultChocolateyInstallReasoning). - -## Attributes - -All attributes below are pre-pended with `node['chocolatey']` - -Attribute | Description | Type | Default ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------- -`['upgrade']` | Whether to upgrade Chocolatey if it's already installed | Boolean | false -`['install_vars']['chocolateyProxyLocation']` | HTTPS proxy for Chocolatey install script | String | Chef::Config['https_proxy'] or ENV['https_proxy'] -`['install_vars']['chocolateyProxyUser']` | Proxy user for authenticating proxies | String | nil -`['install_vars']['chocolateyProxyPassword']` | Proxy user password | String | nil -`['install_vars']['chocolateyVersion']` | Version of Chocolatey to install, e.g. '0.9.9.11' | String | nil (download latest version) -`['install_vars']['chocolateyDownloadUrl']` | Chocolatey .nupkg file URL. Use this if you host an internal copy of the chocolatey.nupkg | String | (download from chocolatey.org) -`['install_vars']['chocolateyUseWindowsCompression']`| To use built-in compression instead of 7zip (requires additional download) set to `true` | String | nil (use 7zip) - -## Recipes - -- `chocolatey::default` - installs Chocolatey - -## License and Maintainer - -Maintainer:: Guilhem Lettron ([guilhem@lettron.fr](mailto:guilhem@lettron.fr)) - -License:: Apache 2.0 diff --git a/vendor-cookbooks/chocolatey/attributes/default.rb b/vendor-cookbooks/chocolatey/attributes/default.rb deleted file mode 100644 index 9ff8005..0000000 --- a/vendor-cookbooks/chocolatey/attributes/default.rb +++ /dev/null @@ -1,11 +0,0 @@ -default['chocolatey']['upgrade'] = false - -# Chocolatey install.ps1 env vars. See https://chocolatey.org/install.ps1 -default['chocolatey']['install_vars'].tap do |env| - env['chocolateyProxyLocation'] = Chef::Config['https_proxy'] || ENV['https_proxy'] - env['chocolateyProxyUser'] = nil - env['chocolateyProxyPassword'] = nil - env['chocolateyVersion'] = nil - env['chocolateyDownloadUrl'] = 'https://chocolatey.org/api/v2/package/chocolatey' - env['chocolateyUseWindowsCompression'] = nil -end diff --git a/vendor-cookbooks/chocolatey/files/install.ps1 b/vendor-cookbooks/chocolatey/files/install.ps1 deleted file mode 100644 index 5e65268..0000000 --- a/vendor-cookbooks/chocolatey/files/install.ps1 +++ /dev/null @@ -1,345 +0,0 @@ -# ===================================================================== -# Copyright 2017 Chocolatey Software, Inc, and the -# original authors/contributors from ChocolateyGallery -# Copyright 2011 - 2017 RealDimensions Software, LLC, and the -# original authors/contributors from ChocolateyGallery -# at https://github.com/chocolatey/chocolatey.org -# -# 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. -# ===================================================================== - -# Environment Variables, specified as $env:NAME in PowerShell.exe and %NAME% in cmd.exe. -# For explicit proxy, please set $env:chocolateyProxyLocation and optionally $env:chocolateyProxyUser and $env:chocolateyProxyPassword -# For an explicit version of Chocolatey, please set $env:chocolateyVersion = 'versionnumber' -# To target a different url for chocolatey.nupkg, please set $env:chocolateyDownloadUrl = 'full url to nupkg file' -# NOTE: $env:chocolateyDownloadUrl does not work with $env:chocolateyVersion. -# To use built-in compression instead of 7zip (requires additional download), please set $env:chocolateyUseWindowsCompression = 'true' -# To bypass the use of any proxy, please set $env:chocolateyIgnoreProxy = 'true' - -#specifically use the API to get the latest version (below) -$url = '' - -$chocolateyVersion = $env:chocolateyVersion -if (![string]::IsNullOrEmpty($chocolateyVersion)){ - Write-Output "Downloading specific version of Chocolatey: $chocolateyVersion" - $url = "https://chocolatey.org/api/v2/package/chocolatey/$chocolateyVersion" -} - -$chocolateyDownloadUrl = $env:chocolateyDownloadUrl -if (![string]::IsNullOrEmpty($chocolateyDownloadUrl)){ - Write-Output "Downloading Chocolatey from : $chocolateyDownloadUrl" - $url = "$chocolateyDownloadUrl" -} - -if ($env:TEMP -eq $null) { - $env:TEMP = Join-Path $env:SystemDrive 'temp' -} -$chocTempDir = Join-Path $env:TEMP "chocolatey" -$tempDir = Join-Path $chocTempDir "chocInstall" -if (![System.IO.Directory]::Exists($tempDir)) {[void][System.IO.Directory]::CreateDirectory($tempDir)} -$file = Join-Path $tempDir "chocolatey.zip" - -# PowerShell v2/3 caches the output stream. Then it throws errors due -# to the FileStream not being what is expected. Fixes "The OS handle's -# position is not what FileStream expected. Do not use a handle -# simultaneously in one FileStream and in Win32 code or another -# FileStream." -function Fix-PowerShellOutputRedirectionBug { - $poshMajorVerion = $PSVersionTable.PSVersion.Major - - if ($poshMajorVerion -lt 4) { - try{ - # http://www.leeholmes.com/blog/2008/07/30/workaround-the-os-handles-position-is-not-what-filestream-expected/ plus comments - $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" - $objectRef = $host.GetType().GetField("externalHostRef", $bindingFlags).GetValue($host) - $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetProperty" - $consoleHost = $objectRef.GetType().GetProperty("Value", $bindingFlags).GetValue($objectRef, @()) - [void] $consoleHost.GetType().GetProperty("IsStandardOutputRedirected", $bindingFlags).GetValue($consoleHost, @()) - $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" - $field = $consoleHost.GetType().GetField("standardOutputWriter", $bindingFlags) - $field.SetValue($consoleHost, [Console]::Out) - [void] $consoleHost.GetType().GetProperty("IsStandardErrorRedirected", $bindingFlags).GetValue($consoleHost, @()) - $field2 = $consoleHost.GetType().GetField("standardErrorWriter", $bindingFlags) - $field2.SetValue($consoleHost, [Console]::Error) - } catch { - Write-Output "Unable to apply redirection fix." - } - } -} - -Fix-PowerShellOutputRedirectionBug - -# Attempt to set highest encryption available for SecurityProtocol. -# PowerShell will not set this by default (until maybe .NET 4.6.x). This -# will typically produce a message for PowerShell v2 (just an info -# message though) -try { - # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) - # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't - # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is - # installed (.NET 4.5 is an in-place upgrade). - [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 -} catch { - Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to do one or more of the following: (1) upgrade to .NET Framework 4.5+ and PowerShell v3, (2) specify internal Chocolatey package location (set $env:chocolateyDownloadUrl prior to install or host the package internally), (3) use the Download + PowerShell method of install. See https://chocolatey.org/install for all install options.' -} - -function Get-Downloader { -param ( - [string]$url - ) - - $downloader = new-object System.Net.WebClient - - $defaultCreds = [System.Net.CredentialCache]::DefaultCredentials - if ($defaultCreds -ne $null) { - $downloader.Credentials = $defaultCreds - } - - $ignoreProxy = $env:chocolateyIgnoreProxy - if ($ignoreProxy -ne $null -and $ignoreProxy -eq 'true') { - Write-Debug "Explicitly bypassing proxy due to user environment variable" - $downloader.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy() - } else { - # check if a proxy is required - $explicitProxy = $env:chocolateyProxyLocation - $explicitProxyUser = $env:chocolateyProxyUser - $explicitProxyPassword = $env:chocolateyProxyPassword - if ($explicitProxy -ne $null -and $explicitProxy -ne '') { - # explicit proxy - $proxy = New-Object System.Net.WebProxy($explicitProxy, $true) - if ($explicitProxyPassword -ne $null -and $explicitProxyPassword -ne '') { - $passwd = ConvertTo-SecureString $explicitProxyPassword -AsPlainText -Force - $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($explicitProxyUser, $passwd) - } - - Write-Debug "Using explicit proxy server '$explicitProxy'." - $downloader.Proxy = $proxy - - } elseif (!$downloader.Proxy.IsBypassed($url)) { - # system proxy (pass through) - $creds = $defaultCreds - if ($creds -eq $null) { - Write-Debug "Default credentials were null. Attempting backup method" - $cred = get-credential - $creds = $cred.GetNetworkCredential(); - } - - $proxyaddress = $downloader.Proxy.GetProxy($url).Authority - Write-Debug "Using system proxy server '$proxyaddress'." - $proxy = New-Object System.Net.WebProxy($proxyaddress) - $proxy.Credentials = $creds - $downloader.Proxy = $proxy - } - } - - return $downloader -} - -function Download-String { -param ( - [string]$url - ) - $downloader = Get-Downloader $url - - return $downloader.DownloadString($url) -} - -function Download-File { -param ( - [string]$url, - [string]$file - ) - #Write-Output "Downloading $url to $file" - $downloader = Get-Downloader $url - - $downloader.DownloadFile($url, $file) -} - -if ($url -eq $null -or $url -eq '') { - Write-Output "Getting latest version of the Chocolatey package for download." - $url = 'https://chocolatey.org/api/v2/Packages()?$filter=((Id%20eq%20%27chocolatey%27)%20and%20(not%20IsPrerelease))%20and%20IsLatestVersion' - [xml]$result = Download-String $url - $url = $result.feed.entry.content.src -} - -# Download the Chocolatey package - -Write-Output "Getting Chocolatey from $url." -Download-File $url $file - -# Determine unzipping method -# 7zip is the most compatible so use it by default -$7zaExe = Join-Path $tempDir '7za.exe' -$unzipMethod = '7zip' -$useWindowsCompression = $env:chocolateyUseWindowsCompression -if ($useWindowsCompression -ne $null -and $useWindowsCompression -eq 'true') { - Write-Output 'Using built-in compression to unzip' - $unzipMethod = 'builtin' -} elseif (-Not (Test-Path ($7zaExe))) { - Write-Output "Downloading 7-Zip commandline tool prior to extraction." - # download 7zip - Download-File 'https://chocolatey.org/7za.exe' "$7zaExe" -} - -#if ($useWindowsCompression -eq $null -or $windowsCompression -eq '') { -# Write-Output 'Using 7zip to unzip.' -# Write-Warning "The default is currently 7zip to better handle things like Server Core. This default will be changed to use built-in compression in December 2016. Please make sure if you need to use 7zip that you have adjusted your scripts to set `$env:chocolateyUseWindowsCompression = 'false' prior to calling the install." -# $unzipMethod = '7zip' -#} - -# unzip the package -Write-Output "Extracting $file to $tempDir..." -if ($unzipMethod -eq '7zip') { - $params = "x -o`"$tempDir`" -bd -y `"$file`"" - # use more robust Process as compared to Start-Process -Wait (which doesn't - # wait for the process to finish in PowerShell v3) - $process = New-Object System.Diagnostics.Process - $process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($7zaExe, $params) - $process.StartInfo.RedirectStandardOutput = $true - $process.StartInfo.UseShellExecute = $false - $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden - $process.Start() | Out-Null - $process.BeginOutputReadLine() - $process.WaitForExit() - $exitCode = $process.ExitCode - $process.Dispose() - - $errorMessage = "Unable to unzip package using 7zip. Perhaps try setting `$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:" - switch ($exitCode) { - 0 { break } - 1 { throw "$errorMessage Some files could not be extracted" } - 2 { throw "$errorMessage 7-Zip encountered a fatal error while extracting the files" } - 7 { throw "$errorMessage 7-Zip command line error" } - 8 { throw "$errorMessage 7-Zip out of memory" } - 255 { throw "$errorMessage Extraction cancelled by the user" } - default { throw "$errorMessage 7-Zip signalled an unknown error (code $exitCode)" } - } -} else { - if ($PSVersionTable.PSVersion.Major -lt 5) { - try { - $shellApplication = new-object -com shell.application - $zipPackage = $shellApplication.NameSpace($file) - $destinationFolder = $shellApplication.NameSpace($tempDir) - $destinationFolder.CopyHere($zipPackage.Items(),0x10) - } catch { - throw "Unable to unzip package using built-in compression. Set `$env:chocolateyUseWindowsCompression = 'false' and call install again to use 7zip to unzip. Error: `n $_" - } - } else { - Expand-Archive -Path "$file" -DestinationPath "$tempDir" -Force - } -} - -# Call chocolatey install -Write-Output "Installing chocolatey on this machine" -$toolsFolder = Join-Path $tempDir "tools" -$chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1" - -& $chocInstallPS1 - -Write-Output 'Ensuring chocolatey commands are on the path' -$chocInstallVariableName = "ChocolateyInstall" -$chocoPath = [Environment]::GetEnvironmentVariable($chocInstallVariableName) -if ($chocoPath -eq $null -or $chocoPath -eq '') { - $chocoPath = "$env:ALLUSERSPROFILE\Chocolatey" -} - -if (!(Test-Path ($chocoPath))) { - $chocoPath = "$env:SYSTEMDRIVE\ProgramData\Chocolatey" -} - -$chocoExePath = Join-Path $chocoPath 'bin' - -if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower()) -eq $false) { - $env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine); -} - -Write-Output 'Ensuring chocolatey.nupkg is in the lib folder' -$chocoPkgDir = Join-Path $chocoPath 'lib\chocolatey' -$nupkg = Join-Path $chocoPkgDir 'chocolatey.nupkg' -if (![System.IO.Directory]::Exists($chocoPkgDir)) { [System.IO.Directory]::CreateDirectory($chocoPkgDir); } -Copy-Item "$file" "$nupkg" -Force -ErrorAction SilentlyContinue - -# SIG # Begin signature block -# MIINVQYJKoZIhvcNAQcCoIINRjCCDUICAQExDzANBglghkgBZQMEAgEFADB5Bgor -# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBtI1XhNa+BTJDA -# Udd7cvDCY121zDB7LmEXLgQMpQmPnqCCCnIwggUwMIIEGKADAgECAhAECRgbX9W7 -# ZnVTQ7VvlVAIMA0GCSqGSIb3DQEBCwUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK -# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV -# BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0xMzEwMjIxMjAwMDBa -# Fw0yODEwMjIxMjAwMDBaMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2Vy -# dCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lD -# ZXJ0IFNIQTIgQXNzdXJlZCBJRCBDb2RlIFNpZ25pbmcgQ0EwggEiMA0GCSqGSIb3 -# DQEBAQUAA4IBDwAwggEKAoIBAQD407Mcfw4Rr2d3B9MLMUkZz9D7RZmxOttE9X/l -# qJ3bMtdx6nadBS63j/qSQ8Cl+YnUNxnXtqrwnIal2CWsDnkoOn7p0WfTxvspJ8fT -# eyOU5JEjlpB3gvmhhCNmElQzUHSxKCa7JGnCwlLyFGeKiUXULaGj6YgsIJWuHEqH -# CN8M9eJNYBi+qsSyrnAxZjNxPqxwoqvOf+l8y5Kh5TsxHM/q8grkV7tKtel05iv+ -# bMt+dDk2DZDv5LVOpKnqagqrhPOsZ061xPeM0SAlI+sIZD5SlsHyDxL0xY4PwaLo -# LFH3c7y9hbFig3NBggfkOItqcyDQD2RzPJ6fpjOp/RnfJZPRAgMBAAGjggHNMIIB -# yTASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjATBgNVHSUEDDAK -# BggrBgEFBQcDAzB5BggrBgEFBQcBAQRtMGswJAYIKwYBBQUHMAGGGGh0dHA6Ly9v -# Y3NwLmRpZ2ljZXJ0LmNvbTBDBggrBgEFBQcwAoY3aHR0cDovL2NhY2VydHMuZGln -# aWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJlZElEUm9vdENBLmNydDCBgQYDVR0fBHow -# eDA6oDigNoY0aHR0cDovL2NybDQuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJl -# ZElEUm9vdENBLmNybDA6oDigNoY0aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0Rp -# Z2lDZXJ0QXNzdXJlZElEUm9vdENBLmNybDBPBgNVHSAESDBGMDgGCmCGSAGG/WwA -# AgQwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzAK -# BghghkgBhv1sAzAdBgNVHQ4EFgQUWsS5eyoKo6XqcQPAYPkt9mV1DlgwHwYDVR0j -# BBgwFoAUReuir/SSy4IxLVGLp6chnfNtyA8wDQYJKoZIhvcNAQELBQADggEBAD7s -# DVoks/Mi0RXILHwlKXaoHV0cLToaxO8wYdd+C2D9wz0PxK+L/e8q3yBVN7Dh9tGS -# dQ9RtG6ljlriXiSBThCk7j9xjmMOE0ut119EefM2FAaK95xGTlz/kLEbBw6RFfu6 -# r7VRwo0kriTGxycqoSkoGjpxKAI8LpGjwCUR4pwUR6F6aGivm6dcIFzZcbEMj7uo -# +MUSaJ/PQMtARKUT8OZkDCUIQjKyNookAv4vcn4c10lFluhZHen6dGRrsutmQ9qz -# sIzV6Q3d9gEgzpkxYz0IGhizgZtPxpMQBvwHgfqL2vmCSfdibqFT+hKUGIUukpHq -# aGxEMrJmoecYpJpkUe8wggU6MIIEIqADAgECAhAGsBFbtfCQ0/DaDmIsYn1YMA0G -# CSqGSIb3DQEBCwUAMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJ -# bmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lDZXJ0 -# IFNIQTIgQXNzdXJlZCBJRCBDb2RlIFNpZ25pbmcgQ0EwHhcNMTcwMzI4MDAwMDAw -# WhcNMTgwNDAzMTIwMDAwWjB3MQswCQYDVQQGEwJVUzEPMA0GA1UECBMGS2Fuc2Fz -# MQ8wDQYDVQQHEwZUb3Bla2ExIjAgBgNVBAoTGUNob2NvbGF0ZXkgU29mdHdhcmUs -# IEluYy4xIjAgBgNVBAMTGUNob2NvbGF0ZXkgU29mdHdhcmUsIEluYy4wggEiMA0G -# CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLIWIaEiqkPbIMZi6jD6J8F3YIYPxG -# 3Vw2I8AsM5c63WUmV+bYZQGxY5AHHVFphy9mU6spXgAqVpzkcALjo1oArVscUU34 -# 8S4mokGbZVvHlO8ny1b1HzfR4ZPHpUL71btSqpcOElYOOL0wUnf5As/39VN+Wxef -# //D5KTDD17AA2DVvIaXMT+utERbo+c+leaPS4fKo/Q0KvpCt0sKr6LItAMNgaqL4 -# 9Z+Dg5n1oHjxAz4ZYhJYdHIPZPoqyeLQ8IuYiqCxKS07tkfvkwlgWxksHpliIKqf -# Jpv0YE2vqlZrcx0WYHNhgX3BIhQa21wxn/XAFNCpgrDgI0u0UupZfxAdAgMBAAGj -# ggHFMIIBwTAfBgNVHSMEGDAWgBRaxLl7KgqjpepxA8Bg+S32ZXUOWDAdBgNVHQ4E -# FgQUJqUaP1/S0OF1EG1dxC6UzM6w6T8wDgYDVR0PAQH/BAQDAgeAMBMGA1UdJQQM -# MAoGCCsGAQUFBwMDMHcGA1UdHwRwMG4wNaAzoDGGL2h0dHA6Ly9jcmwzLmRpZ2lj -# ZXJ0LmNvbS9zaGEyLWFzc3VyZWQtY3MtZzEuY3JsMDWgM6Axhi9odHRwOi8vY3Js -# NC5kaWdpY2VydC5jb20vc2hhMi1hc3N1cmVkLWNzLWcxLmNybDBMBgNVHSAERTBD -# MDcGCWCGSAGG/WwDATAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2Vy -# dC5jb20vQ1BTMAgGBmeBDAEEATCBhAYIKwYBBQUHAQEEeDB2MCQGCCsGAQUFBzAB -# hhhodHRwOi8vb2NzcC5kaWdpY2VydC5jb20wTgYIKwYBBQUHMAKGQmh0dHA6Ly9j -# YWNlcnRzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydFNIQTJBc3N1cmVkSURDb2RlU2ln -# bmluZ0NBLmNydDAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQCLBAE/ -# 2x4amEecDEoy9g+WmWMROiB4GnkPqj+IbiwftmwC5/7yL3/592HOFMJr0qOgUt51 -# moE8SuuLuOGw63c5+/48LJS4jP2XzbVNByRPIxPWorm4t/OzTJNziTowHQ+wLwwI -# 8U97+8DaHCNL7iLZNEiqbVlpF3j7SMWGgf2BVYADJyxluNzf0ZUO+lXN4gOkM8tl -# VDc7SjZEKvu6ckAaxXf7NPbCXVL/3+LvdmoLbT3vJlfzeXqduO3oieB10ic3ug5T -# XtoYmyEk/P3yR3x/TqUlg1x/xaolBxy5TyMeSLcBlYn42fnQL154bvMGwFiCsHWQ -# wY09I0xpEysOMiy8MYICOTCCAjUCAQEwgYYwcjELMAkGA1UEBhMCVVMxFTATBgNV -# BAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTExMC8G -# A1UEAxMoRGlnaUNlcnQgU0hBMiBBc3N1cmVkIElEIENvZGUgU2lnbmluZyBDQQIQ -# BrARW7XwkNPw2g5iLGJ9WDANBglghkgBZQMEAgEFAKCBhDAYBgorBgEEAYI3AgEM -# MQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQB -# gjcCAQsxDjAMBgorBgEEAYI3AgEVMC8GCSqGSIb3DQEJBDEiBCA30tiIkQr58z/E -# B7+e4qnBMyyqgtyBNCzS+4Lf0KDlwTANBgkqhkiG9w0BAQEFAASCAQB0y8X6HZlj -# VVxJY4s+6XYx/QM6a8KCe1oTwPt++jafTuOCZkv4LaFONT8jQO+ddPYhkeNv2D1v -# xjJu7oU2vsbwdHGdgOFdaCvjce+6j4FqJ6QvFT4CbIYgq5F+dJ6idy9i0f2Wa4N9 -# Ei8bJ2C5ruOwDbDtPeoGP5+H4ehHqHKY1ubVXdm5nOKrB0XRxroUykAZbzho7OHv -# UZ3uA7RX0CvDJ78hEAn5Zg3MsMB1e7B3B5m9DKbPTa/k6q65uVDDNZE66GEyzQ04 -# lqUJK2K9SNM7MmSJkCga40y02t0OTR8w+V8Ev4GPL47Ubu3fLetknY2Z5r+b1+eu -# camDGbsbstoG -# SIG # End signature block diff --git a/vendor-cookbooks/chocolatey/libraries/helpers.rb b/vendor-cookbooks/chocolatey/libraries/helpers.rb deleted file mode 100644 index 1d4b36c..0000000 --- a/vendor-cookbooks/chocolatey/libraries/helpers.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Chocolatey - module Helpers - # include the PowershellOut module from the windows cookbook - # in case we are running an older chef client - include Chef::Mixin::PowershellOut - - # Get the ChocolateyInstall directory from the environment. - def chocolatey_install - ENV.fetch('ChocolateyInstall') { |env_var| machine_env_var(env_var) } - end - - # The Chocolatey command. - # - # Reference: https://github.com/chocolatey/chocolatey-cookbook/pull/16#issuecomment-47975896 - def chocolatey_executable - "\"#{::File.join(chocolatey_install, 'bin', 'choco')}\"" - end - - def chocolatey_lib_dir - File.join(chocolatey_install, 'lib', 'chocolatey') - end - - # Check if Chocolatey is installed - def chocolatey_installed? - return @is_chocolatey_installed if @is_chocolatey_installed - return false if chocolatey_install.nil? - # choco /? returns an exit status of -1 with chocolatey 0.9.9 => use list - cmd = Mixlib::ShellOut.new("#{chocolatey_executable} list -l chocolatey") - cmd.run_command - @is_chocolatey_installed = cmd.exitstatus == 0 - end - - # combine the local path with the user and machine paths - def environment_path(local_path) - machine = env_var('PATH', 'MACHINE').split(';') - user = env_var('PATH', 'USER').split(';') - local = local_path.split(';') - combined = local.concat(machine).concat(user).uniq.compact - combined.join(';') - end - - private - - def machine_env_var(env_var) - env_var(env_var, 'MACHINE') - end - - def env_var(env_var, scope) - env_var = powershell_out!( - "[System.Environment]::GetEnvironmentVariable('#{env_var}', '#{scope}')" - ) - env_var.stdout.chomp - end - end -end diff --git a/vendor-cookbooks/chocolatey/metadata.json b/vendor-cookbooks/chocolatey/metadata.json deleted file mode 100644 index fec3ac0..0000000 --- a/vendor-cookbooks/chocolatey/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"chocolatey","version":"2.0.1","description":"Install Chocolatey on Windows","long_description":"Installs the Chocolatey package manager for Windows.","maintainer":"Guilhem Lettron","maintainer_email":"guilhem.lettron@youscribe.com","license":"Apache-2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chocolatey/chocolatey-cookbook","issues_url":"https://github.com/chocolatey/chocolatey-cookbook/issues","chef_version":[[">= 12.7"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/chocolatey/recipes/default.rb b/vendor-cookbooks/chocolatey/recipes/default.rb deleted file mode 100644 index 4593360..0000000 --- a/vendor-cookbooks/chocolatey/recipes/default.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Cookbook Name:: chocolatey -# recipe:: default -# Author:: Guilhem Lettron -# -# Copyright 2012, Societe Publica. -# Copyright 2015, Doug Ireton -# -# 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. -# -unless platform_family?('windows') - return "Chocolatey install not supported on #{node['platform_family']}" -end - -Chef::Resource.send(:include, Chocolatey::Helpers) - -install_ps1 = File.join(Chef::Config['file_cache_path'], 'chocolatey-install.ps1') - -cookbook_file install_ps1 do - action :create - backup false - source 'install.ps1' -end - -powershell_script 'Install Chocolatey' do - environment node['chocolatey']['install_vars'] - cwd Chef::Config['file_cache_path'] - code install_ps1 - not_if { chocolatey_installed? && (node['chocolatey']['upgrade'] == false) } -end diff --git a/vendor-cookbooks/ohai/CHANGELOG.md b/vendor-cookbooks/ohai/CHANGELOG.md deleted file mode 100644 index f0caadb..0000000 --- a/vendor-cookbooks/ohai/CHANGELOG.md +++ /dev/null @@ -1,205 +0,0 @@ -# ohai Cookbook CHANGELOG - -This file is used to list changes made in each version of the ohai cookbook. - -## 5.3.0 (2019-08-29) - -- Add code owners file - [@tas50](https://github.com/tas50) -- Cookstyle fixes - [@tas50](https://github.com/tas50) -- Require Chef 13 or later - [@tas50](https://github.com/tas50) -- Remove the long_description metadata - [@tas50](https://github.com/tas50) -- Add the load_single_plugin option to the ohai_plugin resource - [@MarkGibbons](https://github.com/MarkGibbons) -- Update for Chef 15 license agreement and Chef Workstation - [@tas50](https://github.com/tas50) -- Update the platforms we test on in Travis / Test Kitchen - [@tas50](https://github.com/tas50) - -## 5.2.5 (2018-09-04) - -- Add note that ohai_hint will be removed April 2019 when Chef 13 goes EOL as this resource now ships in Chef 14+ - -## 5.2.4 (2018-08-28) - -- Avoid deprecation warnings in Chef 14.3+ by not loading resources already in Chef - -## 5.2.3 (2018-06-08) - -- Make sure we properly compare a provided plugin path to the path on disk by stripping trailing slashes from the provided directory -- Don't reload ohai when the plugin exists in a subdirectory of the config's set plugin path - -## 5.2.2 (2018-02-15) - -- Remove ChefSpec matchers we no longer need since they're auto generated - -## 5.2.1 (2018-01-25) - -- Switch from a .foodcritic file to an inline comments which resolve Supermarket warnings -- Remove unused helper method - -## 5.2.0 (2017-08-17) - -- Resolve multiple issues with Windows paths that caused the cookbook to converge on every run or fail -- Move maintainer information to the readme -- Add testing on Chef 12.7 in Travis -- Move helpers to their own modules and add testing framework - -## 5.1.0 (2017-05-06) - -- Workaround action_class bug by requiring Chef 12.7+ - -## 5.0.4 (2017-04-25) - -- Fix lack of .rb extension when deleting plugins. - -## 5.0.3 (2017-04-06) - -- Use class_eval again in the custom resource to provide Chef 12.5/12.6 compatibility -- Remove kind_of and use name_property not name_attribute -- Fix failures on Chef 13 - -## 5.0.2 (2017-03-24) - -- Remove class_eval - -## 5.0.1 (2017-03-14) - -- Test with Delivery Local Mode -- Bump the dependency to 12.7+ due to failures on 12.5-12.6 - -## 5.0.0 (2017-02-23) - -- Require Chef 12.5+ and remove compat_resource dependency - -## 4.2.3 (2016-12-02) -- Prevent chef_version metadata from failing runs in Opsworks -- Better explain how to resolve the plugin_path issue -- Add suse as a supported platform -- Require at least compat_resource 12.14.7 - -## 4.2.2 (2016-09-19) -- Ignore case in plugin path check on Windows - -## 4.2.1 (2016-09-08) -- Fix typo in compile warning text -- Depend on the latest compat_resource (12.14) -- Remove Chef 11 compat in the metadata -- Require Chef 12.1 not 12.0 -- Define ohai_plugin matcher for Chefspec - -## v4.2.0 (2016-07-19) - -- Added the ability to specify the source cookbook for the cookbook_file or template used in the ohai_plugin resource. -- Added chef_version to the metadata -- Added testing on openSUSE and switched from Rubocop to Cookstyle - -## v4.1.1 (2016-06-16) - -- Fixed error in notifies reload for the delete action -- Bump the compat_resource requirement from 12.9+ to 12.10+ to prevent random failures - -## v4.1.0 (2016-05-26) - -- Added the ability to use templates and pass in variables with the plugin custom resource - -## v4.0.2 (2016-05-23) - -- Resolve failures on Windows nodes - -## v4.0.1 (2016-05-19) - -- Added .rb to the name of the plugins so they actually load -- Added testing to ensure the plugins are being loaded in the chef run - -## v4.0.0 (2016-05-18) - -### BREAKING CHANGE: - -The 4.0 release of the Ohai cookbook removes the previous cookbook_file behavior that required forking the cookbook and adding your own plugins. Instead the cookbook ships with a new ohai_plugin custom resource for installing plugins. In addition to this new custom resource the cookbook now requires Chef 12+. See the readme and test recipe for examples. If you require Chef 11 support you'll need to pin to version 3.0 in your environment. - -## v3.0.1 (2016-03-14) - -- Fixed the Chefspec matchers - -## v3.0.0 (2016-03-14) - -- Change the default value for `node['ohai']['hints_path']` to use the Ohai config value. This should be the same value in most use cases, but if a custom path is specified in the chef client config this value will get used automatically by the cookbook. -- Removed backwards compatibility with Chefspec < 4.1 in the matchers library -- Fix bad link to the custom Ohai plugin documentation in the readme -- Improve documentation for `node['ohai']['plugin_path']` - -## v2.1.0 (2016-01-26) - -- Properly handle creating ohai hints without specifying the content. Previously if the content wasn't specified a deprecation notice would be thrown and the file would not be created -- Simplified the test suite and added inspec tests to ensure hints are created, especially if the content is not specified -- Added FreeBSD and Windows as supported platform in the metadata and add them to the Test Kitchen config -- Add Test Kitchen integration tests to Travis CI -- Updated testing Gems to the latest releases in the Gemfile - -## v2.0.4 (2015-10-30) - -- Resolved deprecation warnings with the Chefspec matchers - -## v2.0.3 (2015-10-21) - -- Validate the hints before loading them to avoid failures -- Added supported platforms to the metadata -- Updated .gitignore file -- Updated Test Kitchen config for the latest platforms -- Added Chef standard Rubocop config -- Added Travis CI testing -- Added Berksfile -- Updated contributing and testing docs -- Added maintainers.md and maintainers.toml files -- Added Travis and cookbook version badges to the readme -- Expanded the requirements section in the readme and clarify the minimum supported Chef release is 11 -- Updated Opscode -> Chef Software -- Added a Rakefile for simplified testing -- Added a Chefignore file -- Resolved Rubocop warnings -- Added source_url and issues_url to the metadata -- Added Chefspec matchers -- Added basic convergence Chefspec test - -## v2.0.1 (2014-06-07) - -- [COOK-4683] Remove warnings about reopening resource - -Please note, this changes the name of a remote_directory resource. It is not expected that anyone would be explicitly notifying this resource but, please review [PR #16](https://github.com/chef-cookbooks/ohai/pull/16/files) for more info. - -## v2.0.0 (2014-02-25) - -'[COOK-3865] - create lwrp ohai_hint' - -## v1.1.12 - -- Dummy release due to a Community Site upload failure - -## v1.1.10 - -### Bug - -- **[COOK-3091](https://tickets.chef.io/browse/COOK-3091)** - Fix checking `Chef::Config[:config_file]` - -## v1.1.8 - -- [COOK-1918] - Ohai cookbook to distribute plugins fails on windows -- [COOK-2096] - Ohai cookbook sets unix-only default path attribute - -## v1.1.6 - -- [COOK-2057] - distribution from another cookbok fails if ohai attributes are loaded after the other cookbook - -## v1.1.4 - -- [COOK-1128] - readme update, Replace reference to deprecated chef cookbook with one to chef-client - -## v1.1.2 - -- [COOK-1424] - prevent plugin_path growth to infinity - -## v1.1.0 - -- [COOK-1174] - custom_plugins is only conditionally available -- [COOK-1383] - allow plugins from other cookbooks - -## v1.0.2 - -- [COOK-463] ohai cookbook default recipe should only reload plugins if there were updates diff --git a/vendor-cookbooks/ohai/CONTRIBUTING.md b/vendor-cookbooks/ohai/CONTRIBUTING.md deleted file mode 100644 index ef2f2b8..0000000 --- a/vendor-cookbooks/ohai/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/ohai/README.md b/vendor-cookbooks/ohai/README.md deleted file mode 100644 index 0c061a7..0000000 --- a/vendor-cookbooks/ohai/README.md +++ /dev/null @@ -1,139 +0,0 @@ -# ohai Cookbook - -[![Build Status](https://travis-ci.org/chef-cookbooks/ohai.svg?branch=master)](https://travis-ci.org/chef-cookbooks/ohai) [![Build status](https://ci.appveyor.com/api/projects/status/lgok2kr6l007s8hf/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/ohai/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/ohai.svg)](https://supermarket.chef.io/cookbooks/ohai) - -Contains custom resources for adding Ohai hints and installing custom Ohai plugins. Handles path creation as well as the reloading of Ohai so that new data will be available during the same run. - -NOTE: The ohai_hint resource shipped in Chef 14.0 (April 2018). When Chef 15.0 is released (April 2019) and Chef 13 goes EOL the ohai_hint resource will be removed from this cookbook. - -## Requirements - -### Platforms - -- Debian/Ubuntu -- RHEL/CentOS/Scientific/Amazon/Oracle -- openSUSE / SUSE Enterprise Linux -- FreeBSD -- Windows - -### Chef - -- Chef 12.7+ - -### Cookbooks - -- none - -## Custom Resources - -### `ohai_hint` - -Creates Ohai hint files, which are consumed by Ohai plugins in order to determine if they should run or not. - -#### Resource Properties - -- `hint_name` - The name of hints file and key. Should be string, default is name of resource. -- `content` - Values of hints. It will be used as automatic attributes. Should be Hash, default is empty Hash -- `compile_time` - Should the resource run at compile time. This defaults to true - -#### Examples - -Hint file installed to the default directory: - -```ruby -ohai_hint 'ec2' -``` - -Hint file not installed at compile time: - -```ruby -ohai_hint 'ec2' do - compile_time false -end -``` - -Hint file installed with content: - -```ruby -ohai_hint 'raid_present' do - content Hash[:a, 'test_content'] -end -``` - -#### ChefSpec Matchers - -You can check for the creation or deletion of ohai hints with chefspec using these custom matches: - -- create_ohai_hint -- delete_ohai_hint - -### `ohai_plugin` - -Installs custom Ohai plugins. - -#### Resource Properties - -- `plugin_name` - The name to give the plugin on the filesystem. Should be string, default is name of resource. -- `path` - The path to your custom plugin directory. Defaults to a directory named 'plugins' under the directory 'ohai' in the Chef config dir. -- `source_file` - The source file for the plugin in your cookbook if not NAME.rb. -- `cookbook` - The cookbook where the source file exists if not the cookbook where the ohai_plugin resource is running from. -- `resource` - The resource type for the plugin file. Either `:cookbook_file` or `:template`. Defaults to `:cookbook_file`. -- `variables` - Usable only if `resource` is `:template`. Defines the template's variables. -- `compile_time` - Should the resource run at compile time. This defaults to `true`. -- `load_single_plugin` - Reload all plugins unless this value is set to true. Load only the named plugin. - -#### examples - -Simple Ohai plugin installation: - -```ruby -ohai_plugin 'my_custom_plugin' -``` - -Installation where the resource doesn't match the filename and you install to a custom plugins dir: - -```ruby -ohai_plugin 'My Ohai Plugin' do - name 'my_custom_plugin' - path '/my/custom/path/' -end -``` - -Installation using a template: - -```ruby -ohai_plugin 'My Templated Plugin' do - name 'templated_plugin' - resource :template - variables node_type: :web_server -end -``` - -#### ChefSpec Matchers - -You can check for the creation or deletion of ohai plugins with chefspec using these custom matches: - -- create_ohai_plugin -- delete_ohai_plugin - -## Maintainers - -This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/) - -## License - -**Copyright:** 2011-2016, Chef Software, Inc. - -``` -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. -``` diff --git a/vendor-cookbooks/ohai/libraries/hint_helpers.rb b/vendor-cookbooks/ohai/libraries/hint_helpers.rb deleted file mode 100644 index a0e58ba..0000000 --- a/vendor-cookbooks/ohai/libraries/hint_helpers.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# Cookbook:: ohai -# Library:: hint_helpers -# -# Author:: Tim Smith () -# -# Copyright:: 2017, Chef Software, Inc. -# -# 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. -# - -module OhaiCookbook - module HintHelpers - def ohai_hint_file_path(filename) - path = ::File.join(::Ohai::Config.ohai.hints_path.first, filename) - path << '.json' unless path.end_with?('.json') - path - end - - def format_content(content) - return '' if content.nil? || content.empty? - JSON.pretty_generate(content) - end - end -end diff --git a/vendor-cookbooks/ohai/libraries/plugin_helpers.rb b/vendor-cookbooks/ohai/libraries/plugin_helpers.rb deleted file mode 100644 index 218d550..0000000 --- a/vendor-cookbooks/ohai/libraries/plugin_helpers.rb +++ /dev/null @@ -1,77 +0,0 @@ -# -# Cookbook:: ohai -# Library:: plugin_helpers -# -# Author:: Tim Smith () -# -# Copyright:: 2017-2018, Chef Software, Inc. -# -# 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. -# - -module OhaiCookbook - module PluginHelpers - # return the path property if specified or - # CHEF_CONFIG_PATH/ohai/plugins if a path isn't specified - def desired_plugin_path - if new_resource.path - new_resource.path.chomp('/') # if the user gave us /foo/bar/ we need /foo/bar for later comparison - else - ::File.join(chef_config_path, 'ohai', 'plugins') - end - end - - # return the chef config files dir or fail hard - def chef_config_path - if Chef::Config['config_file'] - ::File.dirname(Chef::Config['config_file']) - else - Chef::Application.fatal!("No chef config file defined. Are you running \ - chef-solo? If so you will need to define a path for the ohai_plugin as the \ - path cannot be determined") - end - end - - # is the desired plugin dir in the ohai config plugin dir array? - def in_plugin_path?(path) - normalized_path = normalize_path(path) - # get the directory where we plan to stick the plugin (not the actual file path) - desired_dir = ::File.directory?(normalized_path) ? normalized_path : ::File.dirname(normalized_path) - ::Ohai::Config.ohai['plugin_path'].map { |x| normalize_path(x) }.any? do |d| - desired_dir.start_with?(d) - end - end - - # return path to lower and with forward slashes so we can compare it - # this works around the 3 different way we can represent windows paths - def normalize_path(path) - path.downcase.gsub(/\\+/, '/') - end - - def add_to_plugin_path(path) - ::Ohai::Config.ohai['plugin_path'] << path # new format - end - - # we need to warn the user that unless the path for this plugin is in Ohai's - # plugin path already we're going to have to reload Ohai on every Chef run. - # Ideally in future versions of Ohai /etc/chef/ohai/plugins is in the path. - def plugin_path_warning - Chef::Log.warn("The Ohai plugin_path does not include #{desired_plugin_path}. \ -Ohai will reload on each chef-client run in order to add this directory to the \ -path unless you modify your client.rb configuration to add this directory to \ -plugin_path. The plugin_path can be set via the chef-client::config recipe. \ -See 'Ohai Settings' at https://docs.chef.io/config_rb_client.html#ohai-settings \ -for more details.") - end - end -end diff --git a/vendor-cookbooks/ohai/metadata.json b/vendor-cookbooks/ohai/metadata.json deleted file mode 100644 index 627ba01..0000000 --- a/vendor-cookbooks/ohai/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"ohai","version":"5.3.0","description":"Provides custom resources for installing Ohai hints and plugins","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0","centos":">= 0.0.0","redhat":">= 0.0.0","amazon":">= 0.0.0","scientific":">= 0.0.0","fedora":">= 0.0.0","oracle":">= 0.0.0","suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","freebsd":">= 0.0.0","windows":">= 0.0.0","zlinux":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/ohai","issues_url":"https://github.com/chef-cookbooks/ohai/issues","chef_version":[[">= 13"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/ohai/metadata.rb b/vendor-cookbooks/ohai/metadata.rb deleted file mode 100644 index d1450d3..0000000 --- a/vendor-cookbooks/ohai/metadata.rb +++ /dev/null @@ -1,15 +0,0 @@ -name 'ohai' -maintainer 'Chef Software, Inc.' -maintainer_email 'cookbooks@chef.io' -license 'Apache-2.0' -description 'Provides custom resources for installing Ohai hints and plugins' - -version '5.3.0' - -%w(ubuntu debian centos redhat amazon scientific fedora oracle suse opensuse opensuseleap freebsd windows zlinux).each do |os| - supports os -end - -source_url 'https://github.com/chef-cookbooks/ohai' -issues_url 'https://github.com/chef-cookbooks/ohai/issues' -chef_version '>= 13' diff --git a/vendor-cookbooks/ohai/recipes/default.rb b/vendor-cookbooks/ohai/recipes/default.rb deleted file mode 100644 index 6f83639..0000000 --- a/vendor-cookbooks/ohai/recipes/default.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Cookbook:: ohai -# Recipe:: default -# -# Copyright:: 2011-2017, Chef Software, Inc -# -# 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. -# - -Chef::Log.warn('The Ohai cookbook default recipe has no content as of the 4.0 release. See the readme for instructions on using the custom resources.') diff --git a/vendor-cookbooks/ohai/resources/hint.rb b/vendor-cookbooks/ohai/resources/hint.rb deleted file mode 100644 index c11d245..0000000 --- a/vendor-cookbooks/ohai/resources/hint.rb +++ /dev/null @@ -1,41 +0,0 @@ -chef_version_for_provides '< 14.0' if respond_to?(:chef_version_for_provides) -resource_name :ohai_hint - -property :hint_name, String, name_property: true -property :content, Hash -property :compile_time, [true, false], default: true - -action :create do - directory ::Ohai::Config.ohai.hints_path.first do - action :create - recursive true - end - - file ohai_hint_file_path(new_resource.hint_name) do - action :create - content format_content(new_resource.content) - end -end - -action :delete do - file ohai_hint_file_path(new_resource.hint_name) do # ~FC009 - action :delete - notifies :reload, ohai[reload ohai post hint removal] - end - - ohai 'reload ohai post hint removal' do - action :nothing - end -end - -action_class do - include OhaiCookbook::HintHelpers -end - -# this resource forces itself to run at compile_time -def after_created - return unless compile_time - Array(action).each do |action| - run_action(action) - end -end diff --git a/vendor-cookbooks/ohai/resources/plugin.rb b/vendor-cookbooks/ohai/resources/plugin.rb deleted file mode 100644 index 46cdd8a..0000000 --- a/vendor-cookbooks/ohai/resources/plugin.rb +++ /dev/null @@ -1,71 +0,0 @@ -property :plugin_name, String, name_property: true -property :path, String -property :source_file, String -property :cookbook, String -property :resource, [:cookbook_file, :template], default: :cookbook_file -property :variables, Hash -property :compile_time, [true, false], default: true -property :load_single_plugin, [true, false], default: false - -action :create do - # why create_if_missing you ask? - # no one can agree on perms and this allows them to manage the perms elsewhere - directory desired_plugin_path do - action :create - recursive true - not_if { ::File.exist?(desired_plugin_path) } - end - - if new_resource.resource.eql?(:cookbook_file) - cookbook_file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do - cookbook new_resource.cookbook - source new_resource.source_file || "#{new_resource.plugin_name}.rb" - notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately - end - elsif new_resource.resource.eql?(:template) - template ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do - cookbook new_resource.cookbook - source new_resource.source_file || "#{new_resource.plugin_name}.rb" - variables new_resource.variables - notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately - end - end - - # Add the plugin path to the ohai plugin path if need be and warn - # the user that this is going to result in a reload every run - unless in_plugin_path?(desired_plugin_path) - plugin_path_warning - Chef::Log.warn("Adding #{desired_plugin_path} to the Ohai plugin path for this chef-client run only") - add_to_plugin_path(desired_plugin_path) - reload_required = true - end - - ohai new_resource.plugin_name do - action :nothing - action :reload if reload_required - plugin new_resource.plugin_name if new_resource.load_single_plugin - end -end - -action :delete do - file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do - action :delete - notifies :reload, 'ohai[reload ohai post plugin removal]' - end - - ohai 'reload ohai post plugin removal' do - action :nothing - end -end - -action_class do - include OhaiCookbook::PluginHelpers -end - -# this resource forces itself to run at compile_time -def after_created - return unless compile_time - Array(action).each do |action| - run_action(action) - end -end diff --git a/vendor-cookbooks/seven_zip/.gitignore b/vendor-cookbooks/seven_zip/.gitignore deleted file mode 100644 index 6a9bd26..0000000 --- a/vendor-cookbooks/seven_zip/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -*# -*.un~ -*~ -.#* -.*.sw[a-z] -.vagrant -/cache/ -/cookbooks -\#*# -version.txt - -# Bundler -bin/* -.bundle/* -.vendor/* - -# Test Kitchen -.kitchen.local.yml -.kitchen/ -.kitchen/* -Berksfile.lock - -#IntelliJ IDEA -.idea -.idea/ -.idea/* diff --git a/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml b/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml deleted file mode 100644 index b1eba2e..0000000 --- a/vendor-cookbooks/seven_zip/.kitchen.appveyor.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -driver: - name: proxy - host: localhost - reset_command: "exit 0" - port: 5985 - username: <%= ENV["machine_user"] %> - password: <%= ENV["machine_pass"] %> - elevated: false - elevated_username: <%= ENV["machine_user"] %> - elevated_password: <%= ENV["machine_pass"] %> - require_chef_omnibus: 13.8.5 - -provisioner: - name: chef_zero - -platforms: - - name: windows-2012R2 - driver: - box: mwrock/Windows2012R2 - -suites: - - name: default - run_list: - - recipe[test_archive] diff --git a/vendor-cookbooks/seven_zip/.kitchen.yml b/vendor-cookbooks/seven_zip/.kitchen.yml deleted file mode 100644 index 5018fa5..0000000 --- a/vendor-cookbooks/seven_zip/.kitchen.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -driver: - name: vagrant - provider: virtualbox - gui: true - username: vagrant - password: vagrant - elevated: false - elevated_username: vagrant - elevated_password: vagrant - require_chef_omnibus: 13.8.5 - -provisioner: - name: chef_zero - product_name: chef - product_version: 13.8.5 - -platforms: - - name: windows-2012R2 - transport: - name: winrm - driver: - box: mwrock/Windows2012R2 - -suites: - - name: default - run_list: - - recipe[test_archive] diff --git a/vendor-cookbooks/seven_zip/.rspec b/vendor-cookbooks/seven_zip/.rspec deleted file mode 100644 index 2559e39..0000000 --- a/vendor-cookbooks/seven_zip/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format progress ---require spec_helper diff --git a/vendor-cookbooks/seven_zip/.rubocop.yml b/vendor-cookbooks/seven_zip/.rubocop.yml deleted file mode 100644 index f4acc5c..0000000 --- a/vendor-cookbooks/seven_zip/.rubocop.yml +++ /dev/null @@ -1,16 +0,0 @@ -AllCops: - Exclude: - - 'Berksfile' - -Style/Encoding: - Enabled: true - -# Multiline block chains are needed for ChefSpec stubbing of libraries -Style/MultilineBlockChain: - Enabled: false - -Metrics/LineLength: - Max: 120 - -Metrics/AbcSize: - Max: 25 diff --git a/vendor-cookbooks/seven_zip/Berksfile b/vendor-cookbooks/seven_zip/Berksfile deleted file mode 100644 index 376e212..0000000 --- a/vendor-cookbooks/seven_zip/Berksfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://supermarket.chef.io' - -metadata - -group :integration do - cookbook 'test_archive', path: 'test/fixtures/cookbooks/test_archive' -end diff --git a/vendor-cookbooks/seven_zip/CHANGELOG.md b/vendor-cookbooks/seven_zip/CHANGELOG.md deleted file mode 100644 index 5466593..0000000 --- a/vendor-cookbooks/seven_zip/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# CHANGELOG for seven_zip - -This file is used to list changes made in each version of seven_zip. - -## 3.1.2 -* Update nokogiri from 1.8.2 to 1.8.5 (https://snyk.io/vuln/SNYK-RUBY-NOKOGIRI-72433) - -## 3.1.1 -* Fix deprecation warning regarding the use of win_friendly_path helper. - -## 3.1.0 - -* Having a simple resource to setup 7-zip allows other resources (since including a recipe inside a resource is not a good pattern) to use it to ensure that their prerequisites are installed before-hand. -* This resource leverage existing attributes as default values to keep backward compatibility. -* The seven_zip::default recipe's code has been refactored to just use this resource. - -## 3.0.0 - -* Support Chef 13, drop support for Chef 12. -* Upgrade to 7-Zip 18.05. -* Standardize testing environment across repos. (AppVeyor, Kitchen, Rake, etc.) -* Upgrade development dependencies. - -## 2.0.2 - -* Add timeout to extract action on seven\_zip resource and configurable default\_extract_timeout attribute. - -## 2.0.1 - -* [GH Issue 21 - NoMethodError: Undefined method or attribute `kernel' on `node'](https://github.com/daptiv/seven_zip/issues/21). - -## 2.0.0 - -* [Upgrade to 7-Zip 15.14](https://github.com/daptiv/seven_zip/pull/9). -* [7-Zip now installed to the default MSI location by default](https://github.com/daptiv/seven_zip/pull/11). -* [7z.exe is located using the Windows registry unless the home attribute is explicitly set](https://github.com/daptiv/seven_zip/pull/10). -* [7-Zip is only added to the Windows PATH if the syspath attribute is set](https://github.com/daptiv/seven_zip/pull/11). -* [Installation idempotence check was fixed](https://github.com/daptiv/seven_zip/pull/14), package name was corrected. -* [TravisCI build added](https://github.com/daptiv/seven_zip/pull/12). -* [ServerSpec tests added](https://github.com/daptiv/seven_zip/pull/9) -* [Document Archive LRWP](https://github.com/daptiv/seven_zip/pull/6) - -## 1.0.2 - -* [COOK-3476 - Upgrade to 7-zip 9.22](https://tickets.opscode.com/browse/COOK-3476) - -## 1.0.0 - -* initial release - -- - - -Refer to the [Markdown Syntax Guide](https://daringfireball.net/projects/markdown/syntax) for help with standard Markdown, and [Writing on GitHub](https://help.github.com/categories/writing-on-github/) for help with the GitHub dialect of Markdown. diff --git a/vendor-cookbooks/seven_zip/Gemfile b/vendor-cookbooks/seven_zip/Gemfile deleted file mode 100644 index b6ba658..0000000 --- a/vendor-cookbooks/seven_zip/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source 'http://rubygems.org' - -gem 'cookstyle' -gem 'foodcritic' -gem 'rspec-expectations' -gem 'rspec-mocks' -gem 'rubocop' -gem 'stove' diff --git a/vendor-cookbooks/seven_zip/Gemfile.lock b/vendor-cookbooks/seven_zip/Gemfile.lock deleted file mode 100644 index 877a1e3..0000000 --- a/vendor-cookbooks/seven_zip/Gemfile.lock +++ /dev/null @@ -1,79 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - ast (2.4.0) - backports (3.11.3) - chef-api (0.8.0) - logify (~> 0.1) - mime-types - cookstyle (3.0.0) - rubocop (= 0.55.0) - cucumber-core (3.1.0) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (>= 5.0.0) - cucumber-tag_expressions (1.1.1) - diff-lcs (1.3) - erubis (2.7.0) - ffi-yajl (2.3.1) - libyajl2 (~> 1.2) - foodcritic (13.1.1) - cucumber-core (>= 1.3) - erubis - ffi-yajl (~> 2.0) - nokogiri (>= 1.5, < 2.0) - rake - rufus-lru (~> 1.0) - treetop (~> 1.4) - gherkin (5.0.0) - libyajl2 (1.2.0) - logify (0.2.0) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_portile2 (2.4.0) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) - parallel (1.12.1) - parser (2.5.1.0) - ast (~> 2.4.0) - polyglot (0.3.5) - powerpack (0.1.1) - rainbow (3.0.0) - rake (13.0.1) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubocop (0.55.0) - parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - rufus-lru (1.1.0) - stove (6.0.0) - chef-api (~> 0.5) - logify (~> 0.2) - treetop (1.6.10) - polyglot (~> 0.3) - unicode-display_width (1.3.2) - -PLATFORMS - ruby - -DEPENDENCIES - cookstyle - foodcritic - rspec-expectations - rspec-mocks - rubocop - stove - -BUNDLED WITH - 1.16.1 diff --git a/vendor-cookbooks/seven_zip/LICENSE b/vendor-cookbooks/seven_zip/LICENSE deleted file mode 100644 index 11069ed..0000000 --- a/vendor-cookbooks/seven_zip/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -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. diff --git a/vendor-cookbooks/seven_zip/README.md b/vendor-cookbooks/seven_zip/README.md deleted file mode 100644 index 7e04831..0000000 --- a/vendor-cookbooks/seven_zip/README.md +++ /dev/null @@ -1,114 +0,0 @@ -[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip) -[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master) - -# seven_zip Cookbook -[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-Zip suite of tools (GUI and CLI). This cookbook replaces the older [7-Zip cookbook](https://github.com/sneal/7-zip). - -# Requirements -## Platforms -- Windows XP -- Windows Vista -- Windows 7 -- Windows 8, 8.1 -- Windows 10 -- Windows Server 2003 R2 -- Windows Server 2008 (R1, R2) -- Windows Server 2012 (R1, R2) - -## Chef -- Chef >= 13.0 - -## Cookbooks -- windows - -# Attributes -## Optional - -| Key | Type | Description | Default | -|-----|------|-------------|---------| -| `['seven_zip']['home']` | String | 7-Zip installation directory. | | -| `['seven_zip']['syspath']` | Boolean | If true, adds 7-Zip directory to system PATH environment variable. | | -| `['seven_zip']['default_extract_timeout']` | Integer | The default timeout for an extract operation in seconds. This can be overridden by a resource attribute. | `600` | - -# Usage -## default - -Add `seven_zip::default` to your run\_list which will download and install 7-Zip for the current Windows platform. - -# Resource/Provider -## seven_zip_archive -Extracts a 7-Zip compatible archive (iso, zip, 7z, etc.) to the specified destination directory. - -#### Actions -- `:extract` - Extract a 7-Zip compatible archive. - -#### Attribute Parameters -- `path` - Name attribute. The destination to extract to. -- `source` - The file path to the archive to extract. -- `overwrite` - Defaults to false. If true, the destination files will be overwritten. -- `checksum` - The archive file checksum. -- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`. - -#### Examples -Extract 7-Zip source files to `C:\seven_zip_source`. - -```ruby -seven_zip_archive 'seven_zip_source' do - path 'C:\seven_zip_source' - source 'https://www.7-zip.org/a/7z1805-src.7z' - overwrite true - checksum 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83' - timeout 30 -end -``` - -## seven_zip_tool -Download and install 7-zip for the current Windows platform. - -#### Actions -- `:install` - Installs 7-zip -- `:add_to_path` - Add 7-zip to the PATH - -#### Attribute Parameters -- `package` - The name of the package. -- `path` - The install directory of 7-zip. -- `source` - The source URL of the 7-zip package. -- `checksum` - The 7-zip package checksum. - -#### Examples -Install 7-zip in `C:\7z` and add it to the path. - -```ruby -seven_zip_tool '7z 15.14 install' do - action [:install, :add_to_path] - package '7-Zip 15.14' - path 'C:\7z' - source 'http://www.7-zip.org/a/7z1514.msi' - checksum 'eaf58e29941d8ca95045946949d75d9b5455fac167df979a7f8e4a6bf2d39680' -end -``` - -# Recipes -## default - -Installs 7-Zip and adds it to your system PATH. - -# License & Authors -- Author:: Seth Chisamore () -- Author:: Shawn Neal () - -```text -Copyright:: 2011-2016, Chef Software, Inc. - -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. -``` diff --git a/vendor-cookbooks/seven_zip/appveyor.yml b/vendor-cookbooks/seven_zip/appveyor.yml deleted file mode 100644 index 321b270..0000000 --- a/vendor-cookbooks/seven_zip/appveyor.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: "3.1.1.{build}-{branch}" - -image: Visual Studio 2013 -platform: x64 - -environment: - machine_user: vagrant - machine_pass: vagrant - KITCHEN_YAML: .kitchen.appveyor.yml - -branches: - only: - - master - -# Do not build on tags (GitHub only) -skip_tags: true - -#faster cloning -clone_depth: 1 - -install: - - ps: (& cmd /c); iex (irm https://omnitruck.chef.io/install.ps1); Install-Project -Project chefdk -channel stable -version 3.10.1 - - ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version' - - ps: $PSVersionTable - - c:\opscode\chefdk\bin\chef.bat exec ruby --version - - ps: secedit /export /cfg $env:temp/export.cfg - - ps: ((get-content $env:temp/export.cfg) -replace ('PasswordComplexity = 1', 'PasswordComplexity = 0')) | Out-File $env:temp/export.cfg - - ps: ((get-content $env:temp/export.cfg) -replace ('MinimumPasswordLength = 8', 'MinimumPasswordLength = 0')) | Out-File $env:temp/export.cfg - - ps: secedit /configure /db $env:windir/security/new.sdb /cfg $env:temp/export.cfg /areas SECURITYPOLICY - - ps: net user /add $env:machine_user $env:machine_pass - - ps: net localgroup administrators $env:machine_user /add - -build_script: - - ps: c:\opscode\chefdk\bin\chef.bat shell-init powershell | iex; cmd /c c:\opscode\chefdk\bin\chef.bat --version - -test_script: - - c:\opscode\chefdk\bin\cookstyle --version - - c:\opscode\chefdk\bin\chef.bat exec foodcritic --version - - c:\opscode\chefdk\bin\chef.bat exec rake - - c:\opscode\chefdk\bin\chef.bat exec kitchen verify - -deploy: off diff --git a/vendor-cookbooks/seven_zip/attributes/default.rb b/vendor-cookbooks/seven_zip/attributes/default.rb deleted file mode 100644 index 443a28b..0000000 --- a/vendor-cookbooks/seven_zip/attributes/default.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: seven_zip -# Attribute:: default -# -# Copyright:: 2011-2017, Chef Software, Inc. -# -# 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. -# - -if node['kernel']['machine'] == 'x86_64' - default['seven_zip']['url'] = 'https://www.7-zip.org/a/7z1805-x64.msi' - default['seven_zip']['checksum'] = '898c1ca0015183fe2ba7d55cacf0a1dea35e873bf3f8090f362a6288c6ef08d7' - default['seven_zip']['package_name'] = '7-Zip 18.05 (x64 edition)' -else - default['seven_zip']['url'] = 'https://www.7-zip.org/a/7z1805.msi' - default['seven_zip']['checksum'] = 'c554238bee18a03d736525e06d9258c9ecf7f64ead7c6b0d1eb04db2c0de30d0' - default['seven_zip']['package_name'] = '7-Zip 18.05' -end - -default['seven_zip']['default_extract_timeout'] = 600 diff --git a/vendor-cookbooks/seven_zip/chefignore b/vendor-cookbooks/seven_zip/chefignore deleted file mode 100644 index 9c2bd55..0000000 --- a/vendor-cookbooks/seven_zip/chefignore +++ /dev/null @@ -1,98 +0,0 @@ -# OS generated files # -###################### -.DS_Store -Icon? -nohup.out -ehthumbs.db -Thumbs.db - -# SASS # -######## -.sass-cache - -# EDITORS # -########### -\#* -.#* -*~ -*.sw[a-z] -*.bak -REVISION -TAGS* -tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log - -## COMPILED ## -############## -a.out -*.o -*.pyc -*.so -*.com -*.class -*.dll -*.exe -*/rdoc/ - -# Testing # -########### -.watchr -.rspec -spec/* -spec/fixtures/* -test/* -features/* -examples/* -Guardfile -Procfile -.kitchen* -.rubocop.yml -spec/* -Rakefile -.travis.yml -.foodcritic -.codeclimate.yml - -# SCM # -####### -.git -*/.git -.gitignore -.gitmodules -.gitconfig -.gitattributes -.svn -*/.bzr/* -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Cookbooks # -############# -CONTRIBUTING* -CHANGELOG* -TESTING* -MAINTAINERS.toml - -# Strainer # -############ -Colanderfile -Strainerfile -.colander -.strainer - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/vendor-cookbooks/seven_zip/libraries/matchers.rb b/vendor-cookbooks/seven_zip/libraries/matchers.rb deleted file mode 100644 index 6dd4dca..0000000 --- a/vendor-cookbooks/seven_zip/libraries/matchers.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# Author:: Shawn Neal () -# Cookbook:: visualstudio -# -# Copyright:: 2015-2017, Shawn Neal -# -# 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. -# - -if defined?(ChefSpec) - chefspec_version = Gem.loaded_specs['chefspec'].version - define_method = if chefspec_version < Gem::Version.new('4.1.0') - ChefSpec::Runner.method(:define_runner_method) - else - ChefSpec.method(:define_matcher) - end - - define_method.call :seven_zip_archive - - def extract_seven_zip_archive(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:seven_zip_archive, :extract, resource_name) - end -end diff --git a/vendor-cookbooks/seven_zip/metadata.json b/vendor-cookbooks/seven_zip/metadata.json deleted file mode 100644 index 523109a..0000000 --- a/vendor-cookbooks/seven_zip/metadata.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "seven_zip", - "description": "Installs/Configures 7-Zip", - "long_description": "[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip)\n[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master)\n\n# seven_zip Cookbook\n[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-Zip suite of tools (GUI and CLI). This cookbook replaces the older [7-Zip cookbook](https://github.com/sneal/7-zip).\n\n# Requirements\n## Platforms\n- Windows XP\n- Windows Vista\n- Windows 7\n- Windows 8, 8.1\n- Windows 10\n- Windows Server 2003 R2\n- Windows Server 2008 (R1, R2)\n- Windows Server 2012 (R1, R2)\n\n## Chef\n- Chef >= 13.0\n\n## Cookbooks\n- windows\n\n# Attributes\n## Optional\n\n| Key | Type | Description | Default |\n|-----|------|-------------|---------|\n| `['seven_zip']['home']` | String | 7-Zip installation directory. | |\n| `['seven_zip']['syspath']` | Boolean | If true, adds 7-Zip directory to system PATH environment variable. | |\n| `['seven_zip']['default_extract_timeout']` | Integer | The default timeout for an extract operation in seconds. This can be overridden by a resource attribute. | `600` |\n\n# Usage\n## default\n\nAdd `seven_zip::default` to your run\\_list which will download and install 7-Zip for the current Windows platform.\n\n# Resource/Provider\n## seven_zip_archive\nExtracts a 7-Zip compatible archive (iso, zip, 7z, etc.) to the specified destination directory.\n\n#### Actions\n- `:extract` - Extract a 7-Zip compatible archive.\n\n#### Attribute Parameters\n- `path` - Name attribute. The destination to extract to.\n- `source` - The file path to the archive to extract.\n- `overwrite` - Defaults to false. If true, the destination files will be overwritten.\n- `checksum` - The archive file checksum.\n- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`.\n\n#### Examples\nExtract 7-Zip source files to `C:\\seven_zip_source`.\n\n```ruby\nseven_zip_archive 'seven_zip_source' do\n path 'C:\\seven_zip_source'\n source 'https://www.7-zip.org/a/7z1805-src.7z'\n overwrite true\n checksum 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83'\n timeout 30\nend\n```\n\n## seven_zip_tool\nDownload and install 7-zip for the current Windows platform.\n\n#### Actions\n- `:install` - Installs 7-zip\n- `:add_to_path` - Add 7-zip to the PATH\n\n#### Attribute Parameters\n- `package` - The name of the package.\n- `path` - The install directory of 7-zip.\n- `source` - The source URL of the 7-zip package.\n- `checksum` - The 7-zip package checksum.\n\n#### Examples\nInstall 7-zip in `C:\\7z` and add it to the path.\n\n```ruby\nseven_zip_tool '7z 15.14 install' do\n action [:install, :add_to_path]\n package '7-Zip 15.14'\n path 'C:\\7z'\n source 'http://www.7-zip.org/a/7z1514.msi'\n checksum 'eaf58e29941d8ca95045946949d75d9b5455fac167df979a7f8e4a6bf2d39680'\nend\n```\n\n# Recipes\n## default\n\nInstalls 7-Zip and adds it to your system PATH.\n\n# License & Authors\n- Author:: Seth Chisamore ()\n- Author:: Shawn Neal ()\n\n```text\nCopyright:: 2011-2016, Chef Software, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n", - "maintainer": "Shawn Neal", - "maintainer_email": "sneal@sneal.net", - "license": "Apache-2.0", - "platforms": { - "windows": ">= 0.0.0" - }, - "dependencies": { - "windows": ">= 0.0.0" - }, - "providing": { - - }, - "recipes": { - - }, - "version": "3.1.2", - "source_url": "https://github.com/windowschefcookbooks/seven_zip", - "issues_url": "https://github.com/windowschefcookbooks/seven_zip/issues", - "privacy": false, - "chef_versions": [ - [ - ">= 13.0" - ] - ], - "ohai_versions": [ - - ], - "gems": [ - - ] -} diff --git a/vendor-cookbooks/seven_zip/metadata.rb b/vendor-cookbooks/seven_zip/metadata.rb deleted file mode 100644 index 67cf09b..0000000 --- a/vendor-cookbooks/seven_zip/metadata.rb +++ /dev/null @@ -1,12 +0,0 @@ -name 'seven_zip' -maintainer 'Shawn Neal' -maintainer_email 'sneal@sneal.net' -source_url 'https://github.com/windowschefcookbooks/seven_zip' -issues_url 'https://github.com/windowschefcookbooks/seven_zip/issues' -chef_version '>= 13.0' if respond_to?(:chef_version) -license 'Apache-2.0' -description 'Installs/Configures 7-Zip' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '3.1.2' -supports 'windows' -depends 'windows' diff --git a/vendor-cookbooks/seven_zip/providers/archive.rb b/vendor-cookbooks/seven_zip/providers/archive.rb deleted file mode 100644 index c935569..0000000 --- a/vendor-cookbooks/seven_zip/providers/archive.rb +++ /dev/null @@ -1,64 +0,0 @@ -# -# Author:: Shawn Neal () -# Cookbook:: seven_zip -# Provider:: archive -# -# Copyright:: 2013-2017, Daptiv Solutions LLC -# -# 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. -# - -require 'fileutils' -require 'chef/mixin/shell_out' -require 'chef/util/path_helper' - -include Chef::Mixin::ShellOut -include Windows::Helper - -def whyrun_supported? - true -end - -action :extract do - converge_by("Extract #{@new_resource.source} => #{@new_resource.path} (overwrite=#{@new_resource.overwrite})") do - FileUtils.mkdir_p(@new_resource.path) unless Dir.exist?(@new_resource.path) - local_source = cached_file(@new_resource.source, @new_resource.checksum) - overwrite_file = @new_resource.overwrite ? ' -y' : ' -aos' - cmd = "\"#{seven_zip_exe}\" x" - cmd << overwrite_file - cmd << " -o\"#{Chef::Util::PathHelper.cleanpath(@new_resource.path)}\"" - cmd << " \"#{local_source}\"" - Chef::Log.debug(cmd) - shell_out!(cmd, timeout: extract_timeout) - end -end - -def seven_zip_exe - path = node['seven_zip']['home'] || seven_zip_exe_from_registry - Chef::Log.debug("Using 7-zip home: #{path}") - Chef::Util::PathHelper.cleanpath(::File.join(path, '7z.exe')) -end - -def seven_zip_exe_from_registry - require 'win32/registry' - # Read path from recommended Windows App Paths registry location - # docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 - ::Win32::Registry::HKEY_LOCAL_MACHINE.open( - 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe', - ::Win32::Registry::KEY_READ - ).read_s('Path') -end - -def extract_timeout - @new_resource.timeout || node['seven_zip']['default_extract_timeout'] -end diff --git a/vendor-cookbooks/seven_zip/rakefile.rb b/vendor-cookbooks/seven_zip/rakefile.rb deleted file mode 100644 index 6eab0cc..0000000 --- a/vendor-cookbooks/seven_zip/rakefile.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'cookstyle' -require 'foodcritic' -require 'rspec/core/rake_task' -require 'rubocop/rake_task' - -task default: [:rubocop, :foodcritic, :spec] - -FoodCritic::Rake::LintTask.new do |t| - t.options = { - cookbook_paths: '.', - search_gems: true, - } -end - -RSpec::Core::RakeTask.new do |task| - task.pattern = 'spec/**/*_spec.rb' - task.rspec_opts = ['--color', '-f documentation', '-tunit'] -end - -RuboCop::RakeTask.new - -begin - require 'stove/rake_task' - Stove::RakeTask.new -rescue LoadError => e - puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] -end diff --git a/vendor-cookbooks/seven_zip/recipes/default.rb b/vendor-cookbooks/seven_zip/recipes/default.rb deleted file mode 100644 index b013889..0000000 --- a/vendor-cookbooks/seven_zip/recipes/default.rb +++ /dev/null @@ -1,24 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: seven_zip -# Recipe:: default -# -# Copyright:: 2011-2017, Chef Software, Inc. -# -# 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. -# - -# Install 7z and optionally add it to path -seven_zip_tool 'install seven_zip' do - action [:install, :add_to_path] if node['seven_zip']['syspath'] -end diff --git a/vendor-cookbooks/seven_zip/resources/archive.rb b/vendor-cookbooks/seven_zip/resources/archive.rb deleted file mode 100644 index 5558f14..0000000 --- a/vendor-cookbooks/seven_zip/resources/archive.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Author:: Shawn Neal () -# Cookbook:: seven_zip -# Resource:: archive -# -# Copyright:: 2013-2017, Daptiv Solutions LLC -# -# 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. -# - -default_action :extract - -actions :extract - -attribute :path, kind_of: String, name_attribute: true -attribute :source, kind_of: String -attribute :overwrite, kind_of: [TrueClass, FalseClass], default: false -attribute :checksum, kind_of: String -attribute :timeout, kind_of: Integer diff --git a/vendor-cookbooks/seven_zip/resources/tool.rb b/vendor-cookbooks/seven_zip/resources/tool.rb deleted file mode 100644 index 4e27965..0000000 --- a/vendor-cookbooks/seven_zip/resources/tool.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# Author:: Annih () -# Cookbook:: seven_zip -# Resource:: tool -# -# Copyright:: 2018, Baptiste Courtois -# -# 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. -# -property :package, ::String, default: lazy { node['seven_zip']['package_name'] } -property :source, ::String, default: lazy { node['seven_zip']['url'] } -property :checksum, [::NilClass, ::String], default: lazy { node['seven_zip']['checksum'] } -property :path, [::NilClass, ::String], default: lazy { node['seven_zip']['home'] } - -action :install do - windows_package new_resource.package do - action :install - source new_resource.source - checksum new_resource.checksum unless new_resource.checksum.nil? - options "INSTALLDIR=\"#{new_resource.path}\"" unless new_resource.path.nil? - end -end - -action :add_to_path do - windows_path 'seven_zip' do - action :add - path new_resource.path || registry_path - end -end - -action_class do - REG_PATH = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe'.freeze - - def registry_path - ::Win32::Registry::HKEY_LOCAL_MACHINE.open(REG_PATH, ::Win32::Registry::KEY_READ).read_s('Path') - end -end diff --git a/vendor-cookbooks/seven_zip/spec/default_spec.rb b/vendor-cookbooks/seven_zip/spec/default_spec.rb deleted file mode 100644 index e2bb248..0000000 --- a/vendor-cookbooks/seven_zip/spec/default_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -describe 'seven_zip::default' do - context 'with defaults' do - let(:chef_run) do - ChefSpec::ServerRunner.new(step_into: 'seven_zip_tool').converge(described_recipe) - end - it 'installs seven_zip package' do - expect(chef_run).to install_windows_package '7-Zip 18.05 (x64 edition)' - end - it 'updates the path to include seven_zip' do - expect(chef_run).to_not add_windows_path('seven_zip').with(path: 'C:\\\\7-zip') - end - end - context 'with syspath' do - let(:chef_run) do - ChefSpec::ServerRunner.new(step_into: 'seven_zip_tool') do |node| - node.override['seven_zip']['syspath'] = true - node.override['seven_zip']['home'] = 'C:\\\\7-zip' - end.converge(described_recipe) - end - it 'installs seven_zip package' do - expect(chef_run).to install_windows_package '7-Zip 18.05 (x64 edition)' - end - it 'updates the path to include seven_zip' do - expect(chef_run).to add_windows_path('seven_zip').with(path: 'C:\\\\7-zip') - end - end -end diff --git a/vendor-cookbooks/seven_zip/spec/spec_helper.rb b/vendor-cookbooks/seven_zip/spec/spec_helper.rb deleted file mode 100644 index efb35f2..0000000 --- a/vendor-cookbooks/seven_zip/spec/spec_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rspec/expectations' -require 'chefspec' -require 'chefspec/berkshelf' - -RSpec.configure do |config| - config.run_all_when_everything_filtered = true - config.filter_run :focus - config.order = 'random' - config.platform = 'windows' - config.version = '2012R2' - ENV['ProgramFiles(x86)'] = 'C:\Program Files (x86)' # assume 64bit OS - ENV['ProgramFiles'] = 'C:\Program Files' - ENV['WINDIR'] = 'C:\Windows' - ENV['SYSTEMDRIVE'] = 'C:\\' -end diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb deleted file mode 100644 index 41b0706..0000000 --- a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/attributes/default.rb +++ /dev/null @@ -1,3 +0,0 @@ -default['test_archive']['source'] = 'https://www.7-zip.org/a/7z1805-src.7z' -default['test_archive']['overwrite'] = true -default['test_archive']['checksum'] = 'd9acfcbbdcad078435586e00f73909358ed8d714d106e064dcba52fa73e75d83' diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb deleted file mode 100644 index 893a7eb..0000000 --- a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/metadata.rb +++ /dev/null @@ -1,3 +0,0 @@ -name 'test_archive' -version '1.0.0' -depends 'seven_zip' diff --git a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb b/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb deleted file mode 100644 index d17f4f4..0000000 --- a/vendor-cookbooks/seven_zip/test/fixtures/cookbooks/test_archive/recipes/default.rb +++ /dev/null @@ -1,17 +0,0 @@ -# This recipe is for testing the seven_zip archive provider -include_recipe 'seven_zip' - -seven_zip_archive 'test_archive' do - path 'C:\seven_zip_source' - source node['test_archive']['source'] - overwrite node['test_archive']['overwrite'] - checksum node['test_archive']['checksum'] - timeout 30 -end - -seven_zip_archive 'extract_with_spaces' do - path 'C:\Program Files\seven_zip_source' - source node['test_archive']['source'] - overwrite node['test_archive']['overwrite'] - checksum node['test_archive']['checksum'] -end diff --git a/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb b/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb deleted file mode 100644 index f01aa14..0000000 --- a/vendor-cookbooks/seven_zip/test/integration/default/serverspec/default_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe package('7-zip 18.05 (x64 edition)') do - it 'is installed' do - expect(subject).to be_installed - end -end - -describe file('C:\seven_zip_source') do - it 'is a directory' do - expect(subject).to be_directory - end - - it 'should contain only extracted files' do - expect(Dir.entries(subject.name).sort).to eq %w(. .. Asm C CPP DOC) - end -end - -describe file('C:\Program Files\seven_zip_source') do - it 'is a directory' do - expect(subject).to be_directory - end - - it 'should contain only extracted files' do - expect(Dir.entries(subject.name).sort).to eq %w(. .. Asm C CPP DOC) - end -end diff --git a/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb b/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb deleted file mode 100644 index 4a32b7d..0000000 --- a/vendor-cookbooks/seven_zip/test/integration/helpers/serverspec/spec_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'serverspec' - -set :backend, :cmd -set :os, family: 'windows' diff --git a/vendor-cookbooks/windows/CHANGELOG.md b/vendor-cookbooks/windows/CHANGELOG.md deleted file mode 100644 index bda8148..0000000 --- a/vendor-cookbooks/windows/CHANGELOG.md +++ /dev/null @@ -1,870 +0,0 @@ -# windows Cookbook CHANGELOG - -This file is used to list changes made in each version of the windows cookbook. - -## 7.0.0 (2020-03-26) - -### Breaking Changes - -- This cookbook now requires Chef Infra Client 14.7 and later as it no longer includes the `windows_share` and `windows_certificate` resources that are now built into Chef Infra Client. - -### Other Changes - -- Remove list of actions in the dns resource - [@tas50](https://github.com/tas50) -- Don't set the guard_interpreter in powershell_script - [@tas50](https://github.com/tas50) -- Add windows_schannel resource (#619) - [@Xorima](https://github.com/Xorima) -- Remove desired_state: true from resources - [@tas50](https://github.com/tas50) -- The host_name property in the dns resource doesn't need to be a name property - [@tas50](https://github.com/tas50) -- Remove unnecessary include of the powershell mixin - [@tas50](https://github.com/tas50) - -## Unreleased - -- Added windows_schannel to configure schannel (tls settings for dotnet apps and powershell) - -## 6.0.1 (2019-10-01) - -- Update README.md for Windows cookbook suggesting core dns resources (#616) - [@NAshwini](https://github.com/NAshwini) -- Add a warning when using windows_zipfile resource as users should migrate to archive_file (#617) - [@NAshwini](https://github.com/NAshwini) - -## 6.0.0 (2019-04-25) - -### Breaking Changes - -- This cookbook now requires Chef 14 or later. As of April 2019 Chef 13 is EOL. If you are still running Chef 13 we highly suggest you begin your migration. Chef 14 provides a greatly improved Windows experience with built in resources for Windows clients. -- Resources that are built into Chef 14 and later have been removed from this cookbook: - - windows_auto_run - - windows_feature - - windows_font - - windows_pagefile - - windows_printer_port - - windows_printer - - windows_shortcut - -## 5.3.1 (2019-04-25) - -- Resolved failures on Chef 14.11 or later -- Removed OS detectio support in the helpers for Windows 2003 - -## 5.3.0 (2019-03-06) - -- Expanded certificate testing to cover more scenarios - [@Xorima](https://github.com/Xorima) -- Updated windows_share to better compare the current and desired path in order to prevent converging on each Chef run - [@Xorima](https://github.com/Xorima) -- Backported all windows_certificate fixes from Chef 14.8 - 14.11 including improvements to importing the types of certificates that can be imported, suppport for nested certs, and support for importing private keys with certs. - -## 5.2.4 (2019-02-28) - -- Fix http_acl regex to properly capture SDDL - [@Annih](https://github.com/Annih) -- Updated windows_share to create share if the share is deleted, and to sanitize paths using Chef::Util::PathHelper.cleanpath (#607) - [@Xorima](https://github.com/Xorima) - -## 5.3.3 (2019-01-30) - -- Updated windows_certificate code to match that in Chef 14.10. This increases the requirement of the win32_certstore gem to the latest and resolves multiple issues with the previous implementation. - -## 5.2.2 (2018-11-20) - -- windows_share: Accounts to be revoked should be provided as an individually quoted string array - -## 5.2.1 (2018-11-19) - -- windows_share: Fix idempotency by not adding everyone by default - -## 5.2.0 (2018-11-14) - -- Support installing deleted features in windows_feature_dism - -## 5.1.6 (2018-11-13) - -- Add a warning to the readme regarding windows_share and windows_certificate now being included in Chef 14.7 -- Deprecated win_friendly_path helper in favor of built-in helpers - -## 5.1.5 (2018-11-07) - -- Avoid deprecation warnings in windows_share and windows_certificate on Chef 14.7+ as these are now included in the chef-client itself. - -## 5.1.4 (2018-10-30) - -- Note the :verify action for windows_certificate in the readme -- certificate resource: auto set sensitive is passing password - -## 5.1.3 (2018-10-11) - -- Remove docs and test suite for windows tasks -- Changed variable name in log message for retrieving SMB share access -- Don't load the windows helper in windows_certificate - -## 5.1.2 (2018-10-08) - -- Fix typo in windows_feature_dism resource name - -## 5.1.1 (2018-09-06) - -- Require the win32-certstore gem and upgrade the gem as the resource runs so we get the most up to date version -- Remove redundant helper methods from the windows_certificate resource - -## 5.1.0 (2018-08-29) - -- Add an action to windows_user_privilege to remove a privilege -- Fix failing appveyor tests -- Require win32-certstore 0.1.8 which resolves several issues with the windows_certificate resource -- Avoid deprecation warnings with Chef 14.3+ by not loading resources that are now built into Chef - -## 5.0.0 (2018-07-24) - -### Breaking Changes - -This release removes the windows_task and windows_path resources from this cookbook. This resources shipped in Chef 13.0 and 13.4 This raises the required version of chef-client for this cookbook to 13.4 or later. - -## 4.3.4 (2018-07-18) - -- Fix error message typo in windows_feature_powershell -- Use win32-certstore 0.1.7 for bugfixes - -## 4.3.3 (2018-07-05) - -- Fix failures on PS 3.0 in windows_feature_powershell - -## 4.3.2 (2018-06-13) - -- Don't error in windows_feature_dism when providing a source - -## 4.3.1 (2018-06-11) - -- Make sure to quote each individual user to grant share access to - -## 4.3.0 (2018-06-11) - -- Add the windows_user_privilege resource which can grant privileges like Logon As a Service -- Add windows_feature_powershell support for Windows 2008 R2 by not downcasing the feature names there and modifying the shell_out commands to make older output look like the 2012+ output -- windows_certificate resource has been reworked to use the new win32-certstore gem. This gem abstracts away much of the logic and will allow us to better support certificates on Windows, especially on non-english systems. -- Convert pester tests to InSpec for easier testing with ChefDK out of the box -- Added additional tests for better testing in AppVeyor -- Stop importing the servermanager module in windows_feature_powershell since we require PowerShell 3.0 and we don't need to do this there -- Improve the error messages in Windows feature to get the Windows versions right -- Increase readability in version logic with helpers in windows_feature resources - -## 4.2.5 (2018-05-28) - -- Add quoting to Path when creating new Share - -## 4.2.4 (2018-05-14) - -- Fix the platform version check in windows_share - -## 4.2.3 (2018-05-07) - -- Include the helper in the action class to prevent failures with the zipfile resource - -## 4.2.2 (2018-04-24) - -- Properly fail in windows_share on Windows 2008 R2 since we lack the cmdlets to manipulates shares on those systems. - -## 4.2.1 (2018-04-17) - -- Make sure shares can have spaces in the share name - -## 4.2.0 (2018-04-16) - -- Initial rewrite of windows_share to use PowerShell for share creation. This introduces multiple new properties and resolves a good number of longstanding issues. Please be sure to report any issues you see with this so we can stabilize this resource and include it in Chef 15! -- Resolve failures in windows_certificate - -## 4.1.4 (2018-03-29) - -- Raise in windows_feature_powershell if we're on PS < 3.0 - -## 4.1.3 (2018-03-28) - -- Restore support for Windows 2008 R2 in windows_feature_dism - -## 4.1.2 (2018-03-27) - -- Improve creation messaging for shares -- Allow feature names to be case insensitive in windows_feature - -## 4.1.1 (2018-03-23) - -- Simplify delete action slightly in windows_pagefile -- Don't use win_friendly_path helper in windows_pagefile since we already coerce the path value - -## 4.1.0 (2018-03-21) - -- Adds Caching for WIndows Feature Powershell resource using the same sort of logic we use on windows_feature_dism. This gives us a 3.5X speedup when no features need to be changed (subsequent runs after the change) -- Warn if we're on w2k12 and trying to use source/management properties in windows_feature_powershell since that doesn't work. -- Properly parse features into arrays so installing an array of features works in dism/powershell. This is the preferred way to install a number of features and will be faster than a large number of feature resources -- Fix description of properties for pagefile in the readme - -## 4.0.2 (2018-03-20) - -- Enable FC016 testing -- Enable FC059 testing -- Properly calculate available packages if source is passed in windows_feature_dism resource - -## 4.0.1 (2018-03-07) - -Fix the previous update to windows_feature_dism to use 'override' level of attributes not the normal level which persists to the node. Thanks to @Annih for pointing out the mistake here. - -## 4.0.0 (2018-03-05) - -### WARNING - -This release contains a complete rewrite to windows_feature_dism resource and includes several behavior changes to windows_feature resource. Make sure to read the complete list of changes below before deploying this to production systems. - -#### DISM feature caching Ohai plugin replacement - -In the 3.X cookbook we installed an Ohai plugin that cached the state of features on the node, and we reloaded that plugin anytime we installed/removed a feature from the system. This greatly sped up Chef runs where no features were actually installed/removed (2nd run and later). Without the caching each resource would take about 1 second longer while it queried current feature state. Using Ohai to cache this data was problematic though due to incompatibilities with Chef Solo, the reliance on the ohai cookbook, and the addition of extra node data which had to be stored on the Chef Server. - -In the 4.0 release instead of caching data via an Ohai plugin we just write directly to the node within the resource. This avoids the need to load in the ohai plugin and the various issues that come with that. In the end it's basically the exact same thing, but less impacting on end users and faster when the data needs to be updated. - -#### Fail when feature is missing in windows_feature_dism - -The windows_feature_dism resource had a rather un-Chef behavior in which it just warned you if a feature wasn't available on your platform and then continued on silently. This isn't how we handle missing packages in any of our package resource and because of that it's not going to be what anyone expects out of the box. If someone really wants SNMP installed and we can't install it we should fail instead of continuing on as if we did install it. So we'll now do the following things: - -- When installing a feature that doesn't exist: fail -- When removing a feature that doesn't exist: continue since it is technically removed -- When deleting a feature that doesn't exist: continue since it is technically deleted - -For some users, particularly those writing community cookbooks, this is going to be a breaking change. I'd highly recommend putting logic within your cookbooks to only install features on supported releases of Windows. If you'd just like it to continue even with a failure you can also use `ignore_failure true` on your resource although this produces a lot of failure messaging in logs. - -#### Properly support features as an array in windows_feature_dism - -We claimed to support installing features as an array in the windows_feature_dism resource previously, but it didn't actually work. The actual result was a warning that the array of features wasn't available on your platform since we compared the array to available features as if it was a string. We now properly support installation as a array and we do validation on each feature in the array to make sure the features are available on your Windows release. - -#### Install as the default action in windows_feature_powershell - -Due to some previous refactoring the :install action was not the default action for windows_feature_powershell. For all other package resources in Chef install is the default so this would likely lead to some unexpected behavior in cookbooks. This is technically a breaking change, but I suspect everyone assumed :install was always the default. - -#### servermanagercmd.exe Support Removal - -This cookbook previously supported servermanagercmd.exe, which was necessary for feature installation on Windows 2003 / 2008 (not R2) systems. Windows 2003 went full EOL in 2015 and 2008 went into extended support in 2015\. Neither releases are supported platforms for Chef or this cookbook so we've chosen to simplify the code and remove support entirely. - -#### Remove the undocumented node['windows']['rubyzipversion'] attribute - -This attribute was a workaround for a bug in the rubyzip gem YEARS ago that's just not necessary anymore. We also never documented this attribute and a resource shouldn't change behavior based on attributes. - -## 3.5.2 (2018-03-01) - -- Remove value_for_feature_provider helper which wasn't being used and was using deprecated methods -- Add all the Windows Core editions to the version helper -- Simplify / speedup how we find the font directory in windows_font -- Don't bother enabling why-run mode in the resources since it's enabled by default -- Don't include mixlib-shellout in the resources since it's included by default -- Fix installation messaging for windows_feature_powershell to properly show all features being installed -- Use powershell for the share creation / deletion in windows_share. This speeds up the runs and fixes some of the failures. - -## 3.5.1 (2018-02-23) - -- Add a new `shortcut_name` property to `windows_shortcut` -- Use Chef's built in registry_key_exists helper in `windows_printer_port` -- Fix the `source` coerce in `windows_font` - -## 3.5.0 (2018-02-23) - -- Add Windows 2016 to the supported releases in the readme -- Add Windows 10 detection to the version helper -- Remove the Chefspec matchers. These are auto generated by ChefSpec now. If this causes your specs to fail upgrade ChefDK -- In `certificate_binding` support `hostnameport` option if address is a hostname -- Convert several tests to InSpec tests and add additional test scenarios -- Remove `required: true` on the name_properties, which serves no purpose and will be a Foodcritic rule in the next Foodcritic release -- Fix `windows_feature` logging to work when the user provides an array of features -- Don't both coercing a symbol into a symbol in the `windows_auto_run` resource. -- Switch `windows_font` over to the built in path helper in Chef, which a much more robust -- Don't coerce forward slashes to backslashes in the `windows_font` `source` property if the source is a URI -- Add a new `path` property to `windows_pagefile` for properly overriding the resource name -- Coerce backslashes to forward slashes in `windows_pagefile`'s `path` property so we do the right thing even if a user gives bad input -- Add a new `program_name` property in windows_auto_run for overriding the resource name -- Rename `program` property to `path` in windows_auto_run. The legacy name will continue to work, but cookbooks should be updated -- Coerce the `path` property to use backslashes in `windows_auto_run` so it works no matter what format of path the user provides -- Avoid writing out an extra space in `windows_auto_run`'s registry entry when the user doesn't specify an arg -- Added yard comments to many of the helper methods - -## 3.4.4 (2018-01-19) - -- Fix undefined method for 'ipv4_address' in windows_printer_port - -## 3.4.3 (2018-01-04) - -- Added missing parentheses around PersistKeySet flag that was preventing PowerShell from creating X509Certificate2 object - -## 3.4.2 (2018-01-02) - -- Add deprecation warnings for windows_path and windows_task which are now included in Chef 13\. These will be removed from this cookbook in Sept 2018. - -## 3.4.1 (2017-12-06) - -- Fix long-running filtering by replace LIKE with equality sign in the share resource -- Use logical OR instead of AND when trying to detect share permissions changing in the share resource -- Remove extra new_resource.updated_by_last_action in the windows_task resource that resulted in a Foodcritic warning - -## 3.4.0 (2017-11-14) - -- Add a root key property for the auto_run resource -- Fix a resource typo where a name_property was still written name_attribute -- Resolve FC108 warnings - -## 3.3.0 (2017-11-06) - -- Add new dns resource. See readme for examples -- Add BUILTIN\Users to SYSTEM_USERS for windows_task - -## 3.2.0 (2017-10-17) - -- Add management_tools property to windows_feature powershell provider which installs the various management tools -- Fix deprecations_namespace_collisions -- Add additional certificate store names -- Add the ability to define a timeout on windows_feature -- Multiple improvements to the font resource - - - Improved logging, particularly debug logging - - Allow pulling the font from a remote location using remote_file - - Fix some failures in fetching local fonts - - Added a font_name property that allows you specify the local name of the font, which can be different from the name of the chef resource. This allows you to create more friendly resource names for your converge. - - Handle font resources with backslashes in their source - -- Remove source property from servermanagercmd provider as it does not support it. - -- Remove converge_by around inner powershell_script resource to stop it always reporting as changed - -- Change install feature guards to work on Windows 2008r2 - -- Allow dism feature installs to work on non-English systems - -## 3.1.3 (2017-09-18) - -### windows_task and windows_path deprecation - -s of chef-client 13.0+ and 13.4+ windows_task and windows_path are now included in the Chef client. windows_task underwent a full rewrite that greatly improved the functionality and idempotency of the resource. We highly recommend using these new resources by upgrading to Chef 13.4 or later. If you are running these more recent Chef releases the windows_task and windows_path resources within chef-client will take precedence over those in this cookbook. In September 2018 we will release a new major version of this cookbook that removes windows_task and windows_path. - -## 3.1.2 (2017-08-14) - -- Revert "Require path in the share resource instead of raising if it's missing" which was causing failures due to a bug in the chef-client - -## 3.1.1 (2017-06-13) - -- Replace Windows 7 testing with Windows 10 testing -- Expand debug logging in the pagefile resource -- Require path in the share resource instead of raising if it's missing -- Make pagefile properly fail the run if the command fails to run - -## 3.1.0 (2017-05-30) - -- Updated resource documentation for windows_pagefile -- Declare windows_feature as why-runnable -- Remove action_class.class_eval usage and require 12.7+ as class_eval is causing issues with later versions of Chef - -## 3.0.5 (2017-04-07) - -- Add support for windows_task resource to run on non-English editions of Windows -- Ensure chef-client 12.6 compatibility with action_class.class_eval - -## 3.0.4 (2017-03-29) - -- restoring the `cached_file` helper as downstream cookbooks use it. - -## 3.0.3 (2017-03-28) - -- Correct a typo in a Log message - -## 3.0.2 (2017-03-21) - -- Fix `windows_zipfile` resource to properly download and cache the zip archives - -## 3.0.1 (2017-03-17) - -- Fix `windows_share` to be fully idempotent. Fixes #447 - -## 3.0.0 (2017-03-15) - -**Warning** This release includes multiple breaking changes as we refactored all existing resources and resolved many longstanding bugs. We highly recommend exercising caution and fully testing this new version before rolling it out to a production environment. - -### Breaking changes - -- This cookbook now requires Chef 12.6 or later and we highly recommend even more recent Chef 12 releases as they resolve critical Windows bugs and include new Windows specific functionality. -- The windows_package resource has been removed as it is built into chef-client 12.6+ and the built in version is faster / more robust. -- The powershell out helper has been removed as it is now included in chef-client 12.6+ -- The default recipe no longer installs the various Windows rubygems required for non-omnibus chef-client installs. This was a leftover from Chef 10 and is no longer necessary, or desired, as we ship these gems in every Windows chef release. -- windows_feature has been heavily refactored and in doing so the method used to control the underlying providers has changed. You can no longer specify which windows_feature provider to use by setting `node['windows']['feature_provider']` or by setting the `provider` property on the resource itself. Instead you must set `install_method` to specify the correct underlying installation method. You can also now reference the resources directly by using `windows_feature_servermanagercmd`, `windows_feature_powershell` or `windows_feature_dism` instead of `windows_feature` - -- Windows_font's `file` property has been renamed to `name` to avoid collisions with the Chef file resource. - -### Other Changes - -- All LWRPs in this cookbook have been refactored to be custom resources -- windows_path, windows_shortcut, and windows_zipfile have been updated to be idempotent with support for why-run mode and proper notification when the resources actually update -- windows_pagefile now validates the name of the pagefile to avoid cryptic error messages -- A new `share` resource has been added for setting up Windows shares -- TrustedPeople certificate store has been added to the list of allowed store_names in the certificate resources -- version helper constant definitions has been improved -- A new `all` property has been added to the Windows feature resource to install all dependent features. See the windows feature test recipe for usage examples. -- Windows feature now accepts an array of features, which greatly speeds up feature installs and simplifies recipe code -- The path resource now accepts paths with either forward slashes or backslashes and correctly adds the path using Windows style backslash. -- The powershell provider for windows_feature resource has been fixed to properly import ServerManager in the :remove action -- Testing has been switched from a Rakefile to the new Delivery local mode -- Several issues with testing the resources on non-Windows hosts in ChefSpec have been resolved -- A new `source` property has been added to the windows_feature_powershell resource -- Additional test suites have been added to Test Kitchen to cover all resources and those test suites are now being executed in AppVeyer on every PR -- Travis CI testing has been removed and all testing is being performed in AppVeyer - -## 2.1.1 (2016-11-23) - -- Make sure the ohai plugin is available when installing features - -## 2.1.0 (2016-11-22) - -- Reduce expensive executions of dism in windows_feature by using a new Ohai plugin -- Add guard around chef_version metadata for Opsworks and older Chef 12 clients -- Update the rakefile to the latest -- Add deprecation dates for the windows_package and powershell functionality that has been moved to core Chef. These will be removed 4/17 when we release Chef 13 -- Provide helper method to get windows version info -- Allow defining http acl using SDDL - -## 2.0.2 (2016-09-07) - -- Added the powershell_out mixin back to allow for Chef 12.1-12.3 compatibility -- Set the dependency back to Chef 12.1 - -## 2.0.1 (2016-09-07) - -- Clarify the platforms we support in the readme -- Require Chef 12.4 which included powershell_out - -## 2.0.0 (2016-09-07) - -This cookbook now requires Chef 12.1+. Resources (lwrps) that have been moved into the chef-client have been removed from this cookbook. While the functionality in the chef-client is similar, and in many cases improved, the names and properties have changed in some cases. Make sure to check for full documentation on each of these resources, and as usual carefully test your cookbooks before upgrading to this new release. - -### Removed resources and helpers: - -- windows_reboot provider -- windows_batch provider -- windows_registry provider -- Powershell out for only_if / not_if statements -- Windows Architecture Helper -- Reboot handler and the dependency on the chef_handler cookbook - -#### Changes resource behavior - -- For Chef clients 12.6 and later the windows_package provider will no longer be used as windows_package logic is now included in Chef. Chef 12.1 - 12.5.1 clients will continue to default to the windows_package provider in this cookbook for full compatibility. - -#### Additional changes - -- Updated and expanded testing -- Fixed the windows_feature powershell provider to run on Windows 2008 / 2008 R2 -- Added TrustedPublisher as a valid cert store_name -- Updated the certificate_binding resource to respect the app_id property -- Added why-run support to the auto_run resource - -## 1.44.3 (2016-08-16) - -- Remove support for ChefSpec <4.1 in the matchers -- Add missing Chefspec matchers - -## 1.44.2 (2016-08-15) - -- Add missing windows_font matcher -- Add chef_version to the metadata -- Switch from Rubocop to Cookstyle and use our improved Rakefile -- Remove test deps from the Gemfile that are in ChefDK - -## v1.44.1 - -- [PR 375](https://github.com/chef-cookbooks/windows/pull/375) - Fix comparison of string to number in platform_version -- [PR 376](https://github.com/chef-cookbooks/windows/pull/376) - Switch to cookstyle, update gem deps and other minor stuff -- [PR 377](https://github.com/chef-cookbooks/windows/pull/377) - add test and check for feature installation through powershell - -## v1.44.0 - -- [PR 372](https://github.com/chef-cookbooks/windows/pull/372) - Support Server 2008 for feature installs via PowerShell - -## v1.43.0 - -- [PR 369](https://github.com/chef-cookbooks/windows/pull/369) - Add a enable_windows_task matcher - -## v1.42.0 - -- [PR 365](https://github.com/chef-cookbooks/windows/pull/365) - Escape command quotes when passing to schtasks - -## v1.41.0 - -- [PR 364](https://github.com/chef-cookbooks/windows/pull/364) - Configurable font source - -## v1.40.0 - -- [PR 357](https://github.com/chef-cookbooks/windows/pull/357) - Fixes for schtasks -- [PR 359](https://github.com/chef-cookbooks/windows/pull/359) - take bundler out of the appveyor build -- [PR 356](https://github.com/chef-cookbooks/windows/pull/356) - Misc fixes and updates -- [PR 355](https://github.com/chef-cookbooks/windows/pull/355) - bump and pin rubocop, fix broken cop -- [PR 348](https://github.com/chef-cookbooks/windows/pull/348) - Make notify work for `windows_task` - -## v1.39.2 - -- [PR 329](https://github.com/chef-cookbooks/windows/pull/329) - Silence `compile_time` warning for `chef_gem` -- [PR 338](https://github.com/chef-cookbooks/windows/pull/338) - ChefSpec matchers for `windows_certificate` -- [PR 341](https://github.com/chef-cookbooks/windows/pull/341) - Updated rubocop and FoodCritic compliance -- [PR 336](https://github.com/chef-cookbooks/windows/pull/336) - Fixed where clause compliance with PS v1/v2 - -## v1.39.1 - -- [PR 325](https://github.com/chef-cookbooks/windows/pull/325) - Raise an error if a bogus feature is given to the powershell `windows_feature` provider -- [PR 326](https://github.com/chef-cookbooks/windows/pull/326) - Fix `windows_font` and copy the font file before installation - -## v1.39.0 - -- [PR 305](https://github.com/chef-cookbooks/windows/pull/305) - Added `months` attribute to `windows_task` and allow `frequency_modifier` to accept values 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'LAST', and 'LASTDAY' for monthly frequency -- [PR 310](https://github.com/chef-cookbooks/windows/pull/310) - Fix `windows_task` breaks when there is a space in the user name -- [PR 314](https://github.com/chef-cookbooks/windows/pull/314) - fixes reboot handling on some chef versions below 11.12 -- [PR 317](https://github.com/chef-cookbooks/windows/pull/317) - Adds a `disable_windows_task` matcher -- [PR 311](https://github.com/chef-cookbooks/windows/pull/311) - Implements the `cwd` attribute of `windows_task` -- [PR 318](https://github.com/chef-cookbooks/windows/pull/318) - Use dsl instead of manual resource instanciation -- [PR 303](https://github.com/chef-cookbooks/windows/pull/303) - Fix `http_acl` idempotency when user name contains a space -- [PR 257](https://github.com/chef-cookbooks/windows/pull/257) - Speed up windows_feature dism provider -- [PR 319](https://github.com/chef-cookbooks/windows/pull/319) - Add a `.kitchen.cloud.yml` for kitchen testing on Azure -- [PR 315](https://github.com/chef-cookbooks/windows/pull/315) - Deprecate `windows_package` and forward to `Chef::Provider::Package::Windows` when running 12.6 or higher - -## v1.38.4 - -- [PR 295](https://github.com/chef-cookbooks/windows/pull/295) - Escape `http_acl` username -- [PR 293](https://github.com/chef-cookbooks/windows/pull/293) - Separating assignments to `code_script` and `guard_script` as they should be different scripts and not hold the same reference -- [Issue 298](https://github.com/chef-cookbooks/windows/issues/298) - `windows_certificate_binding` is ignoring `store_name` attribute and always saving to `MY` -- [Issue 296](https://github.com/chef-cookbooks/windows/pull/302) - Fixes `windows_certificate` idempotentcy on chef 11 clients - -## v1.38.3 - -- Make `windows_task` resource idempotent (double quotes need to be single when comparing) -- [Issue 245](https://github.com/chef-cookbooks/windows/issues/256) - Fix `No resource, method, or local variable named`password' for `Chef::Provider::WindowsTask'` when `interactive_enabled` is `true` - -## v1.38.2 - -- Lazy-load windows-pr gem library files. Chef 12.5 no longer includes the windows-pr gem. Earlier versions of this cookbook will not compile on Chef 12.5. - -## v1.38.1 (2015-07-28) - -- Publishing without extended metadata - -## v1.38.0 (2015-07-27) - -- Do not set new_resource.password to nil, Fixes #219, Fixes #220 -- Add `windows_certificate` resource #212 -- Add `windows_http_acl` resource #214 - -## v1.37.0 (2015-05-14) - -- fix `windows_package` `Chef.set_resource_priority_array` warning -- update `windows_task` to support tasks in folders -- fix `windows_task` delete action -- replace `windows_task` name attribute with 'task_name' -- add :end action to 'windows_task' -- Tasks created with the `windows_task` resource default to the SYSTEM account -- The force attribute for `windows_task` makes the :create action update the definition. -- `windows_task` :create action will force an update of the task if the user or command differs from the currently configured setting. -- add default provider for `windows_feature` -- add a helper to make sure `WindowsRebootHandler` works in ChefSpec -- added a source and issues url to the metadata for Supermarket -- updated the Gemfile and .kitchen.yml to reflect the latest test-kitchen windows guest support -- started tests using the kitchen-pester verifier - -## v1.36.6 (2014-12-18) - -- reverting all chef_gem compile_time work - -## v1.36.5 (2014-12-18) - -- Fix zipfile provider - -## v1.36.4 (2014-12-18) - -- Fix Chef chef_gem with Chef::Resource::ChefGem.method_defined?(:compile_time) - -## v1.36.3 (2014-12-18) - -- Fix Chef chef_gem below 12.1.0 - -## v1.36.2 (2014-12-17) - -- Being explicit about usage of the chef_gem's compile_time property. -- Eliminating future deprecation warnings in Chef 12.1.0 - -## v1.36.1 (2014-12-17) - -- [PR 160](https://github.com/chef-cookbooks/windows/pull/160) - Fix Chef 11.10 / versions without windows_package in core - -## v1.36.0 (2014-12-16) - -- [PR 145](https://github.com/chef-cookbooks/windows/pull/145) - do not fail on non-existant task -- [PR 144](https://github.com/chef-cookbooks/windows/pull/144) - Add a zip example to the README -- [PR 110](https://github.com/chef-cookbooks/windows/pull/110) - More zip documentation -- [PR 148](https://github.com/chef-cookbooks/windows/pull/148) - Add an LWRP for font installation -- [PR 151](https://github.com/chef-cookbooks/windows/pull/151) - Fix windows_package on Chef 12, add integration tests -- [PR 129](https://github.com/chef-cookbooks/windows/pull/129) - Add enable/disable actions to task LWRP -- [PR 115](https://github.com/chef-cookbooks/windows/pull/115) - require Chef::Mixin::PowershellOut before using it -- [PR 88](https://github.com/chef-cookbooks/windows/pull/88) - Code 1003 from servermanagercmd.exe is valid - -## v1.34.8 (2014-10-31) - -- [Issue 137](https://github.com/chef-cookbooks/windows/issues/137) - windows_path resource breaks with ruby 2.x - -## v1.34.6 (2014-09-22) - -- [Chef-2009](https://github.com/chef/chef/issues/2009) - Patch to work around a regression in [Chef](https://github.com/chef/chef) - -## v1.34.2 (2014-08-12) - -- [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Remove rubygems / Internet wmi-lite dependency (PR #108) - -## v1.34.0 (2014-08-04) - -- [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Use wmi-lite to fix Chef 11.14.2 break in rdp-ruby-wmi dependency - -## v1.32.1 (2014-07-15) - -- Fixes broken cookbook release - -## v1.32.0 (2014-07-11) - -- Add ChefSpec resource methods to allow notification testing (@sneal) -- Add use_inline_resources to providers (@micgo) -- [COOK-4728] - Allow reboot handler to be used as an exception handler -- [COOK-4620] - Ensure win_friendly_path doesn't error out when ALT_SEPARATOR is nil - -## v1.31.0 (2014-05-07) - -- [COOK-2934] - Add windows_feature support for 2 new DISM attributes: all, source - -## v1.30.2 (2014-04-02) - -- [COOK-4414] - Adding ChefSpec matchers - -## v1.30.0 (2014-02-14) - -- [COOK-3715] - Unable to create a startup task with no login -- [COOK-4188] - Add powershell_version method to return Powershell version - -## v1.12.8 (2014-01-21) - -- [COOK-3988] Don't unescape URI before constructing it. - -## v1.12.6 (2014-01-03) - -- [COOK-4168] Circular dep on powershell - moving powershell libraries into windows. removing dependency on powershell - -## v1.12.4 - -Fixing depend/depends typo in metadata.rb - -## v1.12.2 - -### Bug - -- **[COOK-4110](https://tickets.chef.io/browse/COOK-4110)** - feature_servermanager installed? method regex bug - -## v1.12.0 - -### Bug - -- **[COOK-3793](https://tickets.chef.io/browse/COOK-3793)** - parens inside parens of README.md don't render - -### New Feature - -- **[COOK-3714](https://tickets.chef.io/browse/COOK-3714)** - Powershell features provider and delete support. - -## v1.11.0 - -### Improvement - -- **[COOK-3724](https://tickets.chef.io/browse/COOK-3724)** - Rrecommend built-in resources over cookbook resources -- **[COOK-3515](https://tickets.chef.io/browse/COOK-3515)** - Remove unprofessional comment from library -- **[COOK-3455](https://tickets.chef.io/browse/COOK-3455)** - Add Windows Server 2012R2 to windows cookbook version helper - -### Bug - -- **[COOK-3542](https://tickets.chef.io/browse/COOK-3542)** - Fix an issue where `windows_zipfile` fails with LoadError -- **[COOK-3447](https://tickets.chef.io/browse/COOK-3447)** - Allow Overriding Of The Default Reboot Timeout In windows_reboot_handler -- **[COOK-3382](https://tickets.chef.io/browse/COOK-3382)** - Allow windows_task to create `on_logon` tasks -- **[COOK-2098](https://tickets.chef.io/browse/COOK-2098)** - Fix and issue where the `windows_reboot` handler is ignoring the reboot time - -### New Feature - -- **[COOK-3458](https://tickets.chef.io/browse/COOK-3458)** - Add support for `start_date` and `start_time` in `windows_task` - -## v1.10.0 - -### Improvement - -- [COOK-3126]: `windows_task` should support the on start frequency -- [COOK-3127]: Support the force option on task create and delete - -## v1.9.0 - -### Bug - -- [COOK-2899]: windows_feature fails when a feature install requires a reboot -- [COOK-2914]: Foodcritic failures in Cookbooks -- [COOK-2983]: windows cookbook has foodcritic failures - -### Improvement - -- [COOK-2686]: Add Windows Server 2012 to version.rb so other depending chef scripts can detect Windows Server 2012 - -## v1.8.10 - -When using Windows qualified filepaths (C:/foo), the #absolute? method for URI returns true, because "C" is the scheme. - -This change checks that the URI is http or https scheme, so it can be passed off to remote_file appropriately. - -- [COOK-2729] - allow only http, https URI schemes - -## v1.8.8 - -- [COOK-2729] - helper should use URI rather than regex and bare string - -## v1.8.6 - -- [COOK-968] - `windows_package` provider should gracefully handle paths with spaces -- [COOK-222] - `windows_task` resource does not declare :change action -- [COOK-241] - Windows cookbook should check for redefined constants -- [COOK-248] - Windows package install type is case sensitive - -## v1.8.4 - -- [COOK-2336] - MSI That requires reboot returns with RC 3010 and causes chef run failure -- [COOK-2368] - `version` attribute of the `windows_package` provider should be documented - -## v1.8.2 - -**Important**: Use powershell in nodes expanded run lists to ensure powershell is downloaded, as powershell has a dependency on this cookbook; v1.8.0 created a circular dependency. - -- [COOK-2301] - windows 1.8.0 has circular dependency on powershell - -## v1.8.0 - -- [COOK-2126] - Add checksum attribute to `windows_zipfile` -- [COOK-2142] - Add printer and `printer_port` LWRPs -- [COOK-2149] - Chef::Log.debug Windows Package command line -- [COOK-2155] -`windows_package` does not send checksum to `cached_file` in `installer_type` - -## v1.7.0 - -- [COOK-1745] - allow for newer versions of rubyzip - -## v1.6.0 - -- [COOK-2048] - undefined method for Falseclass on task :change when action is :nothing (and task doesn't exist) -- [COOK-2049] - Add `windows_pagefile` resource - -## v1.5.0 - -- [COOK-1251] - Fix LWRP "NotImplementedError" -- [COOK-1921] - Task LWRP will return true for resource exists when no other scheduled tasks exist -- [COOK-1932] - Include :change functionality to windows task lwrp - -## v1.4.0: - -- [COOK-1571] - `windows_package` resource (with msi provider) does not accept spaces in filename -- [COOK-1581] - Windows cookbook needs a scheduled tasks LWRP -- [COOK-1584] - `windows_registry` should support all registry types - -## v1.3.4 - -- [COOK-1173] - `windows_registry` throws Win32::Registry::Error for action :remove on a nonexistent key -- [COOK-1182] - windows package sets start window title instead of quoting a path -- [COOK-1476] - zipfile lwrp should support :zip action -- [COOK-1485] - package resource fails to perform install correctly when "source" contains quote -- [COOK-1519] - add action :remove for path lwrp - -## v1.3.2 - -- [COOK-1033] - remove the `libraries/ruby_19_patches.rb` file which causes havoc on non-Windows systems. -- [COOK-811] - add a timeout parameter attribute for `windows_package` - -## v1.3.0 - -- [COOK-1323] - Update for changes in Chef 0.10.10. - - - Setting file mode doesn't make sense on Windows (package provider - - and `reboot_handler` recipe) - - Prefix ::Win32 to avoid namespace collision with Chef::Win32 - - (`registry_helper` library) - - Use chef_gem instead of gem_package so gems get installed correctly under the Ruby environment Chef runs in (reboot_handler recipe, zipfile provider) - -## v1.2.12 - -- [COOK-1037] - specify version for rubyzip gem -- [COOK-1007] - `windows_feature` does not work to remove features with dism -- [COOK-667] - shortcut resource + provider for Windows platforms - -## v1.2.10 - -- [COOK-939] - add `type` parameter to `windows_registry` to allow binary registry keys. -- [COOK-940] - refactor logic so multiple values get created. - -## v1.2.8 - -- FIX: Older Windows (Windows Server 2003) sometimes return 127 on successful forked commands -- FIX: `windows_package`, ensure we pass the WOW* registry redirection flags into reg.open - -## v1.2.6 - -- patch to fix [CHEF-2684], Open4 is named Open3 in Ruby 1.9 -- Ruby 1.9's Open3 returns 0 and 42 for successful commands -- retry keyword can only be used in a rescue block in Ruby 1.9 - -## v1.2.4 - -- `windows_package` - catch Win32::Registry::Error that pops up when searching certain keys - -## v1.2.2 - -- combined numerous helper libarires for easier sharing across libaries/LWRPs -- renamed Chef::Provider::WindowsFeature::Base file to the more descriptive `feature_base.rb` -- refactored `windows_path` LWRP - - - :add action should MODIFY the the underlying ENV variable (vs CREATE) - - deleted greedy :remove action until it could be made more idempotent - -- added a `windows_batch` resource/provider for running batch scripts remotely - -## v1.2.0 - -- [COOK-745] gracefully handle required server restarts on Windows platform - - - WindowsRebootHandler for requested and pending reboots - - `windows_reboot` LWRP for requesting (receiving notifies) reboots - - `reboot_handler` recipe for enabling WindowsRebootHandler as a report handler - -- [COOK-714] Correct initialize misspelling - -- RegistryHelper - new `get_values` method which returns all values for a particular key. - -## v1.0.8 - -- [COOK-719] resource/provider for managing windows features -- [COOK-717] remove `windows_env_vars` resource as env resource exists in core chef -- new `Windows::Version` helper class -- refactored `Windows::Helper` mixin - -## v1.0.6 - -- added `force_modify` action to `windows_registry` resource -- add `win_friendly_path` helper -- re-purpose default recipe to install useful supporting windows related gems - -## v1.0.4 - -- [COOK-700] new resources and improvements to the `windows_registry` provider (thanks Paul Morton!) - - - Open the registry in the bitednes of the OS - - Provide convenience methods to check if keys and values exit - - Provide convenience method for reading registry values - - NEW - `windows_auto_run` resource/provider - - NEW - `windows_env_vars` resource/provider - - NEW - `windows_path` resource/provider - -- re-write of the `windows_package` logic for determining current installed packages - -- new checksum attribute for `windows_package` resource...useful for remote packages - -## v1.0.2 - -- [COOK-647] account for Wow6432Node registry redirecter -- [COOK-656] begin/rescue on win32/registry - -## v1.0.0 - -- [COOK-612] initial release diff --git a/vendor-cookbooks/windows/CONTRIBUTING.md b/vendor-cookbooks/windows/CONTRIBUTING.md deleted file mode 100644 index ef2f2b8..0000000 --- a/vendor-cookbooks/windows/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/vendor-cookbooks/windows/README.md b/vendor-cookbooks/windows/README.md deleted file mode 100644 index eabdd9f..0000000 --- a/vendor-cookbooks/windows/README.md +++ /dev/null @@ -1,426 +0,0 @@ -# Windows Cookbook - -[![Build status](https://ci.appveyor.com/api/projects/status/9x4uepmm1g4rktie/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/windows/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/windows.svg)](https://supermarket.chef.io/cookbooks/windows) - -Provides a set of Windows-specific resources to aid in the creation of cookbooks/recipes targeting the Windows platform. - -## Requirements - -### Platforms - -- Windows 7 -- Windows Server 2008 R2 -- Windows 8, 8.1 -- Windows Server 2012 (R1, R2) -- Windows Server 2016 - -### Chef - -- Chef 14.7+ - -## Resources - -### windows_certificate_binding - -Binds a certificate to an HTTP port to enable TLS communication. - -#### Actions - -- `:create` - creates or updates a binding. -- `:delete` - deletes a binding. - -#### Properties - -- `cert_name` - name attribute. The thumbprint(hash) or subject that identifies the certificate to be bound. -- `name_kind` - indicates the type of cert_name. One of :subject (default) or :hash. -- `address` - the address to bind against. Default is 0.0.0.0 (all IP addresses). One of: - - IP v4 address `1.2.3.4` - - IP v6 address `[::1]` - - Host name `www.foo.com` -- `port` - the port to bind against. Default is 443. -- `app_id` - the GUID that defines the application that owns the binding. Default is the values used by IIS. -- `store_name` - the store to locate the certificate in. One of: - - MY (Personal) - - CA (Intermediate Certification Authorities) - - ROOT (Trusted Root Certification Authorities) - - TRUSTEDPUBLISHER (Trusted Publishers) - - CLIENTAUTHISSUER (Client Authentication Issuers) - - REMOTE DESKTOP (Remote Desktop) - - TRUSTEDDEVICES (Trusted Devices) - - WEBHOSTING (Web Hosting) - - AUTHROOT (Third-Party Root Certification Authorities) - - TRUSTEDPEOPLE (Trusted People) - - SMARTCARDROOT (Smart Card Trusted Roots) - - TRUST (Enterprise Trust) - -#### Examples - -```ruby -# Bind the first certificate matching the subject to the default TLS port -windows_certificate_binding "me.acme.com" do -end -``` - -```ruby -# Bind a cert from the CA store with the given hash to port 4334 -windows_certificate_binding "me.acme.com" do - cert_name "d234567890a23f567c901e345bc8901d34567890" - name_kind :hash - store_name "CA" - port 4334 -end -``` - -### windows_dns - -`Note`: This resource is now included in Chef 15 and later. If you are using newer versions of [windows](https://devblogs.microsoft.com/powershell/configuration-in-a-devops-world-windows-powershell-desired-state-configuration/) then should use the core [resource](https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#windows_dns_record-resource) instead of windows_dns. - -Configures A and CNAME records in Windows DNS. This requires the DNSCMD to be installed, which is done by adding the DNS role to the server or installing the Remote Server Admin Tools. - -#### Actions - -- :create: creates/updates the DNS entry -- :delete: deletes the DNS entry - -#### Properties - -- host_name: name attribute. FQDN of the entry to act on. -- dns_server: the DNS server to update. Default is local machine (.) -- record_type: the type of record to create. One of A (default) or CNAME -- target: for A records an array of IP addresses to associate with the host; for CNAME records the FQDN of the host to alias -- ttl: if > 0 then set the time to live of the record - -#### Examples - -```ruby -# Create A record linked to 2 addresses with a 10 minute ttl -windows_dns "m1.chef.test" do - target ['10.9.8.7', '1.2.3.4'] - ttl 600 -end -``` - -```ruby -# Delete records. target is mandatory although not used -windows_dns "m1.chef.test" do - action :delete - target [] -end -``` - -```ruby -# Set an alias against the node in a role -nodes = search( :node, "role:my_service" ) -windows_dns "myservice.chef.test" do - record_type 'CNAME' - target nodes[0]['fqdn'] -end -``` - -### windows_http_acl - -Sets the Access Control List for an http URL to grant non-admin accounts permission to open HTTP endpoints. - -#### Actions - -- `:create` - creates or updates the ACL for a URL. -- `:delete` - deletes the ACL from a URL. - -#### Properties - -- `url` - the name of the url to be created/deleted. -- `sddl` - the DACL string configuring all permissions to URL. Mandatory for create if user is not provided. Can't be use with `user`. -- `user` - the name (domain\user) of the user or group to be granted permission to the URL. Mandatory for create if sddl is not provided. Can't be use with `sddl`. Only one user or group can be granted permission so this replaces any previously defined entry. If you receive a parameter error your user may not exist. - -#### Examples - -```ruby -windows_http_acl 'http://+:50051/' do - user 'pc\\fred' -end -``` - -```ruby -# Grant access to users "NT SERVICE\WinRM" and "NT SERVICE\Wecsvc" via sddl -windows_http_acl 'http://+:5985/' do - sddl 'D:(A;;GX;;;S-1-5-80-569256582-2953403351-2909559716-1301513147-412116970)(A;;GX;;;S-1-5-80-4059739203-877974739-1245631912-527174227-2996563517)' -end -``` - -```ruby -windows_http_acl 'http://+:50051/' do - action :delete -end -``` - -### windows_schannel - -Used to configure the schannel security settings in windows, this is used by dotnet apps and PowerShell to be able to speak to tls 1.2 endpoints - -#### Actions - -- `configure`: Configures the setting - -#### Properties - -property | type | default | description ------------------------- | ---------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- -`use_strong_crypto` | True, False | true | Enables or disables the setting - -### windows_user_privilege - -Adds the `principal` (User/Group) to the specified privileges (such as `Logon as a batch job` or `Logon as a Service`). - -#### Actions - -- `:add` - add the specified privileges to the `principal` -- `:remove` - remove the specified privilege of the `principal` - -#### Properties - -- `principal` - Name attribute, Required, String. The user or group to be granted privileges. -- `privilege` - Required, String/Array. The privilege(s) to be granted. - -#### Examples - -Grant the Administrator user the `Logon as a batch job` and `Logon as a service` privilege. - -```ruby -windows_user_privilege 'Administrator' do - privilege %w(SeBatchLogonRight SeServiceLogonRight) -end -``` - -Remove `Logon as a batch job` privilege of Administrator. - -```ruby -windows_user_privilege 'Administrator' do - privilege %w(SeBatchLogonRight) - action :remove -end -``` - -#### Available Privileges - -``` -SeTrustedCredManAccessPrivilege Access Credential Manager as a trusted caller -SeNetworkLogonRight Access this computer from the network -SeTcbPrivilege Act as part of the operating system -SeMachineAccountPrivilege Add workstations to domain -SeIncreaseQuotaPrivilege Adjust memory quotas for a process -SeInteractiveLogonRight Allow log on locally -SeRemoteInteractiveLogonRight Allow log on through Remote Desktop Services -SeBackupPrivilege Back up files and directories -SeChangeNotifyPrivilege Bypass traverse checking -SeSystemtimePrivilege Change the system time -SeTimeZonePrivilege Change the time zone -SeCreatePagefilePrivilege Create a pagefile -SeCreateTokenPrivilege Create a token object -SeCreateGlobalPrivilege Create global objects -SeCreatePermanentPrivilege Create permanent shared objects -SeCreateSymbolicLinkPrivilege Create symbolic links -SeDebugPrivilege Debug programs -SeDenyNetworkLogonRight Deny access this computer from the network -SeDenyBatchLogonRight Deny log on as a batch job -SeDenyServiceLogonRight Deny log on as a service -SeDenyInteractiveLogonRight Deny log on locally -SeDenyRemoteInteractiveLogonRight Deny log on through Remote Desktop Services -SeEnableDelegationPrivilege Enable computer and user accounts to be trusted for delegation -SeRemoteShutdownPrivilege Force shutdown from a remote system -SeAuditPrivilege Generate security audits -SeImpersonatePrivilege Impersonate a client after authentication -SeIncreaseWorkingSetPrivilege Increase a process working set -SeIncreaseBasePriorityPrivilege Increase scheduling priority -SeLoadDriverPrivilege Load and unload device drivers -SeLockMemoryPrivilege Lock pages in memory -SeBatchLogonRight Log on as a batch job -SeServiceLogonRight Log on as a service -SeSecurityPrivilege Manage auditing and security log -SeRelabelPrivilege Modify an object label -SeSystemEnvironmentPrivilege Modify firmware environment values -SeManageVolumePrivilege Perform volume maintenance tasks -SeProfileSingleProcessPrivilege Profile single process -SeSystemProfilePrivilege Profile system performance -SeUnsolicitedInputPrivilege "Read unsolicited input from a terminal device" -SeUndockPrivilege Remove computer from docking station -SeAssignPrimaryTokenPrivilege Replace a process level token -SeRestorePrivilege Restore files and directories -SeShutdownPrivilege Shut down the system -SeSyncAgentPrivilege Synchronize directory service data -SeTakeOwnershipPrivilege Take ownership of files or other objects -``` - -### windows_zipfile - -`Note`: This resource has been deprecated as Chef Infra Client 15.0 shipped with a new archive_file resource, which natively handles multiple archive formats. Please update any cookbooks using this resource to instead use the `archive_file` resource: https://docs.chef.io/resource_archive_file.html - -Most versions of Windows do not ship with native cli utility for managing compressed files. This resource provides a pure-ruby implementation for managing zip files. Be sure to use the `not_if` or `only_if` meta parameters to guard the resource for idempotence or action will be taken every Chef run. - -#### Actions - -- `:unzip` - unzip a compressed file -- `:zip` - zip a directory (recursively) - -#### Properties - -- `path` - name attribute. The path where files will be (un)zipped to. -- `source` - source of the zip file (either a URI or local path) for :unzip, or directory to be zipped for :zip. -- `overwrite` - force an overwrite of the files if they already exist. -- `checksum` - for :unzip, useful if source is remote, if the local file matches the SHA-256 checksum, Chef will not download it. - -#### Examples - -Unzip a remote zip file locally - -```ruby -windows_zipfile 'c:/bin' do - source 'http://download.sysinternals.com/Files/SysinternalsSuite.zip' - action :unzip - not_if {::File.exists?('c:/bin/PsExec.exe')} -end -``` - -Unzip a local zipfile - -```ruby -windows_zipfile 'c:/the_codez' do - source 'c:/foo/baz/the_codez.zip' - action :unzip -end -``` - -Create a local zipfile - -```ruby -windows_zipfile 'c:/foo/baz/the_codez.zip' do - source 'c:/the_codez' - action :zip -end -``` - -## Libraries - -### WindowsHelper - -Helper that allows you to use helpful functions in windows - -#### installed_packages - -Returns a hash of all DisplayNames installed - -```ruby -# usage in a recipe -::Chef::Recipe.send(:include, Windows::Helper) -hash_of_installed_packages = installed_packages -``` - -#### is_package_installed? - -- `package_name` - The name of the package you want to query to see if it is installed -- `returns` - true if the package is installed, false if it the package is not installed - -Download a file if a package isn't installed - -```ruby -# usage in a recipe to not download a file if package is already installed -::Chef::Recipe.send(:include, Windows::Helper) -is_win_sdk_installed = is_package_installed?('Windows Software Development Kit') - -remote_file 'C:\windows\temp\windows_sdk.zip' do - source 'http://url_to_download/windows_sdk.zip' - action :create_if_missing - not_if {is_win_sdk_installed} -end -``` - -Do something if a package is installed - -```ruby -# usage in a provider -include Windows::Helper -if is_package_installed?('Windows Software Development Kit') - # do something if package is installed -end -``` - -### Windows::VersionHelper - -Helper that allows you to get information on the windows version running on your node. It leverages windows ohai from kernel.os_info, easy to mock and to use even on Linux. - -#### core_version? - -Determines whether the given node is running on a Windows Core. - -```ruby -if ::Windows::VersionHelper.core_version? node - fail 'Windows Core is not supported' -end -``` - -#### workstation_version? - -Determines whether the given node is a windows workstation version (XP, Vista, 7, 8, 8.1, 10) - -```ruby -if ::Windows::VersionHelper.workstation_version? node - fail 'Only server version of windows are supported' -end -``` - -#### server_version? - -Determines whether the given node is a windows server version (Server 2003, Server 2008, Server 2012, Server 2016) - -```ruby -if ::Windows::VersionHelper.server_version? node - puts 'Server version of windows are cool' -end -``` - -#### nt_version - -Determines NT version of the given node - -```ruby -case ::Windows::VersionHelper.nt_version node - when '6.0' then 'Windows vista or Server 2008' - when '6.1' then 'Windows 7 or Server 2008R2' - when '6.2' then 'Windows 8 or Server 2012' - when '6.3' then 'Windows 8.1 or Server 2012R2' - when '10.0' then 'Windows 10' -end -``` - -## Usage - -Place an explicit dependency on this cookbook (using depends in the cookbook's metadata.rb) from any cookbook where you would like to use the Windows-specific resources/providers that ship with this cookbook. - -```ruby -depends 'windows' -``` - -## License & Authors - -- Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io)) -- Author:: Doug MacEachern ([dougm@vmware.com](mailto:dougm@vmware.com)) -- Author:: Paul Morton ([pmorton@biaprotect.com](mailto:pmorton@biaprotect.com)) -- Author:: Doug Ireton ([doug.ireton@nordstrom.com](mailto:doug.ireton@nordstrom.com)) - -```text -Copyright 2011-2018, Chef Software, Inc. -Copyright 2010, VMware, Inc. -Copyright 2011, Business Intelligence Associates, Inc -Copyright 2012, Nordstrom, Inc. - -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. -``` diff --git a/vendor-cookbooks/windows/libraries/powershell_helper.rb b/vendor-cookbooks/windows/libraries/powershell_helper.rb deleted file mode 100644 index be021a3..0000000 --- a/vendor-cookbooks/windows/libraries/powershell_helper.rb +++ /dev/null @@ -1,53 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: windows -# Library:: powershell_helper -# -# Copyright:: 2011-2018, Chef Software, Inc. -# -# 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. -# - -require 'chef/mixin/shell_out' - -module Powershell - module Helper - include Chef::Mixin::ShellOut - - def powershell_installed? - !powershell_version.nil? - end - - def interpreter - # force 64-bit powershell from 32-bit ruby process - if ::File.exist?("#{ENV['WINDIR']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") - "#{ENV['WINDIR']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" - elsif ::File.exist?("#{ENV['WINDIR']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") - "#{ENV['WINDIR']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" - else - 'powershell.exe' - end - end - - def powershell_version - cmd = shell_out("#{interpreter} -InputFormat none -Command \"& echo $PSVersionTable.psversion.major\"") - if cmd.stdout.empty? # PowerShell 1.0 doesn't have a $PSVersionTable - 1 - else - Regexp.last_match(1).to_i if cmd.stdout =~ /^(\d+)/ - end - rescue Errno::ENOENT - nil - end - end -end diff --git a/vendor-cookbooks/windows/libraries/registry_helper.rb b/vendor-cookbooks/windows/libraries/registry_helper.rb deleted file mode 100644 index 3ca2254..0000000 --- a/vendor-cookbooks/windows/libraries/registry_helper.rb +++ /dev/null @@ -1,356 +0,0 @@ -# -# Author:: Doug MacEachern () -# Author:: Seth Chisamore () -# Author:: Paul Morton () -# Cookbook:: windows -# Library:: registry_helper -# -# Copyright:: 2010-2017, VMware, Inc. -# Copyright:: 2011-2018, Chef Software, Inc. -# Copyright:: 2011-2017, Business Intelligence Associates, Inc -# -# 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. -# - -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'win32/registry' - require_relative 'wmi_helper' -end - -module Windows - module RegistryHelper - @@native_registry_constant = if ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' || - ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' - 0x0100 - else - 0x0200 - end - - def get_hive_name(path) - Chef::Log.debug('Resolving registry shortcuts to full names') - - reg_path = path.split('\\') - hive_name = reg_path.shift - - hkey = { - 'HKLM' => 'HKEY_LOCAL_MACHINE', - 'HKCU' => 'HKEY_CURRENT_USER', - 'HKU' => 'HKEY_USERS', - }[hive_name] || hive_name - - Chef::Log.debug("Hive resolved to #{hkey}") - hkey - end - - def get_hive(path) - Chef::Log.debug("Getting hive for #{path}") - reg_path = path.split('\\') - hive_name = reg_path.shift - - hkey = get_hive_name(path) - - hive = { - 'HKEY_LOCAL_MACHINE' => ::Win32::Registry::HKEY_LOCAL_MACHINE, - 'HKEY_USERS' => ::Win32::Registry::HKEY_USERS, - 'HKEY_CURRENT_USER' => ::Win32::Registry::HKEY_CURRENT_USER, - }[hkey] - - unless hive - Chef::Application.fatal!("Unsupported registry hive '#{hive_name}'") - end - - Chef::Log.debug("Registry hive resolved to #{hkey}") - hive - end - - def unload_hive(path) - hive = get_hive(path) - if hive == ::Win32::Registry::HKEY_USERS - reg_path = path.split('\\') - priv = Chef::WindowsPrivileged.new - begin - priv.reg_unload_key(reg_path[1]) - rescue - end - end - end - - def set_value(mode, path, values, type = nil) - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key_name = reg_path.join('\\') - - Chef::Log.debug("Creating #{path}") - - create_key(path) unless key_exists?(path, true) - - hive.send(mode, key_name, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| - changed_something = false - values.each do |k, val| - key = k.to_s # wtf. avoid "can't modify frozen string" in win32/registry.rb - cur_val = nil - begin - cur_val = reg[key] - rescue - # subkey does not exist (ok) - end - - next unless cur_val != val - - Chef::Log.debug("setting #{key}=#{val}") - - type = :string if type.nil? - - reg_type = { - binary: ::Win32::Registry::REG_BINARY, - string: ::Win32::Registry::REG_SZ, - multi_string: ::Win32::Registry::REG_MULTI_SZ, - expand_string: ::Win32::Registry::REG_EXPAND_SZ, - dword: ::Win32::Registry::REG_DWORD, - dword_big_endian: ::Win32::Registry::REG_DWORD_BIG_ENDIAN, - qword: ::Win32::Registry::REG_QWORD, - }[type] - - reg.write(key, reg_type, val) - - ensure_hive_unloaded(hive_loaded) - - changed_something = true - end - return changed_something - end - false - end - - def get_value(path, value) - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - - hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| - begin - return reg[value] - rescue - return nil - ensure - ensure_hive_unloaded(hive_loaded) - end - end - end - - def get_values(path) - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| - values = [] - begin - reg.each_value do |name, type, data| - values << [name, type, data] - end - rescue - ensure - ensure_hive_unloaded(hive_loaded) - end - values - end - end - - def delete_value(path, values) - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - Chef::Log.debug("Deleting values in #{path}") - hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg| - values.each_key do |key| - name = key.to_s - # Ensure delete operation is idempotent. - if value_exists?(path, key) - Chef::Log.debug("Deleting value #{name} in #{path}") - reg.delete_value(name) - else - Chef::Log.debug("Value #{name} in #{path} does not exist, skipping.") - end - end - end - end - - def create_key(path) - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - Chef::Log.debug("Creating registry key #{path}") - hive.create(key) - end - - def value_exists?(path, value) - if key_exists?(path, true) - - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - - Chef::Log.debug("Attempting to open #{key}") - Chef::Log.debug("Native Constant #{@@native_registry_constant}") - Chef::Log.debug("Hive #{hive}") - - hive.open(key, ::Win32::Registry::KEY_READ | @@native_registry_constant) do |reg| - begin - rtn_value = reg[value] - return true - rescue - return false - ensure - ensure_hive_unloaded(hive_loaded) - end - end - - end - false - end - - # TODO: Does not load user registry... - def key_exists?(path, load_hive = false) - if load_hive - hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path) - key = reg_path.join('\\') - else - hive = get_hive(path) - reg_path = path.split('\\') - hive_name = reg_path.shift - root_key = reg_path[0] - key = reg_path.join('\\') - hive_loaded = false - end - - begin - hive.open(key, ::Win32::Registry::Constants::KEY_READ | @@native_registry_constant) - return true - rescue - return false - ensure - ensure_hive_unloaded(hive_loaded) - end - end - - def get_user_hive_location(sid) - reg_key = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\#{sid}" - Chef::Log.debug("Looking for profile at #{reg_key}") - if key_exists?(reg_key) - return get_value(reg_key, 'ProfileImagePath') - else - return nil - end - end - - def resolve_user_to_sid(username) - user_query = execute_wmi_query("select * from Win32_UserAccount where Name='#{username}'") - sid = nil - - user_query.each do |user| - sid = wmi_object_property(user, 'sid') - break - end - - Chef::Log.debug("Resolved user SID to #{sid}") - sid - rescue - nil - end - - def hive_loaded?(path) - hive = get_hive(path) - reg_path = path.split('\\') - hive_name = reg_path.shift - user_hive = path[0] - - if user_hive?(hive) - return key_exists?("#{hive_name}\\#{user_hive}") - else - return true - end - end - - def user_hive?(hive) - hive == ::Win32::Registry::HKEY_USERS - end - - def get_reg_path_info(path) - hive = get_hive(path) - reg_path = path.split('\\') - hive_name = reg_path.shift - root_key = reg_path[0] - hive_loaded = false - - if user_hive?(hive) && !key_exists?("#{hive_name}\\#{root_key}") - reg_path, hive_loaded = load_user_hive(hive, reg_path, root_key) - root_key = reg_path[0] - Chef::Log.debug("Resolved user (#{path}) to (#{reg_path.join('/')})") - end - - [hive, reg_path, hive_name, root_key, hive_loaded] - end - - def load_user_hive(hive, reg_path, user_hive) - Chef::Log.debug("Reg Path #{reg_path}") - # See if the hive is loaded. Logged in users will have a key that is named their SID - # if the user has specified the a path by SID and the user is logged in, this function - # should not be executed. - if user_hive?(hive) && !key_exists?("HKU\\#{user_hive}") - Chef::Log.debug('The user is not logged in and has not been specified by SID') - sid = resolve_user_to_sid(user_hive) - Chef::Log.debug("User SID resolved to (#{sid})") - # Now that the user has been resolved to a SID, check and see if the hive exists. - # If this exists by SID, the user is logged in and we should use that key. - # TODO: Replace the username with the sid and send it back because the username - # does not exist as the key location. - load_reg = false - if key_exists?("HKU\\#{sid}") - reg_path[0] = sid # use the active profile (user is logged on) - Chef::Log.debug("HKEY_USERS Mapped: #{user_hive} -> #{sid}") - else - Chef::Log.debug('User is not logged in') - load_reg = true - end - - # The user is not logged in, so we should load the registry from disk - if load_reg - profile_path = get_user_hive_location(sid) - unless profile_path.nil? - ntuser_dat = "#{profile_path}\\NTUSER.DAT" - if ::File.exist?(ntuser_dat) - priv = Chef::WindowsPrivileged.new - if priv.reg_load_key(sid, ntuser_dat) - Chef::Log.debug("RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})") - reg_path[0] = sid - else - Chef::Log.debug("Failed RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})") - end - end - end - end - end - - [reg_path, load_reg] - end - - private - - def ensure_hive_unloaded(hive_loaded = false) - if hive_loaded - Chef::Log.debug('Hive was loaded, we really should unload it') - unload_hive(path) - end - end - end -end - -module Registry - module_function # rubocop: disable Lint/UselessAccessModifier - - extend Windows::RegistryHelper -end diff --git a/vendor-cookbooks/windows/libraries/version.rb b/vendor-cookbooks/windows/libraries/version.rb deleted file mode 100644 index 48ff13f..0000000 --- a/vendor-cookbooks/windows/libraries/version.rb +++ /dev/null @@ -1,189 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: windows -# Library:: version -# -# Copyright:: 2011-2018, Chef Software, Inc. -# -# 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. -# - -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require_relative 'wmi_helper' -end - -module Windows - class Version - # http://msdn.microsoft.com/en-us/library/ms724833(v=vs.85).aspx - - # Suite Masks - # Microsoft BackOffice components are installed. - VER_SUITE_BACKOFFICE = 0x00000004 unless defined?(VER_SUITE_BACKOFFICE) - # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed. - VER_SUITE_DATACENTER = 0x00000080 unless defined?(VER_SUITE_DATACENTER) - # Windows Server 2008 Enterprise, Windows Server 2003, Enterprise Edition, or Windows 2000 Advanced Server is installed. Refer to the Remarks section for more information about this bit flag. - VER_SUITE_ENTERPRISE = 0x00000002 unless defined?(VER_SUITE_ENTERPRISE) - # Windows XP Embedded is installed. - VER_SUITE_EMBEDDEDNT = 0x00000040 unless defined?(VER_SUITE_EMBEDDEDNT) - # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed. - VER_SUITE_PERSONAL = 0x00000200 unless defined?(VER_SUITE_PERSONAL) - # Remote Desktop is supported, but only one interactive session is supported. This value is set unless the system is running in application server mode. - VER_SUITE_SINGLEUSERTS = 0x00000100 unless defined?(VER_SUITE_SINGLEUSERTS) - # Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. Refer to the Remarks section for more information about this bit flag. - VER_SUITE_SMALLBUSINESS = 0x00000001 unless defined?(VER_SUITE_SMALLBUSINESS) - # Microsoft Small Business Server is installed with the restrictive client license in force. Refer to the Remarks section for more information about this bit flag. - VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020 unless defined?(VER_SUITE_SMALLBUSINESS_RESTRICTED) - # Terminal Services is installed. This value is always set. - # If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode. - VER_SUITE_TERMINAL = 0x00000010 unless defined?(VER_SUITE_TERMINAL) - # Windows Home Server is installed. - VER_SUITE_WH_SERVER = 0x00008000 unless defined?(VER_SUITE_WH_SERVER) - - # Product Type - # The system is a domain controller and the operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server. - VER_NT_DOMAIN_CONTROLLER = 0x0000002 unless defined?(VER_NT_DOMAIN_CONTROLLER) - # The operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server. - # Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER. - VER_NT_SERVER = 0x0000003 unless defined?(VER_NT_SERVER) - # The operating system is Windows 7, Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional. - VER_NT_WORKSTATION = 0x0000001 unless defined?(VER_NT_WORKSTATION) - - # http://msdn.microsoft.com/en-us/library/ms724358(v=vs.85).aspx - SKU = { - 0x00000006 => { ms_const: 'PRODUCT_BUSINESS', name: 'Business' }, - 0x00000010 => { ms_const: 'PRODUCT_BUSINESS_N', name: 'Business N' }, - 0x00000012 => { ms_const: 'PRODUCT_CLUSTER_SERVER', name: 'HPC Edition' }, - 0x00000008 => { ms_const: 'PRODUCT_DATACENTER_SERVER', name: 'Server Datacenter (full installation)' }, - 0x0000000C => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE', name: 'Server Datacenter (core installation)' }, - 0x00000027 => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE_V', name: 'Server Datacenter without Hyper-V (core installation)' }, - 0x00000025 => { ms_const: 'PRODUCT_DATACENTER_SERVER_V', name: 'Server Datacenter without Hyper-V (full installation)' }, - 0x00000004 => { ms_const: 'PRODUCT_ENTERPRISE', name: 'Enterprise' }, - 0x00000046 => { ms_const: 'PRODUCT_ENTERPRISE_E', name: 'Not supported' }, - 0x0000001B => { ms_const: 'PRODUCT_ENTERPRISE_N', name: 'Enterprise N' }, - 0x0000000A => { ms_const: 'PRODUCT_ENTERPRISE_SERVER', name: 'Server Enterprise (full installation)' }, - 0x0000000E => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE', name: 'Server Enterprise (core installation)' }, - 0x00000029 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE_V', name: 'Server Enterprise without Hyper-V (core installation)' }, - 0x0000000F => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_IA64', name: 'Server Enterprise for Itanium-based Systems' }, - 0x00000026 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_V', name: 'Server Enterprise without Hyper-V (full installation)' }, - 0x00000002 => { ms_const: 'PRODUCT_HOME_BASIC', name: 'Home Basic' }, - 0x00000043 => { ms_const: 'PRODUCT_HOME_BASIC_E', name: 'Not supported' }, - 0x00000005 => { ms_const: 'PRODUCT_HOME_BASIC_N', name: 'Home Basic N' }, - 0x00000003 => { ms_const: 'PRODUCT_HOME_PREMIUM', name: 'Home Premium' }, - 0x00000044 => { ms_const: 'PRODUCT_HOME_PREMIUM_E', name: 'Not supported' }, - 0x0000001A => { ms_const: 'PRODUCT_HOME_PREMIUM_N', name: 'Home Premium N' }, - 0x0000002A => { ms_const: 'PRODUCT_HYPERV', name: 'Microsoft Hyper-V Server' }, - 0x0000001E => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT', name: 'Windows Essential Business Server Management Server' }, - 0x00000020 => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING', name: 'Windows Essential Business Server Messaging Server' }, - 0x0000001F => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY', name: 'Windows Essential Business Server Security Server' }, - 0x00000030 => { ms_const: 'PRODUCT_PROFESSIONAL', name: 'Professional' }, - 0x00000045 => { ms_const: 'PRODUCT_PROFESSIONAL_E', name: 'Not supported' }, - 0x00000031 => { ms_const: 'PRODUCT_PROFESSIONAL_N', name: 'Professional N' }, - 0x00000067 => { ms_const: 'PRODUCT_PROFESSIONAL_WMC', name: 'Professional with Media Center' }, - 0x00000018 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS', name: 'Windows Server 2008 for Windows Essential Server Solutions' }, - 0x00000023 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS_V', name: 'Windows Server 2008 without Hyper-V for Windows Essential Server Solutions' }, - 0x00000021 => { ms_const: 'PRODUCT_SERVER_FOUNDATION', name: 'Server Foundation' }, - 0x00000022 => { ms_const: 'PRODUCT_HOME_PREMIUM_SERVER', name: 'Windows Home Server 2011' }, - 0x00000032 => { ms_const: 'PRODUCT_SB_SOLUTION_SERVER', name: 'Windows Small Business Server 2011 Essentials' }, - 0x00000013 => { ms_const: 'PRODUCT_HOME_SERVER', name: 'Windows Storage Server 2008 R2 Essentials' }, - 0x00000009 => { ms_const: 'PRODUCT_SMALLBUSINESS_SERVER', name: 'Windows Small Business Server' }, - 0x00000038 => { ms_const: 'PRODUCT_SOLUTION_EMBEDDEDSERVER', name: 'Windows MultiPoint Server' }, - 0x00000007 => { ms_const: 'PRODUCT_STANDARD_SERVER', name: 'Server Standard (full installation)' }, - 0x0000000D => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE', name: 'Server Standard (core installation)' }, - 0x00000028 => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE_V', name: 'Server Standard without Hyper-V (core installation)' }, - 0x00000024 => { ms_const: 'PRODUCT_STANDARD_SERVER_V', name: 'Server Standard without Hyper-V (full installation)' }, - 0x0000000B => { ms_const: 'PRODUCT_STARTER', name: 'Starter' }, - 0x00000042 => { ms_const: 'PRODUCT_STARTER_E', name: 'Not supported' }, - 0x0000002F => { ms_const: 'PRODUCT_STARTER_N', name: 'Starter N' }, - 0x00000017 => { ms_const: 'PRODUCT_STORAGE_ENTERPRISE_SERVER', name: 'Storage Server Enterprise' }, - 0x00000014 => { ms_const: 'PRODUCT_STORAGE_EXPRESS_SERVER', name: 'Storage Server Express' }, - 0x00000015 => { ms_const: 'PRODUCT_STORAGE_STANDARD_SERVER', name: 'Storage Server Standard' }, - 0x00000016 => { ms_const: 'PRODUCT_STORAGE_WORKGROUP_SERVER', name: 'Storage Server Workgroup' }, - 0x00000000 => { ms_const: 'PRODUCT_UNDEFINED', name: 'An unknown product' }, - 0x00000001 => { ms_const: 'PRODUCT_ULTIMATE', name: 'Ultimate' }, - 0x00000047 => { ms_const: 'PRODUCT_ULTIMATE_E', name: 'Not supported' }, - 0x0000001C => { ms_const: 'PRODUCT_ULTIMATE_N', name: 'Ultimate N' }, - 0x00000011 => { ms_const: 'PRODUCT_WEB_SERVER', name: 'Web Server (full installation)' }, - 0x0000001D => { ms_const: 'PRODUCT_WEB_SERVER_CORE', name: 'Web Server (core installation)' }, - }.freeze unless defined?(SKU) - - attr_reader :major_version, :minor_version, :build_number, :service_pack_major_version, :service_pack_minor_version - attr_reader :version, :product_type, :product_suite, :sku - - def initialize - unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ - raise NotImplementedError, 'only valid on Windows platform' - end - @version, @product_type, @product_suite, @sku, @service_pack_major_version, @service_pack_minor_version = get_os_info - @major_version, @minor_version, @build_number = version.split('.').map(&:to_i) - end - - WIN_VERSIONS = { - 'Windows 10' => { major: 10, minor: 0, callable: -> { @product_type != VER_NT_WORKSTATION } }, - 'Windows Server 2012 R2' => { major: 6, minor: 3, callable: -> { @product_type != VER_NT_WORKSTATION } }, - 'Windows 8' => { major: 6, minor: 2, callable: -> { @product_type == VER_NT_WORKSTATION } }, - 'Windows Server 2012' => { major: 6, minor: 2, callable: -> { @product_type != VER_NT_WORKSTATION } }, - 'Windows 7' => { major: 6, minor: 1, callable: -> { @product_type == VER_NT_WORKSTATION } }, - 'Windows Server 2008 R2' => { major: 6, minor: 1, callable: -> { @product_type != VER_NT_WORKSTATION } }, - 'Windows Server 2008' => { major: 6, minor: 0, callable: -> { @product_type != VER_NT_WORKSTATION } }, - 'Windows Vista' => { major: 6, minor: 0, callable: -> { @product_type == VER_NT_WORKSTATION } }, - 'Windows Home Server' => { major: 5, minor: 2, callable: -> { (@product_suite & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } }, - 'Windows XP' => { major: 5, minor: 1 }, - 'Windows 2000' => { major: 5, minor: 0 }, - }.freeze unless defined?(WIN_VERSIONS) - - marketing_names = [] - - # General Windows checks - WIN_VERSIONS.each do |k, v| - method_name = "#{k.gsub(/\s/, '_').downcase}?" - define_method(method_name) do - (@major_version == v[:major]) && - (@minor_version == v[:minor]) && - (v[:callable] ? v[:callable].call : true) - end - marketing_names << [k, method_name] - end - - define_method(:marketing_name) do - marketing_names.each do |mn| - break mn[0] if send(mn[1]) - end - end - - # Server Type checks - %w( core full datacenter ).each do |m| - define_method("server_#{m}?") do - if @sku - !(SKU[@sku][:name] =~ /#{m}/i).nil? - else - false - end - end - end - - private - - # query WMI Win32_OperatingSystem for required OS info - def get_os_info - cols = %w( Version ProductType OSProductSuite OperatingSystemSKU ServicePackMajorVersion ServicePackMinorVersion ) - os_info = execute_wmi_query('select * from Win32_OperatingSystem').each.next - cols.map do |c| - begin - wmi_object_property(os_info, c) - rescue # OperatingSystemSKU doesn't exist in all versions of Windows - nil - end - end - end - end -end diff --git a/vendor-cookbooks/windows/libraries/version_helper.rb b/vendor-cookbooks/windows/libraries/version_helper.rb deleted file mode 100644 index fcb0aa7..0000000 --- a/vendor-cookbooks/windows/libraries/version_helper.rb +++ /dev/null @@ -1,93 +0,0 @@ -# -# Cookbook:: windows -# Library:: version_helper -# Author:: Baptiste Courtois () -# -# Copyright:: 2015-2017, 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. -# -module Windows - # Module based on windows ohai kernel.cs_info providing version helpers - module VersionHelper - # Module referencing CORE SKU contants from product type - # see. https://msdn.microsoft.com/windows/desktop/ms724358#PRODUCT_DATACENTER_SERVER_CORE - # n.b. Prefix - PRODUCT_ - and suffix - _CORE- have been removed - module CoreSKU - # Server Datacenter Core - DATACENTER_SERVER = 0x0C unless constants.include?(:DATACENTER_SERVER) - # Server Datacenter without Hyper-V Core - DATACENTER_SERVER_V = 0x27 unless constants.include?(:DATACENTER_SERVER_V) - # Server Enterprise Core - ENTERPRISE_SERVER = 0x0E unless constants.include?(:ENTERPRISE_SERVER) - # Server Enterprise without Hyper-V Core - ENTERPRISE_SERVER_V = 0x29 unless constants.include?(:ENTERPRISE_SERVER_V) - # Server Standard Core - STANDARD_SERVER = 0x0D unless constants.include?(:STANDARD_SERVER) - # Server Standard without Hyper-V Core - STANDARD_SERVER_V = 0x28 unless constants.include?(:STANDARD_SERVER_V) - # Small Business Server Premium Core - PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = 0x3F unless constants.include?(:PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE) - # Server Solutions Premium Core - STANDARD_SERVER_SOLUTIONS = 0x35 unless constants.include?(:STANDARD_SERVER_SOLUTIONS) - # Storage Server Enterprise Core - STORAGE_ENTERPRISE_SERVER = 0x2E unless constants.include?(:STORAGE_ENTERPRISE_SERVER) - # Storage Server Express Core - STORAGE_EXPRESS_SERVER = 0x2B unless constants.include?(:STORAGE_EXPRESS_SERVER) - # Storage Server Standard Core - STORAGE_STANDARD_SERVER = 0x2C unless constants.include?(:STORAGE_STANDARD_SERVER) - # Storage Server Workgroup Core - STORAGE_WORKGROUP_SERVER = 0x2D unless constants.include?(:STORAGE_WORKGROUP_SERVER) - # Web Server Core - WEB_SERVER = 0x1D unless constants.include?(:WEB_SERVER) - end - - # Module referencing product type contants - # see. https://msdn.microsoft.com/windows/desktop/ms724833#VER_NT_SERVER - # n.b. Prefix - VER_NT_ - has been removed - module ProductType - WORKSTATION = 0x1 unless constants.include?(:WORKSTATION) - DOMAIN_CONTROLLER = 0x2 unless constants.include?(:DOMAIN_CONTROLLER) - SERVER = 0x3 unless constants.include?(:SERVER) - end - - # Determines whether current node is running a windows Core version - def self.core_version?(node) - validate_platform node - - CoreSKU.constants.any? { |c| CoreSKU.const_get(c) == node['kernel']['os_info']['operating_system_sku'] } - end - - # Determines whether current node is a workstation version - def self.workstation_version?(node) - validate_platform node - node['kernel']['os_info']['product_type'] == ProductType::WORKSTATION - end - - # Determines whether current node is a server version - def self.server_version?(node) - !workstation_version?(node) - end - - # Determines NT version of the current node - def self.nt_version(node) - validate_platform node - - node['platform_version'].to_f - end - - def self.validate_platform(node) - raise 'Windows helper are only supported on windows platform!' unless node['platform'] == 'windows' - end - end -end diff --git a/vendor-cookbooks/windows/libraries/windows_helper.rb b/vendor-cookbooks/windows/libraries/windows_helper.rb deleted file mode 100644 index 97ec431..0000000 --- a/vendor-cookbooks/windows/libraries/windows_helper.rb +++ /dev/null @@ -1,165 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: windows -# Library:: windows_helper -# -# Copyright:: 2011-2018, Chef Software, Inc. -# -# 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. - -require 'uri' -require 'chef/exceptions' -require 'openssl' -require 'chef/mixin/powershell_out' -require 'chef/mixin/windows_env_helper' -require 'chef/util/path_helper' - -module Windows - module Helper - AUTO_RUN_KEY = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'.freeze unless defined?(AUTO_RUN_KEY) - ENV_KEY = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'.freeze unless defined?(ENV_KEY) - include Chef::Mixin::WindowsEnvHelper - - # returns windows friendly version of the provided path, - # ensures backslashes are used everywhere - def win_friendly_path(path) - Chef::Log.warn('The win_friendly_path helper has been deprecated and will be removed from the next major release of the windows cookbook. Please update any cookbooks using this helper to instead require `chef/util/path_helper` and then use `Chef::Util::PathHelper.cleanpath`.') - path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path - end - - # account for Window's wacky File System Redirector - # http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx - # especially important for 32-bit processes (like Ruby) on a - # 64-bit instance of Windows. - def locate_sysnative_cmd(cmd) - if ::File.exist?("#{ENV['WINDIR']}\\sysnative\\#{cmd}") - "#{ENV['WINDIR']}\\sysnative\\#{cmd}" - elsif ::File.exist?("#{ENV['WINDIR']}\\system32\\#{cmd}") - "#{ENV['WINDIR']}\\system32\\#{cmd}" - else - cmd - end - end - - # singleton instance of the Windows Version checker - def win_version - @win_version ||= Windows::Version.new - end - - # Helper function to properly parse a URI - def as_uri(source) - URI.parse(source) - rescue URI::InvalidURIError - Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters") - URI.parse(URI.escape(source)) - end - - # if a file is local it returns a windows friendly path version - # if a file is remote it caches it locally - def cached_file(source, checksum = nil, windows_path = true) - @installer_file_path ||= begin - - if source =~ %r{^(file|ftp|http|https):\/\/} - uri = as_uri(source) - cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(::URI.unescape(uri.path))}" - Chef::Log.debug("Caching a copy of file #{source} at #{cache_file_path}") - remote_file cache_file_path do - source source - backup false - checksum checksum unless checksum.nil? - end.run_action(:create) - else - cache_file_path = source - end - - windows_path ? Chef::Util::PathHelper.cleanpath(cache_file_path) : cache_file_path - end - end - - # Expands the environment variables - def expand_env_vars(path) - # The windows Env provider does not correctly expand variables in - # the PATH environment variable. Ruby expects these to be expanded. - # Using Chef::Mixin::WindowsEnvHelper - expand_path(path) - end - - def is_package_installed?(package_name) # rubocop:disable Naming/PredicateName - installed_packages.include?(package_name) - end - - def installed_packages - @installed_packages || begin - installed_packages = {} - # Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall - installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE)) # rescue nil - # 64-bit registry view - # Computer\HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall - installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100))) # rescue nil - # 32-bit registry view - # Computer\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall - installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0200))) # rescue nil - # Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall - installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_CURRENT_USER)) # rescue nil - installed_packages - end - end - - # Returns an array - def to_array(var) - var = var.is_a?(Array) ? var : [var] - var.reject(&:nil?) - end - - private - - def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ) - uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall' - packages = {} - begin - ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg| - reg.each_key do |key, _wtime| - begin - k = reg.open(key, desired) - display_name = begin - k['DisplayName'] - rescue - nil - end - version = begin - k['DisplayVersion'] - rescue - 'NO VERSION' - end - uninstall_string = begin - k['UninstallString'] - rescue - nil - end - if display_name - packages[display_name] = { name: display_name, - version: version, - uninstall_string: uninstall_string } - end - rescue ::Win32::Registry::Error - end - end - end - rescue ::Win32::Registry::Error - end - packages - end - end -end - -Chef::Recipe.send(:include, Windows::Helper) diff --git a/vendor-cookbooks/windows/libraries/windows_privileged.rb b/vendor-cookbooks/windows/libraries/windows_privileged.rb deleted file mode 100644 index 68d96c3..0000000 --- a/vendor-cookbooks/windows/libraries/windows_privileged.rb +++ /dev/null @@ -1,103 +0,0 @@ -# -# Author:: Doug MacEachern -# Author:: Paul Morton () -# Cookbook:: windows -# Library:: windows_privileged -# -# Copyright:: 2010-2017, VMware, Inc. -# Copyright:: 2011-2017, Business Intelligence Associates, Inc -# -# 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. -# - -# helpers for Windows API calls that require privilege adjustments -class Chef - class WindowsPrivileged - # File -> Load Hive... in regedit.exe - def reg_load_key(name, file) - load_deps - - run(SE_BACKUP_NAME, SE_RESTORE_NAME) do - rc = RegLoadKey(HKEY_USERS, name.to_s, file) - if rc == ERROR_SUCCESS - return true - elsif rc == ERROR_SHARING_VIOLATION - return false - else - raise get_last_error(rc) - end - end - end - - # File -> Unload Hive... in regedit.exe - def reg_unload_key(name) - load_deps - - run(SE_BACKUP_NAME, SE_RESTORE_NAME) do - rc = RegUnLoadKey(HKEY_USERS, name.to_s) - raise get_last_error(rc) if rc != ERROR_SUCCESS - end - end - - def run(*privileges) - load_deps - - token = [0].pack('L') - - unless OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, token) - raise get_last_error - end - token = token.unpack1('L') - - privileges.each do |name| - unless adjust_privilege(token, name, SE_PRIVILEGE_ENABLED) - raise get_last_error - end - end - - begin - yield - ensure # disable privs - privileges.each do |name| - adjust_privilege(token, name, 0) - end - end - end - - def adjust_privilege(token, priv, attr = 0) - load_deps - - luid = [0, 0].pack('Ll') - if LookupPrivilegeValue(nil, priv, luid) - new_state = [1, luid.unpack('Ll'), attr].flatten.pack('LLlL') - AdjustTokenPrivileges(token, 0, new_state, new_state.size, 0, 0) - end - end - - private - - def load_deps - if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'windows/error' - require 'windows/registry' - require 'windows/process' - require 'windows/security' - - include Windows::Error - include Windows::Registry - include Windows::Process - include Windows::Security - end - end - end -end diff --git a/vendor-cookbooks/windows/libraries/wmi_helper.rb b/vendor-cookbooks/windows/libraries/wmi_helper.rb deleted file mode 100644 index 2acdc38..0000000 --- a/vendor-cookbooks/windows/libraries/wmi_helper.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# Author:: Adam Edwards () -# Cookbook:: windows -# Library:: wmi_helper -# -# Copyright:: 2014-2018, Chef Software, Inc. -# -# 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. -# - -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'win32ole' - - def execute_wmi_query(wmi_query) - wmi = ::WIN32OLE.connect('winmgmts://') - result = wmi.ExecQuery(wmi_query) - return nil unless result.each.count > 0 - result - end - - def wmi_object_property(wmi_object, wmi_property) - wmi_object.send(wmi_property) - end -end diff --git a/vendor-cookbooks/windows/metadata.json b/vendor-cookbooks/windows/metadata.json deleted file mode 100644 index 4f17644..0000000 --- a/vendor-cookbooks/windows/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"windows","version":"7.0.0","description":"Provides a set of useful Windows-specific primitives.","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/windows","issues_url":"https://github.com/chef-cookbooks/windows/issues","chef_version":[[">= 14.7"]],"ohai_version":[]} \ No newline at end of file diff --git a/vendor-cookbooks/windows/metadata.rb b/vendor-cookbooks/windows/metadata.rb deleted file mode 100644 index 7841d55..0000000 --- a/vendor-cookbooks/windows/metadata.rb +++ /dev/null @@ -1,10 +0,0 @@ -name 'windows' -maintainer 'Chef Software, Inc.' -maintainer_email 'cookbooks@chef.io' -license 'Apache-2.0' -description 'Provides a set of useful Windows-specific primitives.' -version '7.0.0' -supports 'windows' -source_url 'https://github.com/chef-cookbooks/windows' -issues_url 'https://github.com/chef-cookbooks/windows/issues' -chef_version '>= 14.7' diff --git a/vendor-cookbooks/windows/providers/dns.rb b/vendor-cookbooks/windows/providers/dns.rb deleted file mode 100644 index fae9858..0000000 --- a/vendor-cookbooks/windows/providers/dns.rb +++ /dev/null @@ -1,148 +0,0 @@ -# -# Author:: Richard Lavey (richard.lavey@calastone.com) -# Cookbook:: windows -# Provider:: dns -# -# Copyright:: 2015, Calastone Ltd. -# -# 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. -# - -# See this for info on DNSCMD -# https://technet.microsoft.com/en-gb/library/cc772069.aspx#BKMK_10 - -include Windows::Helper - -action :create do - if @current_resource.exists - needs_change = (@new_resource.record_type != @current_resource.record_type) || - (@new_resource.ttl > 0 && @new_resource.ttl != @current_resource.ttl) || - (@new_resource.target.is_a?(String) && @new_resource.target != @current_resource.target) || - (@new_resource.target.is_a?(Array) && !(@new_resource.target - @current_resource.target).empty?) - - if needs_change - converge_by("Changing #{@new_resource.host_name}") do - update_dns - end - else - Chef::Log.debug("#{@new_resource.host_name} already exists - nothing to do") - end - else - converge_by("Creating #{@new_resource.host_name}") do - update_dns - end - end -end - -action :delete do - if @current_resource.exists - converge_by("Deleting #{@current_resource.host_name}") do - execute_command! 'recorddelete', "#{@current_resource.record_type} /f" - end - else - Chef::Log.debug("#{@new_resource.host_name} does not exist - nothing to do") - end -end - -def load_current_resource - # validate the new resource params : A records should be an array - if @new_resource.record_type == 'A' && @new_resource.target.is_a?(String) - raise 'target property must be an array for record_type A' - end - - @current_resource = Chef::Resource::WindowsDns.new(@new_resource.name) - @current_resource.host_name(@new_resource.host_name) - @current_resource.dns_server(@new_resource.dns_server) - - parts = @current_resource.host_name.scan(/(\w+)\.(.*)/) - @host = parts[0][0] - @domain = parts[0][1] - - fetch_attributes -end - -private - -def fetch_attributes - @command = locate_sysnative_cmd('dnscmd.exe') - cmd = shell_out("#{@command} #{@current_resource.dns_server} /enumrecords #{@domain} #{@host}") - Chef::Log.debug "dnscmd reports: #{cmd.stdout}" - - # extract values from returned text - if cmd.stdout.include?('DNS_ERROR_NAME_DOES_NOT_EXIST') - @current_resource.exists = false - @current_resource.target([]) - elsif cmd.exitstatus == 0 - @current_resource.exists = true - - m = cmd.stdout.scan(/(\d+)\s(A)\s+(\d+\.\d+\.\d+\.\d+)/) - if m.empty? - m = cmd.stdout.scan(/(\d+)\s(CNAME)\s+((?:\w+\.)+)/) - if m.empty? - @current_resource.exists = false - @current_resource.target([]) - else - # We have a cname record - @current_resource.record_type('CNAME') - @current_resource.ttl(m[0][0].to_i) - @current_resource.target(m[0][2].chomp('.')) - end - else - # we have A entries - @current_resource.record_type('A') - @current_resource.ttl(m[0][0].to_i) - addresses = [] - m.each do |match| - addresses.push(match[2]) - end - @current_resource.target(addresses) - end - else - raise "dnscmd returned error #{cmd.exitstatus} : #{cmd.stderr} #{cmd.stdout}" - end -end - -def update_dns - ttl = @new_resource.ttl if @new_resource.ttl > 0 - - if @current_resource.record_type != @new_resource.record_type - # delete current record(s) as we're changing the type - execute_command! 'recorddelete', "#{@current_resource.record_type} /f" - end - - if @new_resource.record_type == 'A' - # delete existing records that are no longer defined - (@current_resource.target - @new_resource.target).each do |address| - Chef::Log.info "Deleting #{address}" - execute_command! 'recorddelete', "A #{address} /f" - end - - # add new records that don't exist - # if ttl has changed then update all records - addresses = if @current_resource.ttl == @new_resource.ttl - (@new_resource.target - @current_resource.target) - else - @new_resource.target - end - addresses.each do |address| - Chef::Log.info "Adding/Changing #{address}" - execute_command! 'recordadd', "#{ttl} A #{address}" - end - else - execute_command! 'recordadd', "#{ttl} CNAME #{@new_resource.target}" - end -end - -def execute_command!(mode, options) - shell_out!("#{@command} #{@current_resource.dns_server} /#{mode} #{@domain} #{@host} #{options}") -end diff --git a/vendor-cookbooks/windows/recipes/default.rb b/vendor-cookbooks/windows/recipes/default.rb deleted file mode 100644 index 73845f6..0000000 --- a/vendor-cookbooks/windows/recipes/default.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook:: windows -# Recipe:: default -# -# Copyright:: 2011-2018, Chef Software, Inc. -# -# 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. -# - -Chef::Log.warn('The windows::default recipe has been deprecated. The gems previously installed in this recipe ship in the Chef MSI.') diff --git a/vendor-cookbooks/windows/resources/certificate_binding.rb b/vendor-cookbooks/windows/resources/certificate_binding.rb deleted file mode 100644 index 5d908ec..0000000 --- a/vendor-cookbooks/windows/resources/certificate_binding.rb +++ /dev/null @@ -1,134 +0,0 @@ -# -# Author:: Richard Lavey (richard.lavey@calastone.com) -# Cookbook:: windows -# Resource:: certificate_binding -# -# Copyright:: 2015-2017, Calastone Ltd. -# Copyright:: 2018, Chef Software, Inc. -# -# 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. -# - -include Windows::Helper - -property :cert_name, String, name_property: true -property :name_kind, Symbol, equal_to: [:hash, :subject], default: :subject -property :address, String, default: '0.0.0.0' -property :port, Integer, default: 443 -property :app_id, String, default: '{4dc3e181-e14b-4a21-b022-59fc669b0914}' -property :store_name, String, default: 'MY', equal_to: ['TRUSTEDPUBLISHER', 'CLIENTAUTHISSUER', 'REMOTE DESKTOP', 'ROOT', 'TRUSTEDDEVICES', 'WEBHOSTING', 'CA', 'AUTHROOT', 'TRUSTEDPEOPLE', 'MY', 'SMARTCARDROOT', 'TRUST'] -property :exists, [true, false] - -load_current_value do |desired| - mode = desired.address.match(/(\d+\.){3}\d+|\[.+\]/).nil? ? 'hostnameport' : 'ipport' - cmd = shell_out("#{locate_sysnative_cmd('netsh.exe')} http show sslcert #{mode}=#{desired.address}:#{desired.port}") - Chef::Log.debug "netsh reports: #{cmd.stdout}" - - address desired.address - port desired.port - store_name desired.store_name - app_id desired.app_id - - if cmd.exitstatus == 0 - m = cmd.stdout.scan(/Certificate Hash\s+:\s?([A-Fa-f0-9]{40})/) - raise "Failed to extract hash from command output #{cmd.stdout}" if m.empty? - cert_name m[0][0] - name_kind :hash - exists true - else - exists false - end -end - -action :create do - hash = new_resource.name_kind == :subject ? hash_from_subject : new_resource.cert_name - - if current_resource.exists - needs_change = (hash.casecmp(current_resource.cert_name) != 0) - - if needs_change - converge_by("Changing #{current_resource.address}:#{current_resource.port}") do - delete_binding - add_binding hash - end - else - Chef::Log.debug("#{new_resource.address}:#{new_resource.port} already bound to #{hash} - nothing to do") - end - else - converge_by("Binding #{new_resource.address}:#{new_resource.port}") do - add_binding hash - end - end -end - -action :delete do - if current_resource.exists - converge_by("Deleting #{current_resource.address}:#{current_resource.port}") do - delete_binding - end - else - Chef::Log.debug("#{current_resource.address}:#{current_resource.port} not bound - nothing to do") - end -end - -action_class do - def netsh_command - locate_sysnative_cmd('netsh.exe') - end - - def add_binding(hash) - cmd = "#{netsh_command} http add sslcert" - mode = address_mode(current_resource.address) - cmd << " #{mode}=#{current_resource.address}:#{current_resource.port}" - cmd << " certhash=#{hash}" - cmd << " appid=#{current_resource.app_id}" - cmd << " certstorename=#{current_resource.store_name}" - check_hash hash - - shell_out!(cmd) - end - - def delete_binding - mode = address_mode(current_resource.address) - shell_out!("#{netsh_command} http delete sslcert #{mode}=#{current_resource.address}:#{current_resource.port}") - end - - def check_hash(hash) - p = powershell_out!("Test-Path \"cert:\\LocalMachine\\#{current_resource.store_name}\\#{hash}\"") - - unless p.stderr.empty? && p.stdout =~ /True/i - raise "A Cert with hash of #{hash} doesn't exist in keystore LocalMachine\\#{current_resource.store_name}" - end - nil - end - - def hash_from_subject - # escape wildcard subject name (*.acme.com) - subject = new_resource.cert_name.sub(/\*/, '`*') - ps_script = "& { gci cert:\\localmachine\\#{new_resource.store_name} | where { $_.subject -like '*#{subject}*' } | select -first 1 -expandproperty Thumbprint }" - - Chef::Log.debug "Running PS script #{ps_script}" - p = powershell_out!(ps_script) - - raise "#{ps_script} failed with #{p.stderr}" if !p.stderr.nil? && !p.stderr.empty? - raise "Couldn't find thumbprint for subject #{new_resource.cert_name}" if p.stdout.nil? || p.stdout.empty? - - # seem to get a UTF-8 string with BOM returned sometimes! Strip any such BOM - hash = p.stdout.strip - hash[0].ord == 239 ? hash.force_encoding('UTF-8').delete!("\xEF\xBB\xBF".force_encoding('UTF-8')) : hash - end - - def address_mode(address) - address.match(/(\d+\.){3}\d+|\[.+\]/).nil? ? 'hostnameport' : 'ipport' - end -end diff --git a/vendor-cookbooks/windows/resources/dns.rb b/vendor-cookbooks/windows/resources/dns.rb deleted file mode 100644 index 30149d4..0000000 --- a/vendor-cookbooks/windows/resources/dns.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Author:: Richard Lavey (richard.lavey@calastone.com) -# Cookbook:: windows -# Resource:: dns -# -# Copyright:: 2015, Calastone Ltd. -# -# 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. -# - -default_action :create - -attribute :host_name, kind_of: String, required: true -attribute :record_type, kind_of: String, default: 'A', regex: /^(?:A|CNAME)$/ -attribute :dns_server, kind_of: String, default: '.' -attribute :target, kind_of: [Array, String], required: true -attribute :ttl, kind_of: Integer, required: false, default: 0 - -attr_accessor :exists diff --git a/vendor-cookbooks/windows/resources/http_acl.rb b/vendor-cookbooks/windows/resources/http_acl.rb deleted file mode 100644 index b78f126..0000000 --- a/vendor-cookbooks/windows/resources/http_acl.rb +++ /dev/null @@ -1,109 +0,0 @@ -# -# Author:: Richard Lavey (richard.lavey@calastone.com) -# Cookbook:: windows -# Resource:: http_acl -# -# Copyright:: 2015-2017, Calastone Ltd. -# -# 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. -# - -include Windows::Helper - -property :url, String, name_property: true -property :user, String -property :sddl, String -property :exists, [true, false] - -# See https://msdn.microsoft.com/en-us/library/windows/desktop/cc307236%28v=vs.85%29.aspx for netsh info - -load_current_value do |desired| - cmd_out = shell_out!("#{locate_sysnative_cmd('netsh.exe')} http show urlacl url=#{desired.url}").stdout - Chef::Log.debug "netsh reports: #{cmd_out}" - - if cmd_out.include? desired.url - exists true - url desired.url - # Checks first for sddl, because it generates user(s) - sddl_match = cmd_out.match(/SDDL:\s*(?\S+)/) - if sddl_match - sddl sddl_match['sddl'] - else - # if no sddl, tries to find a single user - user_match = cmd_out.match(/User:\s*(?.+)/) - user user_match['user'] - end - else - exists false - end -end - -action :create do - raise '`user` xor `sddl` can\'t be used together' if new_resource.user && new_resource.sddl - raise 'When provided user property can\'t be empty' if new_resource.user && new_resource.user.empty? - raise 'When provided sddl property can\'t be empty' if new_resource.sddl && new_resource.sddl.empty? - - if current_resource.exists - sddl_changed = ( - new_resource.sddl && - current_resource.sddl && - current_resource.sddl.casecmp(new_resource.sddl) != 0 - ) - user_changed = ( - new_resource.user && - current_resource.user && - current_resource.user.casecmp(new_resource.user) != 0 - ) - - if sddl_changed || user_changed - converge_by("Changing #{new_resource.url}") do - delete_acl - apply_acl - end - else - Chef::Log.debug("#{new_resource.url} already set - nothing to do") - end - else - converge_by("Setting #{new_resource.url}") do - apply_acl - end - end -end - -action :delete do - if current_resource.exists - converge_by("Deleting #{new_resource.url}") do - delete_acl - end - else - Chef::Log.debug("#{new_resource.url} does not exist - nothing to do") - end -end - -action_class do - def netsh_command - locate_sysnative_cmd('netsh.exe') - end - - def apply_acl - if current_resource.sddl - shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} sddl=\"#{new_resource.sddl}\"") - else - shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} user=\"#{new_resource.user}\"") - end - end - - def delete_acl - shell_out!("#{netsh_command} http delete urlacl url=#{new_resource.url}") - end -end diff --git a/vendor-cookbooks/windows/resources/schannel.rb b/vendor-cookbooks/windows/resources/schannel.rb deleted file mode 100644 index d608601..0000000 --- a/vendor-cookbooks/windows/resources/schannel.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Author:: Jason Field (jason.field@calastone.com) -# Cookbook:: windows -# Resource:: schannel -# -# Copyright:: 2019, Calastone Ltd. -# -# 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. -# - -property :use_strong_crypto, [true, false], default: true - -action :configure do - registry_key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\v4.0.30319' do - values [{ - name: 'SchUseStrongCrypto', - type: :dword, - data: new_resource.use_strong_crypto ? 1 : 0, - }] - end - - registry_key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\.NETFramework\\v4.0.30319' do - values [{ - name: 'SchUseStrongCrypto', - type: :dword, - data: new_resource.use_strong_crypto ? 1 : 0, - }] - end -end diff --git a/vendor-cookbooks/windows/resources/user_privilege.rb b/vendor-cookbooks/windows/resources/user_privilege.rb deleted file mode 100644 index 2264ded..0000000 --- a/vendor-cookbooks/windows/resources/user_privilege.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Author:: Jared Kauppila () -# Cookbook:: windows -# Resource:: user_privilege -# - -property :principal, String, name_property: true -property :privilege, [Array, String], required: true, coerce: proc { |v| [*v].sort } - -action :add do - ([*new_resource.privilege] - [*current_resource.privilege]).each do |user_right| - converge_by("adding user privilege #{user_right}") do - Chef::ReservedNames::Win32::Security.add_account_right(new_resource.principal, user_right) - end - end -end - -action :remove do - if Gem::Version.new(Chef::VERSION) < Gem::Version.new('14.4.10') - Chef::Log.warn('Chef 14.4.10 is required to use windows_privilege remove action') - else - curr_res_privilege = current_resource.privilege - new_res_privilege = new_resource.privilege - missing_res_privileges = (new_res_privilege - curr_res_privilege) - - if missing_res_privileges - Chef::Log.info("Privilege: #{missing_res_privileges.join(', ')} not present. Unable to delete") - end - - (new_res_privilege - missing_res_privileges).each do |user_right| - converge_by("removing user privilege #{user_right}") do - Chef::ReservedNames::Win32::Security.remove_account_right(new_resource.principal, user_right) - end - end - end -end - -load_current_value do |desired| - privilege Chef::ReservedNames::Win32::Security.get_account_right(desired.principal) -end diff --git a/vendor-cookbooks/windows/resources/zipfile.rb b/vendor-cookbooks/windows/resources/zipfile.rb deleted file mode 100644 index f182b5a..0000000 --- a/vendor-cookbooks/windows/resources/zipfile.rb +++ /dev/null @@ -1,128 +0,0 @@ -# -# Author:: Doug MacEachern () -# Author:: Seth Chisamore () -# Author:: Wade Peacock () -# Cookbook:: windows -# Resource:: zipfile -# -# Copyright:: 2010-2017, VMware, Inc. -# Copyright:: 2011-2018, Chef Software, Inc. -# -# 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. -# - -require 'chef/util/path_helper' - -property :path, String, name_property: true -property :source, String -property :overwrite, [true, false], default: false -property :checksum, String - -action :unzip do - ensure_rubyzip_gem_installed - Chef::Log.debug("unzip #{new_resource.source} => #{new_resource.path} (overwrite=#{new_resource.overwrite})") - - cache_file_path = if new_resource.source =~ %r{^(file|ftp|http|https):\/\/} # http://rubular.com/r/DGoIWjLfGI - uri = as_uri(new_resource.source) - local_cache_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(::URI.unescape(uri.path))}" - Chef::Log.debug("Caching a copy of file #{new_resource.source} at #{cache_file_path}") - - remote_file local_cache_path do - source new_resource.source - backup false - checksum new_resource.checksum unless new_resource.checksum.nil? - end - - local_cache_path - else - new_resource.source - end - - cache_file_path = Chef::Util::PathHelper.cleanpath(cache_file_path) - - converge_by("unzip #{new_resource.source}") do - ruby_block 'Unzipping' do - block do - Zip::File.open(cache_file_path) do |zip| - zip.each do |entry| - path = ::File.join(new_resource.path, entry.name) - FileUtils.mkdir_p(::File.dirname(path)) - if new_resource.overwrite && ::File.exist?(path) && !::File.directory?(path) - FileUtils.rm(path) - end - zip.extract(entry, path) unless ::File.exist?(path) - end - end - end - action :run - end - end -end - -action :zip do - ensure_rubyzip_gem_installed - # sanitize paths for windows. - new_resource.source.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) - new_resource.path.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) - Chef::Log.debug("zip #{new_resource.source} => #{new_resource.path} (overwrite=#{new_resource.overwrite})") - - if new_resource.overwrite == false && ::File.exist?(new_resource.path) - Chef::Log.info("file #{new_resource.path} already exists and overwrite is set to false, exiting") - else - # delete the archive if it already exists, because we are recreating it. - if ::File.exist?(new_resource.path) - converge_by("delete existing file at #{new_resource.path}") do - ::File.unlink(new_resource.path) - end - end - - # only supporting compression of a single directory (recursively). - if ::File.directory?(new_resource.source) - converge_by("zipping #{new_resource.source} to #{new_resource.path}") do - z = Zip::File.new(new_resource.path, true) - unless new_resource.source =~ /::File::ALT_SEPARATOR$/ - new_resource.source << ::File::ALT_SEPARATOR - end - Find.find(new_resource.source) do |f| - f.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) - # don't add root directory to the zipfile. - next if f == new_resource.source - # strip the root directory from the filename before adding it to the zipfile. - zip_fname = f.sub(new_resource.source, '') - Chef::Log.debug("adding #{zip_fname} to archive, sourcefile is: #{f}") - z.add(zip_fname, f) - end - z.close - end - else - Chef::Log.info("Single directory must be specified for compression, and #{new_resource.source} does not meet that criteria.") - end - end -end - -action_class do - include Windows::Helper - require 'find' - - def ensure_rubyzip_gem_installed - require 'zip' - Chef::Log.warn('The windows_zipfile resource has been deprecated as Chef Infra Client 15.0 shipped with a new archive_file resource, which natively handles multiple archive formats. Please update any cookbooks using this resource to instead use the `archive_file` resource: https://docs.chef.io/resource_archive_file.html') - rescue LoadError - Chef::Log.info("Missing gem 'rubyzip'...installing now.") - chef_gem 'rubyzip' do - action :install - compile_time true - end - require 'zip' - end -end From 39035cb9058fb888eacefabdbbbc8c2b8a4d43ea Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 28 Apr 2020 14:33:37 -0700 Subject: [PATCH 5/9] Addressing PR Feedback --- .chef-repo.txt | 6 -- .chef/solo.rb | 6 -- chefignore => cookbooks/chefignore | 0 cookbooks/ros2_windows/README.md | 4 +- .../attributes/{default.rb => ros2.rb} | 26 ++----- .../ros2_windows/attributes/visual_studio.rb | 0 .../recipes/chocolatey_installs.rb | 50 ++++--------- .../ros2_windows/recipes/pip_installs.rb | 70 +++++++++---------- cookbooks/ros2_windows/recipes/ros2.rb | 37 +--------- .../ros2_windows/recipes/ros2_sources.rb | 22 ++++++ cookbooks/ros2_windows/recipes/rti_connext.rb | 62 +++++++--------- .../ros2_windows/recipes/visual_studio.rb | 12 ++-- 12 files changed, 112 insertions(+), 183 deletions(-) delete mode 100644 .chef-repo.txt delete mode 100644 .chef/solo.rb rename chefignore => cookbooks/chefignore (100%) rename cookbooks/ros2_windows/attributes/{default.rb => ros2.rb} (68%) create mode 100644 cookbooks/ros2_windows/attributes/visual_studio.rb create mode 100644 cookbooks/ros2_windows/recipes/ros2_sources.rb diff --git a/.chef-repo.txt b/.chef-repo.txt deleted file mode 100644 index 7ee3446..0000000 --- a/.chef-repo.txt +++ /dev/null @@ -1,6 +0,0 @@ -.chef-repo.txt -============== - -This file gives ChefDK's generators a hint that you are using a Chef Repo and -this is the root directory of your Chef Repo. ChefDK's generators use this to -generate code that is designed to work with the Chef Repo workflow. diff --git a/.chef/solo.rb b/.chef/solo.rb deleted file mode 100644 index e115936..0000000 --- a/.chef/solo.rb +++ /dev/null @@ -1,6 +0,0 @@ -a_repo_dir = File.expand_path("../..", __FILE__) -cookbook_path [File.join(a_repo_dir, "vendor-cookbooks"), File.join(a_repo_dir, "cookbooks")] -data_bag_path File.join(a_repo_dir, "data_bags") -role_path File.join(a_repo_dir, "roles") -environment_path File.join(a_repo_dir, "environments") -solo true diff --git a/chefignore b/cookbooks/chefignore similarity index 100% rename from chefignore rename to cookbooks/chefignore diff --git a/cookbooks/ros2_windows/README.md b/cookbooks/ros2_windows/README.md index 05b3a85..4be28b5 100644 --- a/cookbooks/ros2_windows/README.md +++ b/cookbooks/ros2_windows/README.md @@ -21,9 +21,7 @@ In same shell, install chocolatey and git > restart-computer ``` -After the computer restarts, in the cmd shell (not powershell) run the following: - -This will open a GUI to input your github credentials +After the computer restarts, in the cmd shell (not powershell) clone this repo: ``` > git clone https://github.com/ros-infrastructure/ros2-cookbooks ``` diff --git a/cookbooks/ros2_windows/attributes/default.rb b/cookbooks/ros2_windows/attributes/ros2.rb similarity index 68% rename from cookbooks/ros2_windows/attributes/default.rb rename to cookbooks/ros2_windows/attributes/ros2.rb index 1a05699..77f3b16 100644 --- a/cookbooks/ros2_windows/attributes/default.rb +++ b/cookbooks/ros2_windows/attributes/ros2.rb @@ -1,5 +1,9 @@ -# True if setting up machine for ros2 development or false for binaries only -default['ros2_windows']['development'] = false +# github.com/ros2/ros2 branch version, "master", "dashing", "dashing-release", etc. +# Only used if downloading sources +default['ros2_windows']['source']['ros2.repos'] = 'master' + +# Location of ros2 workspace +default['ros2_windows']['ros2_ws'] = 'C:\\dev\\ros2_ws' # ROS 2 binary versions, dashing/eloquent/foxy etc default['ros2_windows']['release_version'] = 'eloquent' @@ -7,26 +11,8 @@ # Binary build version, 'release' or 'debug' default['ros2_windows']['build_type'] = 'release' -# In development, also download ros2 sources -default['ros2_windows']['download_sources'] = true - -# Visual studio version, "buildtools" or "community" -default['ros2_windows']['vs_version'] = 'buildtools' - -# github.com/ros2/ros2 branch version, "master", "dashing", "dashing-release", etc. -# Only used if downloading sources -default['ros2_windows']['source']['ros2.repos'] = 'master' - -# Location of ros2 workspace, used for both development/binary configurations -default['ros2_windows']['ros2_ws'] = 'C:\\dev\\ros2_ws' - # Current binary locations, update as new releases become available default['ros2_windows']['eloquent']['release'] = 'https://github.com/ros2/ros2/releases/download/release-eloquent-20191122/ros2-eloquent-20191122-windows-release-amd64.zip' default['ros2_windows']['eloquent']['debug'] = 'https://github.com/ros2/ros2/releases/download/release-eloquent-20191122/ros2-eloquent-20191122-windows-debug-amd64.zip' default['ros2_windows']['dashing']['release'] = 'https://github.com/ros2/ros2/releases/download/release-dashing-20200319/ros2-dashing-20200319-windows-amd64.zip' default['ros2_windows']['dashing']['debug'] = 'https://github.com/ros2/ros2/releases/download/release-dashing-20200319/ros2-dashing-20200319-windows-debug-amd64.zip' - -# Install additional DDS vendors -default['ros2_windows']['install_opensplice'] = false - -default['ros2_windows']['install_connext'] = false diff --git a/cookbooks/ros2_windows/attributes/visual_studio.rb b/cookbooks/ros2_windows/attributes/visual_studio.rb new file mode 100644 index 0000000..e69de29 diff --git a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb index 8528e01..157570b 100644 --- a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb +++ b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb @@ -11,43 +11,23 @@ action :modify end -# Custom choco packages -remote_file 'asio.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/asio.1.12.1.nupkg' - action :create -end - -remote_file 'bullet.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2020-02-24/bullet.2.89.0.nupkg' - action :create -end - -remote_file 'cunit.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/cunit.2.1.3.nupkg' - action :create -end - -remote_file 'eigen.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/eigen.3.3.4.nupkg' - action :create -end - -remote_file 'log4cxx.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/log4cxx.0.10.0.nupkg' - action :create -end - -remote_file 'tinyxml-usestl.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/tinyxml-usestl.2.6.2.nupkg' - action :create -end - -remote_file 'tinyxml2.nupkg' do - source 'https://github.com/ros2/choco-packages/releases/download/2019-10-24/tinyxml2.6.0.0.nupkg' - action :create +custom_chocolatey_packages = %w[ + asio.1.12.1 + bullet.2.89.0 + cunit.2.1.3 + eigen.3.3.4 + log4cxx.0.10.0 + tinyxml-usestl.2.6.2 + tinyxml2.6.0.0 +] + +custom_chocolatey_packages.each do |pkg| + remote_file "#{pkg}.nupkg" do + source "https://github.com/ros2/choco-packages/releases/download/2020-02-24/#{pkg}.nupkg" + end end chocolatey_package 'custom_packages' do - package_name ['asio', 'bullet', 'cunit', 'eigen', 'tinyxml-usestl', 'tinyxml2', 'log4cxx'] + package_name *custom_chocolatey_packages.map{|pkg| pkg.split('.').first} source '.\\' end diff --git a/cookbooks/ros2_windows/recipes/pip_installs.rb b/cookbooks/ros2_windows/recipes/pip_installs.rb index 4a22892..516c00a 100644 --- a/cookbooks/ros2_windows/recipes/pip_installs.rb +++ b/cookbooks/ros2_windows/recipes/pip_installs.rb @@ -1,39 +1,39 @@ -required_pip_packages = [ - 'pydot', - 'PyQt5', - 'vcstool', - 'colcon-common-extensions', - 'catkin_pkg', - 'cryptography', - 'EmPy', - 'ifcfg', - 'lark-parser', - 'lxml', - 'netifaces', - 'numpy', - 'opencv-python', - 'pyparsing', - 'pyyaml', - 'pytest', - 'pytest-mock', - 'coverage', - 'mock' -] +required_pip_packages = %w( + pydot + PyQt5 + vcstool + colcon-common-extensions + catkin_pkg + cryptography + EmPy + ifcfg + lark-parser + lxml + netifaces + numpy + opencv-python + pyparsing + pyyaml + pytest + pytest-mock + coverage + mock +) -development_pip_packages = [ - 'flake8', - 'flake8-blind-except', - 'flake8-builtins', - 'flake8-class-newline', - 'flake8-comprehensions', - 'flake8-deprecated', - 'flake8-docstrings', - 'flake8-import-order', - 'flake8-quotes', - 'mypy', - 'pep8', - 'pydocstyle' -] +development_pip_packages = %w( + flake8 + flake8-blind-except + flake8-builtins + flake8-class-newline + flake8-comprehensions + flake8-deprecated + flake8-docstrings + flake8-import-order + flake8-quotes + mypy + pep8 + pydocstyle +) # Use explicit location because python may not be on the PATH if chef-solo has not been run before execute 'pip_update' do diff --git a/cookbooks/ros2_windows/recipes/ros2.rb b/cookbooks/ros2_windows/recipes/ros2.rb index 08a0af8..38fe4f5 100644 --- a/cookbooks/ros2_windows/recipes/ros2.rb +++ b/cookbooks/ros2_windows/recipes/ros2.rb @@ -1,5 +1,6 @@ - include_recipe 'chocolatey' + +# Using seven_zip also for general zip files because it can download and extract in a single resource include_recipe 'seven_zip' include_recipe 'ros2_windows::rti_connext' if node['ros2_windows']['install_connext'] == true @@ -10,38 +11,4 @@ include_recipe 'ros2_windows::chocolatey_installs' include_recipe 'ros2_windows::visual_studio' include_recipe 'ros2_windows::qt5' - -include_recipe 'ros2_windows::opensplice' if node['ros2_windows']['install_opensplice'] == true - -include_recipe 'ros2_windows::ros2_binaries' if node['ros2_windows']['development'] == false - -if node['ros2_windows']['download_sources'] == false then - return -end - include_recipe 'ros2_windows::xmllint' - -directory 'ros2_ws' do - path node['ros2_windows']['ros2_ws'] - action :create - recursive true -end - -ros2_src_dir = File.join(node['ros2_windows']['ros2_ws'], 'src') -directory 'ros2_ws_src' do - path ros2_src_dir - action :create - recursive true -end - -ros2_repos_path = File.join(node['ros2_windows']['ros2_ws'], 'ros2.repos') -print('https://raw.githubusercontent.com/ros2/ros2/%s/ros2.repos', node['ros2_windows']['source']['ros2.repos']) -remote_file 'ros2.repos' do - source sprintf('https://raw.githubusercontent.com/ros2/ros2/%s/ros2.repos', node['ros2_windows']['source']['ros2.repos']) - path ros2_repos_path - action :create -end - -execute 'vcs_import' do - command sprintf('C:\Python37\Scripts\vcs.exe import --input %s %s', ros2_repos_path, ros2_src_dir) -end diff --git a/cookbooks/ros2_windows/recipes/ros2_sources.rb b/cookbooks/ros2_windows/recipes/ros2_sources.rb new file mode 100644 index 0000000..70f4e91 --- /dev/null +++ b/cookbooks/ros2_windows/recipes/ros2_sources.rb @@ -0,0 +1,22 @@ +directory 'ros2_ws' do + path node['ros2_windows']['ros2_ws'] + action :create + recursive true +end + +ros2_src_dir = File.join(node['ros2_windows']['ros2_ws'], 'src') +directory 'ros2_ws_src' do + path ros2_src_dir + action :create + recursive true +end + +ros2_repos_path = File.join(node['ros2_windows']['ros2_ws'], 'ros2.repos') +remote_file 'ros2.repos' do + source "https://raw.githubusercontent.com/ros2/ros2/#{node['ros2_windows']['source']['ros2.repos']}/ros2.repos" + path ros2_repos_path +end + +execute 'vcs_import' do + command "C:\\Python37\\Scripts\\vcs.exe import --input #{ros2_repos_path} #{ros2_src_dir}" +end diff --git a/cookbooks/ros2_windows/recipes/rti_connext.rb b/cookbooks/ros2_windows/recipes/rti_connext.rb index 54f8775..32453a9 100644 --- a/cookbooks/ros2_windows/recipes/rti_connext.rb +++ b/cookbooks/ros2_windows/recipes/rti_connext.rb @@ -2,12 +2,10 @@ # These will fail if the rti_connext parameters have not been specified because the defaults are 'nil' assert(File.exists?(connext_params['license_file']), - sprintf('License file location does not exist: %s', - connext_params['license_file'])) + "License file location does not exist: #{connext_params['license_file']}") assert(Dir.exists?(connext_params['installer_dir']), - sprintf('Installer directory does not exist: %s', - connext_params['installer_dir'])) + "Installer directory does not exist: #{connext_params['installer_dir']}") )) assert_not_nil(connext_params['version'], "Version is nil, requires MAJOR.MINOR.PATCH (e.g. '5.3.1')") assert_not_nil(connext_params['edition'], "Edition is nil, requires one of ('evaluation', 'pro')") @@ -15,57 +13,47 @@ assert_not_nil(connext_params['openssl_version'], "OpenSSL version is required (e.g. '1.0.2n')") -host_installer_filename = sprintf('rti_connext_dds-%s-%s-host-%s.exe', - connext_params['version'], - connext_params['edition'], - connext_params['target_platform']) +host_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-host-#{connext_params['target_platform']}.exe") host_installer_path = File.join(connext_params['installer_dir'], host_installer_filename) target_platform_vs_version = connext_params['target_platform'] + 'VS' + connext_params['min_vs_version'] openssl_installer_path = File.join(connext_params['installer_dir'], - sprintf('openssl-%s-target-%s.zip', - connext_params['openssl_version'], - target_platform_vs_version)) - -target_installer_filename = sprintf('rti_connext_dds-%s-%s-target-%s.rtipkg', - connext_params['version'], - connext_params['edition'], - target_platform_vs_version) + "openssl-#{connext_params['openssl_version']}-target-#{target_platform_vs_version}.zip") + +target_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-target-#{target_platform_vs_version}.rtipkg" target_installer_path = File.join(connext_params['installer_dir'], target_installer_filename) rtipkginstall_bat = File.join('%ProgramFiles%', - sprintf('rti_connext_dds-%s', connext_params['version']), + "rti_connext_dds-#{connext_params['version']}", 'bin', 'rtipkginstall.bat') -security_plugins_host_filename = sprintf('rti_security_plugins-%s-host-%s.rtipkg', - connext_params['version'], - connext_params['target_platform']) +security_plugins_host_filename = "rti_security_plugins-#{connext_params['version']}-host-#{connext_params['target_platform']}.rtipkg") security_plugins_host_path = File.join(connext_params['installer_dir'], security_plugins_host_filename) -security_plugins_target_filename = sprintf('rti_security_plugins-%s-target-%s.rtipkg', - connext_params['version'], - target_platform_vs_version) +security_plugins_target_filename = "rti_security_plugins-#{connext_params['version']}-target-#{target_platform_vs_version}.rtipkg") security_plugins_target_path = File.join(connext_params['installer_dir'], security_plugins_target_filename) rti_openssl_base_dir = File.join('C:\\connext', - sprintf('openssl-%s', connext_params['openssl_version']), + "openssl-#{connext_params['openssl_version']}", target_platform_vs_version, 'release') -print "--------------------------RTI Connext Install params--------------------------" -print 'License file: ' + connext_params['license_file'] -print 'Host installer: ' + host_installer_path -print 'Target installer: ' + target_installer_path -print 'Openssl installer: ' + openssl_installer_path -print 'Host security plugins installer: ' + security_plugins_host_path -print 'Target security plugins installer: ' + security_plugins_target_path -print 'Installed openssl dir: ' + rti_openssl_base_dir -print 'rtipkg batch script: ' + rtipkginstall_bat -print "------------------------------------------------------------------------------" +log 'connext_install_message' do + message 'Using the following paths for RTI Connext install: ' + + 'License file: ' + connext_params['license_file'] + + ', Host installer: ' + host_installer_path + + ', Target installer: ' + target_installer_path + + ', Openssl installer: ' + openssl_installer_path + + ', Host security plugins installer: ' + security_plugins_host_path + + ', Target security plugins installer: ' + security_plugins_target_path + + ', Installed openssl dir: ' + rti_openssl_base_dir + + ', rtipkg batch script: ' + rtipkginstall_bat + level :info +end directory "C:\\connext" do path "C:\\connext" @@ -73,11 +61,11 @@ end execute 'copy_license_file' do - command sprintf('copy %s C:\\connext\\', connext_params['license_file']) + command "copy #{connext_params['license_file']} C:\\connext\\" end execute 'copy_connextdds_host' do - command sprintf('copy /b %s.??? %s', host_installer_path, host_installer_path) + command "copy /b #{host_installer_path}.??? #{host_installer_path}" end seven_zip_archive 'openssl_zip' do @@ -87,7 +75,7 @@ end execute 'copy_connextdds_target' do - command sprintf('copy /b %s.??? %s', target_installer_filename, target_installer_filename) + command "copy /b #{target_installer_filename}.??? #{target_installer_filename}" end windows_env 'RTI_LICENSE_FILE' do diff --git a/cookbooks/ros2_windows/recipes/visual_studio.rb b/cookbooks/ros2_windows/recipes/visual_studio.rb index 9d64741..b5f851d 100644 --- a/cookbooks/ros2_windows/recipes/visual_studio.rb +++ b/cookbooks/ros2_windows/recipes/visual_studio.rb @@ -2,12 +2,12 @@ # https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 # If BuildTools is not already installed, install it -packages_to_install = [ - 'Microsoft.Net.Component.4.8.SDK', - 'Microsoft.VisualStudio.Workload.VCTools', - 'Microsoft.Component.MSBuild', - 'Microsoft.VisualStudio.Component.VC.CLI.Support' -] +packages_to_install = %w( + Microsoft.Net.Component.4.8.SDK + Microsoft.VisualStudio.Workload.VCTools + Microsoft.Component.MSBuild + Microsoft.VisualStudio.Component.VC.CLI.Support +) if node['ros2_windows']['vs_version'] != 'buildtools' then packages_to_install += ['Microsoft.VisualStudio.Workload.NativeDesktop',] From 91f2bd35a2e0879c49258c4ba05dd60d3670f875 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 28 Apr 2020 15:42:50 -0700 Subject: [PATCH 6/9] Fixes --- .../ros2_windows/attributes/visual_studio.rb | 2 ++ .../recipes/chocolatey_installs.rb | 28 +++++++++---------- .../ros2_windows/recipes/visual_studio.rb | 4 +-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cookbooks/ros2_windows/attributes/visual_studio.rb b/cookbooks/ros2_windows/attributes/visual_studio.rb index e69de29..b0a5238 100644 --- a/cookbooks/ros2_windows/attributes/visual_studio.rb +++ b/cookbooks/ros2_windows/attributes/visual_studio.rb @@ -0,0 +1,2 @@ +# Visual studio version, "buildtools" or "community" +default['ros2_windows']['vs_version'] = 'buildtools' diff --git a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb index 157570b..912445b 100644 --- a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb +++ b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb @@ -11,23 +11,23 @@ action :modify end -custom_chocolatey_packages = %w[ - asio.1.12.1 - bullet.2.89.0 - cunit.2.1.3 - eigen.3.3.4 - log4cxx.0.10.0 - tinyxml-usestl.2.6.2 - tinyxml2.6.0.0 -] +custom_chocolatey_packages = { + 'asio' => 'asio.1.12.1', + 'bullet' => 'bullet.2.89.0', + 'cunit' => 'cunit.2.1.3', + 'eigen' => 'eigen.3.3.4', + 'log4cxx' => 'log4cxx.0.10.0', + 'tinyxml-usestl' => 'tinyxml-usestl.2.6.2', + 'tinyxml2' => 'tinyxml2.6.0.0' +} -custom_chocolatey_packages.each do |pkg| +custom_chocolatey_packages.each do |name, pkg| remote_file "#{pkg}.nupkg" do source "https://github.com/ros2/choco-packages/releases/download/2020-02-24/#{pkg}.nupkg" end -end -chocolatey_package 'custom_packages' do - package_name *custom_chocolatey_packages.map{|pkg| pkg.split('.').first} - source '.\\' + chocolatey_package 'custom_packages' do + package_name "#{name}" + source '.\\' + end end diff --git a/cookbooks/ros2_windows/recipes/visual_studio.rb b/cookbooks/ros2_windows/recipes/visual_studio.rb index b5f851d..9df46b6 100644 --- a/cookbooks/ros2_windows/recipes/visual_studio.rb +++ b/cookbooks/ros2_windows/recipes/visual_studio.rb @@ -2,12 +2,12 @@ # https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 # If BuildTools is not already installed, install it -packages_to_install = %w( +packages_to_install = %w[ Microsoft.Net.Component.4.8.SDK Microsoft.VisualStudio.Workload.VCTools Microsoft.Component.MSBuild Microsoft.VisualStudio.Component.VC.CLI.Support -) +] if node['ros2_windows']['vs_version'] != 'buildtools' then packages_to_install += ['Microsoft.VisualStudio.Workload.NativeDesktop',] From 9daedb7cb07709532d1c23a2c85833c8df60983e Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 28 Apr 2020 16:03:54 -0700 Subject: [PATCH 7/9] Fixes --- cookbooks/ros2_windows/recipes/pip_installs.rb | 8 ++++---- cookbooks/ros2_windows/recipes/qt5.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cookbooks/ros2_windows/recipes/pip_installs.rb b/cookbooks/ros2_windows/recipes/pip_installs.rb index 516c00a..418d1a4 100644 --- a/cookbooks/ros2_windows/recipes/pip_installs.rb +++ b/cookbooks/ros2_windows/recipes/pip_installs.rb @@ -1,4 +1,4 @@ -required_pip_packages = %w( +required_pip_packages = %w[ pydot PyQt5 vcstool @@ -18,9 +18,9 @@ pytest-mock coverage mock -) +] -development_pip_packages = %w( +development_pip_packages = %w[ flake8 flake8-blind-except flake8-builtins @@ -33,7 +33,7 @@ mypy pep8 pydocstyle -) +] # Use explicit location because python may not be on the PATH if chef-solo has not been run before execute 'pip_update' do diff --git a/cookbooks/ros2_windows/recipes/qt5.rb b/cookbooks/ros2_windows/recipes/qt5.rb index b892163..65096ea 100644 --- a/cookbooks/ros2_windows/recipes/qt5.rb +++ b/cookbooks/ros2_windows/recipes/qt5.rb @@ -28,7 +28,7 @@ windows_package 'Qt Maintenance' do source 'c:\\Qt\\MaintenanceTool.exe' installer_type :custom - returns [0, 1, 3] + returns [0] options '--script qt-maintenance.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' timeout 2000 only_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} @@ -37,7 +37,7 @@ windows_package 'Qt Install' do source 'http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe' installer_type :custom - returns [0, 1] + returns [0] options '--script qt-installer.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' timeout 2000 not_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} From be20e26cdc8f79a970de18399072874bd91c0df9 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Wed, 29 Apr 2020 23:18:33 -0700 Subject: [PATCH 8/9] Switching asserts to log.fatal --- cookbooks/ros2_windows/recipes/rti_connext.rb | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/cookbooks/ros2_windows/recipes/rti_connext.rb b/cookbooks/ros2_windows/recipes/rti_connext.rb index 32453a9..d039bad 100644 --- a/cookbooks/ros2_windows/recipes/rti_connext.rb +++ b/cookbooks/ros2_windows/recipes/rti_connext.rb @@ -1,17 +1,35 @@ connext_params = node['ros2_windows']['rti_connext'] # These will fail if the rti_connext parameters have not been specified because the defaults are 'nil' -assert(File.exists?(connext_params['license_file']), - "License file location does not exist: #{connext_params['license_file']}") +unless File.exists?(connext_params['license_file']) do + Chef::Log.fatal("License file location does not exist: #{connext_params['license_file']}") + raise +end + +unless Dir.exists?(connext_params['installer_dir']) do + Chef::Log.fatal("Installer directory does not exist: #{connext_params['installer_dir']}") + raise +end + +if connext_params['version'] == nil do + Chef::Log.fatal("Version is nil, requires MAJOR.MINOR.PATCH (e.g. '5.3.1')") + raise +end -assert(Dir.exists?(connext_params['installer_dir']), - "Installer directory does not exist: #{connext_params['installer_dir']}") )) -assert_not_nil(connext_params['version'], "Version is nil, requires MAJOR.MINOR.PATCH (e.g. '5.3.1')") -assert_not_nil(connext_params['edition'], "Edition is nil, requires one of ('evaluation', 'pro')") +if connext_params['edition'] == nil do + Chef::Log.fatal("Edition is nil, requires one of ('evaluation', 'pro')") + raise +end -assert_not_nil(connext_params['min_vs_version'], "Minimum Visual Studio version is required (e.g. '2017')") +if connext_params['min_vs_version'] == nil do + Chef::Log.fatal("Minimum Visual Studio version is required (e.g. '2017')") + raise +end -assert_not_nil(connext_params['openssl_version'], "OpenSSL version is required (e.g. '1.0.2n')") +if connext_params['openssl_version'] == nil do + Chef::Log.fatal("OpenSSL version is required (e.g. '1.0.2n')") + raise +end host_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-host-#{connext_params['target_platform']}.exe") host_installer_path = File.join(connext_params['installer_dir'], host_installer_filename) From 76e4f3dbabe36cac4aebd5ee6583e1845291a218 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Wed, 29 Apr 2020 16:59:31 -0700 Subject: [PATCH 9/9] Fix if statements --- cookbooks/ros2_windows/metadata.rb | 2 +- .../recipes/chocolatey_installs.rb | 6 +- cookbooks/ros2_windows/recipes/qt5.rb | 8 +- cookbooks/ros2_windows/recipes/ros2.rb | 2 - cookbooks/ros2_windows/recipes/rti_connext.rb | 94 ++++++++++++------- 5 files changed, 68 insertions(+), 44 deletions(-) diff --git a/cookbooks/ros2_windows/metadata.rb b/cookbooks/ros2_windows/metadata.rb index 58b6486..4c6949f 100644 --- a/cookbooks/ros2_windows/metadata.rb +++ b/cookbooks/ros2_windows/metadata.rb @@ -20,4 +20,4 @@ # source_url 'https://github.com/osrf/chef-osrf' depends 'chocolatey' depends 'seven_zip' -depend 'windows' +depends 'windows' diff --git a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb index 912445b..2ecbbaa 100644 --- a/cookbooks/ros2_windows/recipes/chocolatey_installs.rb +++ b/cookbooks/ros2_windows/recipes/chocolatey_installs.rb @@ -1,7 +1,5 @@ -chocolatey_package 'choco_packages' do - package_name ['git', 'cmake', 'curl', 'vcredist2013', 'vcredist140', 'cppcheck', 'patch'] - # Installs if not installed, otherwise it will upgrade - action :upgrade +execute 'cppcheck' do + command 'choco install -y git cmake curl vcredist2013 vcredist140 patch cppcheck' end windows_env 'PATH' do diff --git a/cookbooks/ros2_windows/recipes/qt5.rb b/cookbooks/ros2_windows/recipes/qt5.rb index 65096ea..2789435 100644 --- a/cookbooks/ros2_windows/recipes/qt5.rb +++ b/cookbooks/ros2_windows/recipes/qt5.rb @@ -28,7 +28,9 @@ windows_package 'Qt Maintenance' do source 'c:\\Qt\\MaintenanceTool.exe' installer_type :custom - returns [0] + # I couldn't find documentation, but return codes don't seem to correspond with an actual failure. + # Instead error information is written to the ErrorLogname below + returns [0, 1, 3] options '--script qt-maintenance.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' timeout 2000 only_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} @@ -37,7 +39,9 @@ windows_package 'Qt Install' do source 'http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe' installer_type :custom - returns [0] + # I couldn't find documentation, but return codes don't seem to correspond with an actual failure. + # Instead error information is written to the ErrorLogname below + returns [0, 1, 3] options '--script qt-installer.qs MsvcVersion=2019 ErrorLogname="' + error_filename + '"' timeout 2000 not_if {::File.exist?('c:\\Qt\\MaintenanceTool.exe')} diff --git a/cookbooks/ros2_windows/recipes/ros2.rb b/cookbooks/ros2_windows/recipes/ros2.rb index 38fe4f5..126e2b1 100644 --- a/cookbooks/ros2_windows/recipes/ros2.rb +++ b/cookbooks/ros2_windows/recipes/ros2.rb @@ -2,8 +2,6 @@ # Using seven_zip also for general zip files because it can download and extract in a single resource include_recipe 'seven_zip' -include_recipe 'ros2_windows::rti_connext' if node['ros2_windows']['install_connext'] == true - include_recipe 'ros2_windows::python' include_recipe 'ros2_windows::pip_installs' include_recipe 'ros2_windows::opencv' diff --git a/cookbooks/ros2_windows/recipes/rti_connext.rb b/cookbooks/ros2_windows/recipes/rti_connext.rb index d039bad..5611766 100644 --- a/cookbooks/ros2_windows/recipes/rti_connext.rb +++ b/cookbooks/ros2_windows/recipes/rti_connext.rb @@ -1,61 +1,94 @@ +bin_dir_installed = (ENV.key?('RTI_OPENSSL_BIN') && Dir.exists?(ENV['RTI_OPENSSL_BIN'])) +lib_dir_installed = (ENV.key?('RTI_OPENSSL_LIB') && Dir.exists?(ENV['RTI_OPENSSL_LIB'])) +if bin_dir_installed != lib_dir_installed + Chef::Log.fatal( + 'RTI Connext has already been installed, but the environment is not properly configured. ' + + 'Uninstall Connext and retry installation.') + raise +end + +if bin_dir_installed && lib_dir_installed + log 'Previous installation exists' do + message 'RTI Connext has been previously installed, skipping.' + end + return +end + connext_params = node['ros2_windows']['rti_connext'] +include_recipe 'seven_zip' + +output="#{Chef::JSONCompat.to_json_pretty(node.to_hash)}" + # These will fail if the rti_connext parameters have not been specified because the defaults are 'nil' -unless File.exists?(connext_params['license_file']) do +if connext_params['license_file'].nil? + Chef::Log.fatal("License file has not been specified"); + raise +end + +unless File.exists?(connext_params['license_file']) Chef::Log.fatal("License file location does not exist: #{connext_params['license_file']}") raise end -unless Dir.exists?(connext_params['installer_dir']) do +if connext_params['installer_dir'].nil? + Chef::Log.fatal("Installer directory does not exist"); + raise +end + +unless Dir.exists?(connext_params['installer_dir']) Chef::Log.fatal("Installer directory does not exist: #{connext_params['installer_dir']}") raise end -if connext_params['version'] == nil do +if connext_params['version'].nil? Chef::Log.fatal("Version is nil, requires MAJOR.MINOR.PATCH (e.g. '5.3.1')") raise end -if connext_params['edition'] == nil do +if connext_params['edition'].nil? Chef::Log.fatal("Edition is nil, requires one of ('evaluation', 'pro')") raise end -if connext_params['min_vs_version'] == nil do +if connext_params['min_vs_version'].nil? Chef::Log.fatal("Minimum Visual Studio version is required (e.g. '2017')") raise end -if connext_params['openssl_version'] == nil do +if connext_params['openssl_version'].nil? Chef::Log.fatal("OpenSSL version is required (e.g. '1.0.2n')") raise end -host_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-host-#{connext_params['target_platform']}.exe") +host_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-host-#{connext_params['target_platform']}.exe" host_installer_path = File.join(connext_params['installer_dir'], host_installer_filename) target_platform_vs_version = connext_params['target_platform'] + 'VS' + connext_params['min_vs_version'] -openssl_installer_path = File.join(connext_params['installer_dir'], +openssl_installer_zip = File.join(connext_params['installer_dir'], "openssl-#{connext_params['openssl_version']}-target-#{target_platform_vs_version}.zip") +openssl_installer_path = File.join(connext_params['installer_dir'], + "openssl-#{connext_params['openssl_version']}-host-#{connext_params['target_platform']}.rtipkg") + target_installer_filename = "rti_connext_dds-#{connext_params['version']}-#{connext_params['edition']}-target-#{target_platform_vs_version}.rtipkg" target_installer_path = File.join(connext_params['installer_dir'], target_installer_filename) -rtipkginstall_bat = File.join('%ProgramFiles%', +rtipkginstall_bat = File.join(ENV['ProgramFiles'], "rti_connext_dds-#{connext_params['version']}", 'bin', 'rtipkginstall.bat') -security_plugins_host_filename = "rti_security_plugins-#{connext_params['version']}-host-#{connext_params['target_platform']}.rtipkg") +security_plugins_host_filename = "rti_security_plugins-#{connext_params['version']}-host-#{connext_params['target_platform']}.rtipkg" security_plugins_host_path = File.join(connext_params['installer_dir'], security_plugins_host_filename) -security_plugins_target_filename = "rti_security_plugins-#{connext_params['version']}-target-#{target_platform_vs_version}.rtipkg") +security_plugins_target_filename = "rti_security_plugins-#{connext_params['version']}-target-#{target_platform_vs_version}.rtipkg" security_plugins_target_path = File.join(connext_params['installer_dir'], security_plugins_target_filename) -rti_openssl_base_dir = File.join('C:\\connext', +rti_openssl_base_dir = File.join('C:/connext', "openssl-#{connext_params['openssl_version']}", target_platform_vs_version, 'release') @@ -73,54 +106,45 @@ level :info end -directory "C:\\connext" do - path "C:\\connext" +directory "C:/connext" do + path "C:/connext" action :create end -execute 'copy_license_file' do - command "copy #{connext_params['license_file']} C:\\connext\\" -end - -execute 'copy_connextdds_host' do - command "copy /b #{host_installer_path}.??? #{host_installer_path}" +powershell_script 'copy_license_file' do + code "copy #{connext_params['license_file']} C:/connext/" end seven_zip_archive 'openssl_zip' do - path 'C:\\connext\\' - source openssl_installer_path - overwrite true -end - -execute 'copy_connextdds_target' do - command "copy /b #{target_installer_filename}.??? #{target_installer_filename}" + path 'C:/connext/' + source openssl_installer_zip + overwrite false end windows_env 'RTI_LICENSE_FILE' do key_name 'RTI_LICENSE_FILE' - value 'C:\\connext\\rti_license.dat' + value 'C:/connext/rti_license.dat' action :create end -windows_package 'rti_connext' do - source host_installer_path - options '--mode unattended --unattendedmodeui minimalWithDialogs --prefix "%ProgramFiles%"' +powershell_script 'rti_connext' do + code host_installer_path + ' --mode unattended --unattendedmodeui minimalWithDialogs --prefix "' + ENV['ProgramFiles'] + '"' end execute 'rtipkginstall_openssl' do - command rtipkginstall_bat + ' ' + openssl_installer_path + command "\"#{rtipkginstall_bat}\" #{openssl_installer_path}" end execute 'rtipkginstall_rti_connext_dds_target' do - command rtipkginstall_bat + ' ' + target_installer_path + command "\"#{rtipkginstall_bat}\" #{target_installer_path}" end execute 'rtipkginstall_rti_security_plugins_host' do - command rtipkginstall_bat + ' ' + security_plugins_host_path + command "\"#{rtipkginstall_bat}\" #{security_plugins_host_path}" end execute 'rtipkginstall_rti_security_plugins_target' do - command rtipkginstall_bat + ' ' + security_plugins_target_path + command "\"#{rtipkginstall_bat}\" #{security_plugins_target_path}" end windows_env 'RTI_OPENSSL_BIN' do