From 6752cc2f4754431afed77ee256a90b900a1efca6 Mon Sep 17 00:00:00 2001 From: tphoney Date: Wed, 13 Dec 2017 10:52:07 +0000 Subject: [PATCH 01/11] (maint) - modulesync 384f4c1 --- .gitignore | 31 ++- .rubocop.yml | 586 +++++++--------------------------------------- .rubocop_todo.yml | 0 Gemfile | 73 ------ 4 files changed, 103 insertions(+), 587 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.gitignore b/.gitignore index f6e8b46c..e5e6f9e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,23 @@ -#This file is generated by ModuleSync, do not edit. -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -log/ -junit/ -.vagrant/ +#This file is generated by ModuleSync, do not edit.Z +*.iml +.*.sw[op] +.DS_Store .bundle/ -coverage/ -log/ .idea/ .metadata -*.iml -.*.sw[op] +.vagrant/ .yardoc .yardwarns -.DS_Store +Gemfile.local +Gemfile.lock +bin/ +coverage/ +doc/ +junit/ +log/ +pkg/ +spec/fixtures/manifests/ +spec/fixtures/modules/ tmp/ vendor/ -doc/ diff --git a/.rubocop.yml b/.rubocop.yml index 5aadd1b6..515ef631 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,508 +1,98 @@ -require: rubocop-rspec +--- +require: + - rubocop-rspec AllCops: - TargetRubyVersion: 1.9 + TargetRubyVersion: '2.1' Include: - - ./**/*.rb + - "./**/*.rb" Exclude: - - vendor/**/* - - .vendor/**/* - - pkg/**/* - - spec/fixtures/**/* -Lint/ConditionPosition: - Enabled: True - -Lint/ElseLayout: - Enabled: True - -Lint/UnreachableCode: - Enabled: True - -Lint/UselessComparison: - Enabled: True - -Lint/EnsureReturn: - Enabled: True - -Lint/HandleExceptions: - Enabled: True - -Lint/LiteralInCondition: - Enabled: True - -Lint/ShadowingOuterLocalVariable: - Enabled: True - -Lint/LiteralInInterpolation: - Enabled: True - -Style/HashSyntax: - Enabled: True - -Style/RedundantReturn: - Enabled: True - -Lint/AmbiguousOperator: - Enabled: True - -Lint/AssignmentInCondition: - Enabled: True - -Style/SpaceBeforeComment: - Enabled: True - -Style/AndOr: - Enabled: True - -Style/RedundantSelf: - Enabled: True - -# Method length is not necessarily an indicator of code quality -Metrics/MethodLength: - Enabled: False - -# Module length is not necessarily an indicator of code quality -Metrics/ModuleLength: - Enabled: False - -Style/WhileUntilModifier: - Enabled: True - -Lint/AmbiguousRegexpLiteral: - Enabled: True - -Lint/Eval: - Enabled: True - -Lint/BlockAlignment: - Enabled: True - -Lint/DefEndAlignment: - Enabled: True - -Lint/EndAlignment: - Enabled: True - -Lint/DeprecatedClassMethods: - Enabled: True - -Lint/Loop: - Enabled: True - -Lint/ParenthesesAsGroupedExpression: - Enabled: True - -Lint/RescueException: - Enabled: True - -Lint/StringConversionInInterpolation: - Enabled: True - -Lint/UnusedBlockArgument: - Enabled: True - -Lint/UnusedMethodArgument: - Enabled: True - -Lint/UselessAccessModifier: - Enabled: True - -Lint/UselessAssignment: - Enabled: True - -Lint/Void: - Enabled: True - -Style/AccessModifierIndentation: - Enabled: True - -Style/AccessorMethodName: - Enabled: True - -Style/Alias: - Enabled: True - -Style/AlignArray: - Enabled: True - -Style/AlignHash: - Enabled: True - -Style/AlignParameters: - Enabled: True - -Metrics/BlockNesting: - Enabled: True - -Style/AsciiComments: - Enabled: True - -Style/Attr: - Enabled: True - -Style/BracesAroundHashParameters: - Enabled: True - -Style/CaseEquality: - Enabled: True - -Style/CaseIndentation: - Enabled: True - -Style/CharacterLiteral: - Enabled: True - -Style/ClassAndModuleCamelCase: - Enabled: True - -Style/ClassAndModuleChildren: - Enabled: False - -Style/ClassCheck: - Enabled: True - -# Class length is not necessarily an indicator of code quality -Metrics/ClassLength: - Enabled: False - -Style/ClassMethods: - Enabled: True - -Style/ClassVars: - Enabled: True - -Style/WhenThen: - Enabled: True - -Style/WordArray: - Enabled: True - -Style/UnneededPercentQ: - Enabled: True - -Style/Tab: - Enabled: True - -Style/SpaceBeforeSemicolon: - Enabled: True - -Style/TrailingBlankLines: - Enabled: True - -Style/SpaceInsideBlockBraces: - Enabled: True - -Style/SpaceInsideBrackets: - Enabled: True - -Style/SpaceInsideHashLiteralBraces: - Enabled: True - -Style/SpaceInsideParens: - Enabled: True - -Style/LeadingCommentSpace: - Enabled: True - -Style/SpaceBeforeFirstArg: - Enabled: True - -Style/SpaceAfterColon: - Enabled: True - -Style/SpaceAfterComma: - Enabled: True - -Style/SpaceAfterMethodName: - Enabled: True - -Style/SpaceAfterNot: - Enabled: True - -Style/SpaceAfterSemicolon: - Enabled: True - -Style/SpaceAroundEqualsInParameterDefault: - Enabled: True - -Style/SpaceAroundOperators: - Enabled: True - -Style/SpaceBeforeBlockBraces: - Enabled: True - -Style/SpaceBeforeComma: - Enabled: True - -Style/CollectionMethods: - Enabled: True - -Style/CommentIndentation: - Enabled: True - -Style/ColonMethodCall: - Enabled: True - -Style/CommentAnnotation: - Enabled: True - -# 'Complexity' is very relative -Metrics/CyclomaticComplexity: - Enabled: False - -Style/ConstantName: - Enabled: True - -Style/Documentation: - Enabled: False - -Style/DefWithParentheses: - Enabled: True - -Style/PreferredHashMethods: - Enabled: True - -Style/DotPosition: - EnforcedStyle: trailing - -Style/DoubleNegation: - Enabled: True - -Style/EachWithObject: - Enabled: True - -Style/EmptyLineBetweenDefs: - Enabled: True - -Style/IndentArray: - Enabled: True - -Style/IndentHash: - Enabled: True - -Style/IndentationConsistency: - Enabled: True - -Style/IndentationWidth: - Enabled: True - -Style/EmptyLines: - Enabled: True - -Style/EmptyLinesAroundAccessModifier: - Enabled: True - -Style/EmptyLiteral: - Enabled: True - -# Configuration parameters: AllowURI, URISchemes. + - bin/* + - ".vendor/**/*" + - Gemfile + - Rakefile + - pkg/**/* + - spec/fixtures/**/* + - vendor/**/* +inherit_from: .rubocop_todo.yml Metrics/LineLength: - Enabled: False - -Style/MethodCallParentheses: - Enabled: True - -Style/MethodDefParentheses: - Enabled: True - -Style/LineEndConcatenation: - Enabled: True - -Style/TrailingWhitespace: - Enabled: True - -Style/StringLiterals: - Enabled: True - -Style/TrailingCommaInArguments: - Enabled: True - -Style/TrailingCommaInLiteral: - Enabled: True - -Style/GlobalVars: - Enabled: True - -Style/GuardClause: - Enabled: True - -Style/IfUnlessModifier: - Enabled: True - -Style/MultilineIfThen: - Enabled: True - -Style/NegatedIf: - Enabled: True - -Style/NegatedWhile: - Enabled: True - -Style/Next: - Enabled: True - -Style/SingleLineBlockParams: - Enabled: True - -Style/SingleLineMethods: - Enabled: True - -Style/SpecialGlobalVars: - Enabled: True - -Style/TrivialAccessors: - Enabled: True - -Style/UnlessElse: - Enabled: True - -Style/VariableInterpolation: - Enabled: True - -Style/VariableName: - Enabled: True - -Style/WhileUntilDo: - Enabled: True - -Style/EvenOdd: - Enabled: True - -Style/FileName: - Enabled: True - -Style/For: - Enabled: True - -Style/Lambda: - Enabled: True - -Style/MethodName: - Enabled: True - -Style/MultilineTernaryOperator: - Enabled: True - -Style/NestedTernaryOperator: - Enabled: True - -Style/NilComparison: - Enabled: True - + Description: People have wide screens, use them. + Max: 200 +RSpec/BeforeAfterAll: + Description: Beware of using after(:all) as it may cause state to leak between tests. + A necessary evil in acceptance testing. + Exclude: + - spec/acceptance/**/*.rb +RSpec/HookArgument: + Description: Prefer explicit :each argument, matching existing module's style + EnforcedStyle: each +Style/BlockDelimiters: + Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to + be consistent then. + EnforcedStyle: braces_for_chaining +Style/ClassAndModuleChildren: + Description: Compact style reduces the required amount of indentation. + EnforcedStyle: compact +Style/EmptyElse: + Description: Enforce against empty else clauses, but allow `nil` for clarity. + EnforcedStyle: empty Style/FormatString: - Enabled: True - -Style/MultilineBlockChain: - Enabled: True - -Style/Semicolon: - Enabled: True - -Style/SignalException: - Enabled: True - -Style/NonNilCheck: - Enabled: True - -Style/Not: - Enabled: True - -Style/NumericLiterals: - Enabled: True - -Style/OneLineConditional: - Enabled: True - -Style/OpMethod: - Enabled: True - -Style/ParenthesesAroundCondition: - Enabled: True - -Style/PercentLiteralDelimiters: - Enabled: True - -Style/PerlBackrefs: - Enabled: True - -Style/PredicateName: - Enabled: True - -Style/RedundantException: - Enabled: True - -Style/SelfAssignment: - Enabled: True - -Style/Proc: - Enabled: True - -Style/RaiseArgs: - Enabled: True - -Style/RedundantBegin: - Enabled: True - -Style/RescueModifier: - Enabled: True - -# based on https://github.com/voxpupuli/modulesync_config/issues/168 + Description: Following the main puppet project's style, prefer the % format format. + EnforcedStyle: percent +Style/FormatStringToken: + Description: Following the main puppet project's style, prefer the simpler template + tokens over annotated ones. + EnforcedStyle: template +Style/Lambda: + Description: Prefer the keyword for easier discoverability. + EnforcedStyle: literal Style/RegexpLiteral: + Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 EnforcedStyle: percent_r - Enabled: True - -Lint/UnderscorePrefixedVariableName: - Enabled: True - -Metrics/ParameterLists: - Enabled: False - -Lint/RequireParentheses: - Enabled: True - -Style/SpaceBeforeFirstArg: - Enabled: True - -Style/ModuleFunction: - Enabled: True - -Lint/Debugger: - Enabled: True - -Style/IfWithSemicolon: - Enabled: True - -Style/Encoding: - Enabled: True - -Style/BlockDelimiters: - Enabled: True - -Style/MultilineBlockLayout: - Enabled: True - -# 'Complexity' is very relative +Style/TernaryParentheses: + Description: Checks for use of parentheses around ternary conditions. Enforce parentheses + on complex expressions for better readability, but seriously consider breaking + it up. + EnforcedStyle: require_parentheses_when_complex +Style/TrailingCommaInArguments: + Description: Prefer always trailing comma on multiline argument lists. This makes + diffs, and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/TrailingCommaInLiteral: + Description: Prefer always trailing comma on multiline literals. This makes diffs, + and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/SymbolArray: + Description: Using percent style obscures symbolic intent of array's contents. + EnforcedStyle: brackets +Style/CollectionMethods: + Enabled: true +Style/MethodCalledOnDoEndBlock: + Enabled: true +Style/StringMethods: + Enabled: true Metrics/AbcSize: - Enabled: False - -# 'Complexity' is very relative + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Enabled: false Metrics/PerceivedComplexity: - Enabled: False - -Lint/UselessAssignment: - Enabled: True - -Style/ClosingParenthesisIndentation: - Enabled: False - -# RSpec - -# We don't use rspec in this way + Enabled: false RSpec/DescribeClass: - Enabled: False - -# Example length is not necessarily an indicator of code quality -RSpec/ExampleLength: - Enabled: False - -RSpec/NamedSubject: - Enabled: False + Enabled: false +RSpec/MessageExpectation: + Enabled: false +Style/AsciiComments: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/SymbolProc: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..e69de29b diff --git a/Gemfile b/Gemfile index 7c82e0ca..608f9b91 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,6 @@ def location_for(place_or_version, fake_version = nil) end # Used for gem conditionals -supports_windows = true ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" @@ -73,78 +72,6 @@ gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] -# For Windows dependencies, these could be required based on the version of -# Puppet you are requiring. Anything greater than v3.5.0 is going to have -# Windows-specific dependencies dictated by the gem itself. The other scenario -# is when you are faking out Puppet to use a local file path / git path. -explicitly_require_windows_gems = false -puppet_gem_location = gem_type(ENV['PUPPET_GEM_VERSION']) -# This is not a perfect answer to the version check -if puppet_gem_location != :gem || (ENV['PUPPET_GEM_VERSION'] && Gem::Version.correct?(ENV['PUPPET_GEM_VERSION']) && Gem::Requirement.new('< 3.5.0').satisfied_by?(Gem::Version.new(ENV['PUPPET_GEM_VERSION'].dup))) - if Gem::Platform.local.os == 'mingw32' - explicitly_require_windows_gems = true - end - if puppet_gem_location == :gem - # If facterversion hasn't been specified and we are - # looking for a Puppet Gem version less than 3.5.0, we - # need to ensure we get a good Facter for specs. - gem "facter",">= 1.6.11","<= 1.7.5",:require => false unless ENV['FACTER_GEM_VERSION'] - # If hieraversion hasn't been specified and we are - # looking for a Puppet Gem version less than 3.5.0, we - # need to ensure we get a good Hiera for specs. - gem "hiera",">= 1.0.0","<= 1.3.0",:require => false unless ENV['HIERA_GEM_VERSION'] - end -end - -if explicitly_require_windows_gems - # This also means Puppet Gem less than 3.5.0 - this has been tested back - # to 3.0.0. Any further back is likely not supported. - if puppet_gem_location == :gem - gem "ffi", "1.9.0", :require => false - gem "win32-eventlog", "0.5.3","<= 0.6.5", :require => false - gem "win32-process", "0.6.5","<= 0.7.5", :require => false - gem "win32-security", "~> 0.1.2","<= 0.2.5", :require => false - gem "win32-service", "0.7.2","<= 0.8.8", :require => false - gem "minitar", "0.5.4", :require => false - else - gem "ffi", "~> 1.9.0", :require => false - gem "win32-eventlog", "~> 0.5","<= 0.6.5", :require => false - gem "win32-process", "~> 0.6","<= 0.7.5", :require => false - gem "win32-security", "~> 0.1","<= 0.2.5", :require => false - gem "win32-service", "~> 0.7","<= 0.8.8", :require => false - gem "minitar", "~> 0.5.4", :require => false - end - - gem "win32-dir", "~> 0.3","<= 0.4.9", :require => false - gem "win32console", "1.3.2", :require => false if RUBY_VERSION =~ /^1\./ - - # sys-admin was removed in Puppet 3.7.0+, and doesn't compile - # under Ruby 2.3 - so restrict it to Ruby 1.x - gem "sys-admin", "1.5.6", :require => false if RUBY_VERSION =~ /^1\./ - - # Puppet less than 3.7.0 requires these. - # Puppet 3.5.0+ will control the actual requirements. - # These are listed in formats that work with all versions of - # Puppet from 3.0.0 to 3.6.x. After that, these were no longer used. - # We do not want to allow newer versions than what came out after - # 3.6.x to be used as they constitute some risk in breaking older - # functionality. So we set these to exact versions. - gem "win32-api", "1.4.8", :require => false - gem "win32-taskscheduler", "0.2.2", :require => false - gem "windows-api", "0.4.3", :require => false - gem "windows-pr", "1.2.3", :require => false -else - if Gem::Platform.local.os == 'mingw32' - # If we're using a Puppet gem on windows, which handles its own win32-xxx gem dependencies (Pup 3.5.0 and above), set maximum versions - # Required due to PUP-6445 - gem "win32-dir", "<= 0.4.9", :require => false - gem "win32-eventlog", "<= 0.6.5", :require => false - gem "win32-process", "<= 0.7.5", :require => false - gem "win32-security", "<= 0.2.5", :require => false - gem "win32-service", "<= 0.8.8", :require => false - end -end - # Evaluate Gemfile.local if it exists if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) From 50a3c57428b9f8da1f4f05319fd49064d9fb342a Mon Sep 17 00:00:00 2001 From: Michael T Lombardi Date: Tue, 19 Dec 2017 10:47:37 -0600 Subject: [PATCH 02/11] (maint) modulesync cd884db Remove AppVeyor OpenSSL update on Ruby 2.4 --- .gitignore | 2 +- appveyor.yml | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e5e6f9e8..a1022772 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -#This file is generated by ModuleSync, do not edit.Z +# This file is generated by ModuleSync, do not edit. *.iml .*.sw[op] .DS_Store diff --git a/appveyor.yml b/appveyor.yml index b533bba6..805c2844 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,15 +25,6 @@ matrix: install: - SET PATH=C:\Ruby%RUBY_VER%\bin;%PATH% - ps: | - # AppVeyor appears to have OpenSSL headers available already - # which msys2 would normally install with: - # pacman -S mingw-w64-x86_64-openssl --noconfirm - # - if ( $(ruby --version) -match "^ruby\s+2\.4" ) { - Write-Output "Building OpenSSL gem ~> 2.0.4 to fix Ruby 2.4 / AppVeyor issue" - gem install openssl --version '~> 2.0.4' --no-ri --no-rdoc - } - gem list openssl ruby -ropenssl -e 'puts \"OpenSSL Version - #{OpenSSL::OPENSSL_VERSION}\"; puts \"OpenSSL Library Version - #{OpenSSL::OPENSSL_LIBRARY_VERSION}\"' - bundle install --jobs 4 --retry 2 --without system_tests From d27521d5542cc23374e80fd10318077685610a6d Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Thu, 4 Jan 2018 11:33:53 +0800 Subject: [PATCH 03/11] (maint) Update sync.yaml for new modsync config options Previously the travis.yaml file was unmanaged as it contained customisations not compatible with modsync. Now that the required options are available the sync file can be updated accordingly. This commit: - Updates the sudo, dist and before_install commands to install Powershell - Updates the NOTICE file to indicate the correct dates for the copyright holders --- .sync.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.sync.yml b/.sync.yml index e5e655cf..065b7721 100644 --- a/.sync.yml +++ b/.sync.yml @@ -8,7 +8,16 @@ Gemfile: platforms: ["mswin", "mingw", "x64_mingw"] version: '< 2.6.0' .travis.yml: - unmanaged: true + # Require sudo and Ubuntu 14 to install PowerShell + sudo: required + dist: trusty + # Powershell installation instructions from + # https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#ubuntu-1404 + before_install: + - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + - curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + - sudo apt-get update + - sudo apt-get install -y powershell spec/spec_helper.rb: unmanaged: true appveyor.yml: @@ -21,6 +30,6 @@ NOTICE: copyright_holders: - name: 'Josh Cooper, original author' begin: 2013 + end: 2013 - name: 'Puppet, Inc.' begin: 2013 - end: 'latest' From 8adfb729201b434223e9379e162422671c2f9eb1 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Mon, 15 Jan 2018 08:24:18 +0800 Subject: [PATCH 04/11] (maint) Modsync a3ae5c94f7d This commit applies modsync at commit a3ae5c94f7d --- .travis.yml | 13 +++++-------- NOTICE | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 23ddfd96..7f132dd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,12 @@ +#This file is generated by ModuleSync, do not edit. --- -# Require sudo and Ubuntu 14 to install PowerShell sudo: required dist: trusty language: ruby cache: bundler script: "bundle exec rake release_checks" -#Inserting below due to the following issue: https://github.com/travis-ci/travis-ci/issues/3531#issuecomment-88311203 before_install: - - gem update bundler - # Powershell installation instructions from - # https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#ubuntu-1404 + # Additional instructions - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update @@ -17,10 +14,10 @@ before_install: matrix: fast_finish: true include: - - rvm: 2.3.1 + - rvm: 2.4.1 bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 4.0" - - rvm: 2.1.7 + env: PUPPET_GEM_VERSION="~> 5.0" + - rvm: 2.1.9 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 4.0" notifications: diff --git a/NOTICE b/NOTICE index 75287211..e5922e73 100644 --- a/NOTICE +++ b/NOTICE @@ -1,7 +1,7 @@ Puppet Module - puppetlabs-powershell -Copyright 2013 Josh Cooper, original author -Copyright 2013 - 2017 Puppet, Inc. +Copyright 2013 - 2013 Josh Cooper, original author +Copyright 2013 Puppet, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 41cdb755812b8d959b9b50e30d21074d30bb9d3c Mon Sep 17 00:00:00 2001 From: Iristyle Date: Thu, 18 Jan 2018 15:32:36 -0800 Subject: [PATCH 05/11] (maint) Minor PowerShell syntax updates to README - It's unnecessary to use PowerShell sub-expressions in the examples given. Remove superfluous syntax to prevent user confusion This appears to have been errantly introduced in f49c95fa06b6e8ed332e933bafa2bc9f36da0223 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b2bea71..a413b7e5 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The powershell module adapts the Puppet [exec](http://docs.puppet.com/references ~~~ puppet exec { 'RESOURCENAME': - command => '$(SOMECOMMAND)', + command => 'SOMECOMMAND', provider => powershell, } ~~~ @@ -47,7 +47,7 @@ For instance, to rename the Guest account: ~~~ puppet exec { 'rename-guest': - command => '$(Get-WMIObject Win32_UserAccount -Filter "Name=\'guest\'").Rename("new-guest")', + command => '(Get-WMIObject Win32_UserAccount -Filter "Name=\'guest\'").Rename("new-guest")', unless => 'if (Get-WmiObject Win32_UserAccount -Filter "Name=\'guest\'") { exit 1 }', provider => powershell, } From 8b43589560b06b7fd38765f0c7b3119581dbbcd5 Mon Sep 17 00:00:00 2001 From: Bill Hurt Date: Mon, 26 Mar 2018 15:47:43 -0700 Subject: [PATCH 06/11] (IMAGES-795) 2008r2 template failing PowerShell module tests The newest image for Windows 2008r2 is exhibiting different behavior for loading .NET assemblies than we have seen in the past. The System.Core assembly is not loaded into the PowerShell host process by default any longer. This causes the init.ps1 script in the module to to fail to start a Pipe Server to receive PowerShell scripts to be executed. This change always attempts to load the System.Core assembly prior to creating the pipe server object. Explicity loading the assembly fixes the issue and the newest image becomes usable again. This fix is also require to fix any moduels that depend on the PowerShell exec provider working properly. --- lib/puppet_x/templates/powershell/init_ps.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puppet_x/templates/powershell/init_ps.ps1 b/lib/puppet_x/templates/powershell/init_ps.ps1 index a7a37b5d..9d1ee2b7 100644 --- a/lib/puppet_x/templates/powershell/init_ps.ps1 +++ b/lib/puppet_x/templates/powershell/init_ps.ps1 @@ -748,6 +748,8 @@ function Start-PipeServer $Encoding ) + Add-Type -AssemblyName "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" + # this does not require versioning in the payload as client / server are tightly coupled $server = New-Object System.IO.Pipes.NamedPipeServerStream($CommandChannelPipeName, [System.IO.Pipes.PipeDirection]::InOut) From 7115852ae32a84fcd13bc5de997c925daca37f91 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Wed, 21 Mar 2018 16:56:25 +0800 Subject: [PATCH 07/11] (MODULES-6750) Add testmode switcher This commit adds the testmode switcher gem and modifies the tests to use test mode switcher. This allows acceptance tests to run with or without a master. --- .sync.yml | 4 ++ Gemfile | 8 ++- spec/acceptance/exec_powershell_spec.rb | 93 ++++++++++++++++--------- spec/spec_helper_acceptance.rb | 5 +- 4 files changed, 74 insertions(+), 36 deletions(-) diff --git a/.sync.yml b/.sync.yml index 065b7721..e744393a 100644 --- a/.sync.yml +++ b/.sync.yml @@ -7,6 +7,10 @@ Gemfile: - gem: 'rspec-puppet' platforms: ["mswin", "mingw", "x64_mingw"] version: '< 2.6.0' + ':system_tests': + - gem: beaker-testmode_switcher + version: '~> 0.4' + - gem: master_manipulator .travis.yml: # Require sudo and Ubuntu 14 to install PowerShell sudo: required diff --git a/Gemfile b/Gemfile index 608f9b91..6066ecf4 100644 --- a/Gemfile +++ b/Gemfile @@ -55,11 +55,13 @@ end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') gem "beaker-pe", :require => false - gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) + gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) - gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') + gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') + gem "beaker-testmode_switcher", '~> 0.4', :require => false + gem 'master_manipulator', :require => false gem "puppet-blacksmith", '~> 3.4', :require => false end diff --git a/spec/acceptance/exec_powershell_spec.rb b/spec/acceptance/exec_powershell_spec.rb index ed26ee9d..db5aab6c 100644 --- a/spec/acceptance/exec_powershell_spec.rb +++ b/spec/acceptance/exec_powershell_spec.rb @@ -26,13 +26,20 @@ def platform_string(host, windows, posix) shared_examples 'should fail' do |manifest, error_check| it 'should throw an error' do - expect { apply_manifest_on(powershell_agents, manifest, :catch_failures => true, :future_parser => FUTURE_PARSER) }.to raise_error(error_check) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each do |hut| + result = execute_manifest_on(hut, manifest, :expect_failures => true) + unless error_check.nil? + expect(result.stderr).to match(error_check) + end + end end end shared_examples 'apply success' do |manifest| it 'should succeed' do - apply_manifest_on(powershell_agents, manifest, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, manifest, :catch_failures => true) } end end @@ -45,7 +52,8 @@ def platform_string(host, windows, posix) } MANIFEST it 'should not fail' do - apply_manifest_on(host_list, padmin, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + host_list.each { |hut| execute_manifest_on(hut, padmin, :catch_failures => true) } end end @@ -72,14 +80,14 @@ def platform_string(host, windows, posix) MANIFEST end } - + it 'should not error on first run' do # Run it twice and test for idempotency - apply_manifest_on(host, manifest, :catch_failures => true, :future_parser => FUTURE_PARSER) + execute_manifest_on(host, manifest, :catch_failures => true) end it 'should be idempotent' do - apply_manifest_on(host, manifest, :catch_failures => true, :future_parser => FUTURE_PARSER, :acceptable_exit_codes => [0]) + execute_manifest_on(host, manifest, :catch_chages => true) end end end @@ -115,7 +123,7 @@ def platform_string(host, windows, posix) } MANIFEST - apply_manifest_on(host, p1, :catch_failures => true, :future_parser => FUTURE_PARSER) + execute_manifest_on(host, p1, :catch_failures => true) on(host, platform_string(host,"cmd.exe /c \"type #{try_successfile}\"","cat #{try_successfile}")) do |result| assert_match(/#{try_content}/, result.stdout, "Unexpected result for host '#{host}'") @@ -148,7 +156,7 @@ def platform_string(host, windows, posix) } MANIFEST - apply_manifest_on(host, p1, :catch_failures => true, :future_parser => FUTURE_PARSER) + execute_manifest_on(host, p1, :catch_failures => true) on(host, platform_string(host,"cmd.exe /c \"type #{catch_successfile}\"","cat #{catch_successfile}")) do |result| assert_match(/#{catch_content}/, result.stdout, "Unexpected result for host '#{host}'") @@ -178,11 +186,13 @@ def platform_string(host, windows, posix) } it 'should not error on first run' do - apply_manifest_on(powershell_agents, exit_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, exit_pp, :expect_changes => true) } end it 'should run a second time' do - apply_manifest_on(powershell_agents, exit_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, exit_pp, :expect_changes => true) } end end @@ -199,11 +209,13 @@ def platform_string(host, windows, posix) } it 'should not error on first run' do - apply_manifest_on(powershell_agents, break_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, break_pp, :expect_changes => true) } end it 'should run a second time' do - apply_manifest_on(powershell_agents, break_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, break_pp, :expect_changes => true) } end end @@ -220,11 +232,13 @@ def platform_string(host, windows, posix) } it 'should not error on first run' do - apply_manifest_on(powershell_agents, return_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, return_pp, :expect_changes => true) } end it 'should run a second time' do - apply_manifest_on(powershell_agents, return_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, return_pp, :expect_changes => true) } end end @@ -251,10 +265,12 @@ def platform_string(host, windows, posix) it 'should not see variable from previous run' do # Setup the variable - apply_manifest_on(powershell_agents, var_leak_setup_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, var_leak_setup_pp, :expect_changes => true) } # Test to see if subsequent call sees the variable - apply_manifest_on(powershell_agents, var_leak_test_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, var_leak_test_pp, :expect_changes => true) } end end @@ -303,10 +319,12 @@ def platform_string(host, windows, posix) it 'should not see environment variable from previous run' do # Setup the environment variable - apply_manifest_on(powershell_agents, envar_leak_setup_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, envar_leak_setup_pp, :expect_changes => true) } # Test to see if subsequent call sees the environment variable - apply_manifest_on(powershell_agents, envar_leak_test_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, envar_leak_test_pp, :expect_changes => true) } end it 'should see environment variables set outside of session' do @@ -322,10 +340,12 @@ def platform_string(host, windows, posix) end # Test to see if initial run sees the environment variable - apply_manifest_on(powershell_agents, envar_leak_test_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, envar_leak_test_pp, :expect_changes => true) } # Test to see if subsequent call sees the environment variable and environment purge - apply_manifest_on(powershell_agents, envar_leak_test_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, envar_leak_test_pp, :expect_changes => true) } end end @@ -352,11 +372,13 @@ def platform_string(host, windows, posix) } it 'should RUN command if unless is NOT triggered' do - apply_manifest_on(powershell_agents, unless_not_triggered_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, unless_not_triggered_pp, :expect_changes => true) } end it 'should NOT run command if unless IS triggered' do - apply_manifest_on(powershell_agents, unless_triggered_pp, :catch_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, unless_triggered_pp, :catch_changes => true) } end end @@ -384,11 +406,13 @@ def platform_string(host, windows, posix) } it 'should NOT run command if onlyif is NOT triggered' do - apply_manifest_on(powershell_agents, onlyif_not_triggered_pp, :catch_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, onlyif_not_triggered_pp, :catch_changes => true) } end it 'should RUN command if onlyif IS triggered' do - apply_manifest_on(powershell_agents, onlyif_triggered_pp, :expect_changes => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + powershell_agents.each { |hut| execute_manifest_on(hut, onlyif_triggered_pp, :expect_changes => true) } end end @@ -407,7 +431,8 @@ def platform_string(host, windows, posix) let(:file_path) { 'C:/services.txt' } it 'should apply the manifest' do - apply_manifest_on(windows_agents, p2, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + windows_agents.each { |hut| execute_manifest_on(hut, p2, :catch_failures => true) } end it { should be_file } @@ -418,7 +443,8 @@ def platform_string(host, windows, posix) let(:file_path) { '/services.txt' } it 'should apply the manifest' do - apply_manifest_on(posix_agents, p2, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + posix_agents.each { |hut| execute_manifest_on(hut, p2, :catch_failures => true) } end it { should be_file } @@ -462,12 +488,13 @@ def platform_string(host, windows, posix) } MANIFEST describe file('c:/temp/services.csv') do - apply_manifest_on(windows_agents, p2, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + windows_agents.each { |hut| execute_manifest_on(hut, p2, :catch_failures => true) } it { should be_file } its(:content) { should match /puppet/ } end end - + context 'on POSIX platforms', :if => posix_agents.count > 0 do p2 = <<-MANIFEST file{'/external-script.ps1': @@ -482,7 +509,8 @@ def platform_string(host, windows, posix) MANIFEST describe file('/tmp/commands.csv') do - apply_manifest_on(posix_agents, p2, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + posix_agents.each { |hut| execute_manifest_on(hut, p2, :catch_failures => true) } it { should be_file } its(:content) { should match /Get-Command/ } end @@ -506,7 +534,8 @@ def platform_string(host, windows, posix) } MANIFEST describe file(outfile) do - apply_manifest_on(windows_agents, pp, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + windows_agents.each { |hut| execute_manifest_on(hut, pp, :catch_failures => true) } it { should be_file } its(:content) { should match /svchost/ } end @@ -530,7 +559,8 @@ def platform_string(host, windows, posix) } MANIFEST describe file(outfile) do - apply_manifest_on(posix_agents, pp, :catch_failures => true, :future_parser => FUTURE_PARSER) + # Due to https://tickets.puppetlabs.com/browse/QA-3461 each host must be done one at a time + posix_agents.each { |hut| execute_manifest_on(hut, pp, :catch_failures => true) } it { should be_file } its(:content) { should match /Export-Csv/ } end @@ -561,6 +591,7 @@ def platform_string(host, windows, posix) $pr = New-Object Security.Principal.WindowsPrincipal $id if(!($pr.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))){Write-Error "Not in admin"} PS1 + #require 'pry'; binding.pry it_should_behave_like 'standard exec', ps1, windows_agents end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 39fa83b7..56978972 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,6 +1,7 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' require 'beaker/puppet_install_helper' +require 'beaker/testmode_switcher/dsl' UNSUPPORTED_PLATFORMS = ['debian', 'ubuntu', 'Solaris'] FUTURE_PARSER = ENV['FUTURE_PARSER'] == 'true' || false @@ -66,10 +67,10 @@ # Ensure test files don't exist before we run the test suite absent_files = 'file{["c:/services.txt","c:/process.txt","c:/try_success.txt","c:/catch_shouldntexist.txt","c:/try_shouldntexist.txt","c:/catch_success.txt"]: ensure => absent }' - apply_manifest_on(windows_agents,absent_files) if windows_agents.count > 0 + apply_manifest_on(windows_agents, absent_files, :catch_failures => true) if windows_agents.count > 0 absent_files = 'file{["/services.txt","/process.txt","/try_success.txt","/catch_shouldntexist.txt","/try_shouldntexist.txt","/catch_success.txt"]: ensure => absent }' - apply_manifest_on(posix_agents,absent_files) if posix_agents.count > 0 + apply_manifest_on(posix_agents, absent_files, :catch_failures => true) if posix_agents.count > 0 end end From 52a456fd6c28a910a87be51e236f13cdb0417a5c Mon Sep 17 00:00:00 2001 From: William Hurt Date: Tue, 27 Mar 2018 10:38:45 -0700 Subject: [PATCH 08/11] Revert "(IMAGES-795) 2008r2 template failing PowerShell module tests" --- lib/puppet_x/templates/powershell/init_ps.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/puppet_x/templates/powershell/init_ps.ps1 b/lib/puppet_x/templates/powershell/init_ps.ps1 index 9d1ee2b7..a7a37b5d 100644 --- a/lib/puppet_x/templates/powershell/init_ps.ps1 +++ b/lib/puppet_x/templates/powershell/init_ps.ps1 @@ -748,8 +748,6 @@ function Start-PipeServer $Encoding ) - Add-Type -AssemblyName "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" - # this does not require versioning in the payload as client / server are tightly coupled $server = New-Object System.IO.Pipes.NamedPipeServerStream($CommandChannelPipeName, [System.IO.Pipes.PipeDirection]::InOut) From 1502783c679ddd4a934f5622839339ddd67ffbf4 Mon Sep 17 00:00:00 2001 From: Bill Hurt Date: Tue, 27 Mar 2018 12:01:58 -0700 Subject: [PATCH 09/11] (MODULES-6927) Fix Pipe Server on Win 2008r2 The newest image for Windows 2008r2 is exhibiting different behavior for loading .NET assemblies than we have seen in the past. The System.Core assembly is not loaded into the PowerShell host process by default any longer. This causes the init.ps1 script in the module to to fail to start a Pipe Server to receive PowerShell scripts to be executed. This change always attempts to load the System.Core assembly prior to creating the pipe server object. Explicity loading the assembly fixes the issue and the newest image becomes usable again. This fix is also required to fix any modules that depend on the PowerShell exec provider working properly. --- lib/puppet_x/templates/powershell/init_ps.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puppet_x/templates/powershell/init_ps.ps1 b/lib/puppet_x/templates/powershell/init_ps.ps1 index a7a37b5d..c9a670af 100644 --- a/lib/puppet_x/templates/powershell/init_ps.ps1 +++ b/lib/puppet_x/templates/powershell/init_ps.ps1 @@ -748,6 +748,8 @@ function Start-PipeServer $Encoding ) + Add-Type -AssemblyName System.Core + # this does not require versioning in the payload as client / server are tightly coupled $server = New-Object System.IO.Pipes.NamedPipeServerStream($CommandChannelPipeName, [System.IO.Pipes.PipeDirection]::InOut) From af70f10073c9467d109d06ba53399d4299b28ea6 Mon Sep 17 00:00:00 2001 From: Bill Hurt Date: Thu, 29 Mar 2018 14:11:35 -0700 Subject: [PATCH 10/11] (MAINT) Update changelog prior to 2.1.4 release --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6c6f453..ebad7dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,19 @@ +## 2017-03-29 - Supported Release 2.1.4 + +### Summary + +Small release with bug fixes + +### Bug Fixes + +- Unabled to start pipes server in PowerShell process on some Windows 2008r2 images ([MODULES-6927](https://tickets.puppetlabs.com/browse/MODULES-6927)) +- Minor updates to PowerShell syntax in README examples. + ## 2017-12-08 - Supported Release 2.1.3 ### Summary -Small release with bugs fixes. +Small release with bug fixes. ### Bug Fixes From d3dde885c0322632ca866e074236684677c6f99a Mon Sep 17 00:00:00 2001 From: Bill Hurt Date: Wed, 28 Mar 2018 10:35:37 -0700 Subject: [PATCH 11/11] (MODULES-6937) Release Prep 2.1.4 This commit updates the CHANGELOG.md and METADATA.json files to prep for the 2.1.4 release of the module. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index de9b0dc2..b8e6ccee 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-powershell", - "version": "2.1.3", + "version": "2.1.4", "author": "Puppet Inc", "summary": "Adds a new exec provider for executing PowerShell commands.", "license": "Apache-2.0",