From da5fe257e5552d159b24dc02cba121ae15eba515 Mon Sep 17 00:00:00 2001 From: Trevor Vaughan Date: Wed, 9 May 2018 16:38:18 -0400 Subject: [PATCH] Fix support for 'puppet generate types' (#41) This works around SERVER-94 issues Puppet < 4.10.4 does not properly process the 'puppet generate types' supporting composite namevars. Closes #40 --- .travis.yml | 22 +++++++++++++------ CHANGELOG.md | 7 ++++++ .../provider/sshd_config_match/augeas.rb | 2 +- lib/puppet/type/sshd_config.rb | 4 ++-- lib/puppet/type/sshd_config_match.rb | 13 +++++------ metadata.json | 20 +++++++++++++++-- spec/spec_helper.rb | 2 +- 7 files changed, 50 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1cba8f6..1c6d21a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,36 @@ language: ruby +dist: precise sudo: required rvm: - 2.1.9 - - 2.3.1 + # Ruby with Puppet 5 + - 2.4.4 notifications: email: - raphael.pinson@camptocamp.com env: - # Most common LTS Puppet Version - - PUPPET=4.7 RUBY_AUGEAS=0.5 FORGE_PUBLISH=true - # Current LTS Puppet Version - - PUPPET=4.10 RUBY_AUGEAS=0.5 +# base env + # Test Puppet 4 + - PUPPET=4.0 RUBY_AUGEAS=0.5 + # Test Oldest Puppet, Inc. supported Puppet + - PUPPET=4.10.4 RUBY_AUGEAS=0.5 FORGE_PUBLISH=true + # Test latest Puppet version + - PUPPET=5.5 RUBY_AUGEAS=0.5 matrix: fast_finish: true + exclude: + # base exclude + # No support for Ruby 2.1.9 in Puppet 5 + - rvm: 2.1.9 + env: PUPPET=5.5 RUBY_AUGEAS=0.5 install: - "travis_retry ./.travis.sh" - script: - AUGEAS_LENS_LIB=lib/augeas/lenses:augeas/lenses bundle exec rake # Do not include the augeas/ directory in the deployed module - rm -rf augeas/ - deploy: provider: puppetforge user: herculesteam diff --git a/CHANGELOG.md b/CHANGELOG.md index c1e2512..e64f57c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 3.0.0 + +- Fix support for 'puppet generate types' +- Bumped supported puppet version to less than 6.0.0 +- Updated the spec_helper.rb to correctly load for Puppet 5 +- Added CentOS and OracleLinux to supported OS list + ## 2.5.3 - ssh_config: fix HostKeyAlgorithms and KexAlgorithms (#GH 36) diff --git a/lib/puppet/provider/sshd_config_match/augeas.rb b/lib/puppet/provider/sshd_config_match/augeas.rb index 3f8c9c0..ce49ec1 100644 --- a/lib/puppet/provider/sshd_config_match/augeas.rb +++ b/lib/puppet/provider/sshd_config_match/augeas.rb @@ -121,7 +121,7 @@ def position! end end - def create + def create augopen! do |aug| path = self.class.static_path(resource) aug.defnode('resource', path, nil) diff --git a/lib/puppet/type/sshd_config.rb b/lib/puppet/type/sshd_config.rb index 50d2c38..7885db4 100644 --- a/lib/puppet/type/sshd_config.rb +++ b/lib/puppet/type/sshd_config.rb @@ -26,14 +26,14 @@ newproperty(:value, :array_matching => :all) do desc "Value to change the setting to. The follow parameters take an array of values: - + - MACs; - AcceptEnv; - AllowGroups; - AllowUsers; - DenyGroups; - DenyUsers. - + All other parameters take a string. When passing an array to other parameters, only the first value in the array will be considered." end diff --git a/lib/puppet/type/sshd_config_match.rb b/lib/puppet/type/sshd_config_match.rb index 8647518..ed48f03 100644 --- a/lib/puppet/type/sshd_config_match.rb +++ b/lib/puppet/type/sshd_config_match.rb @@ -44,27 +44,26 @@ def insync?(is) end def self.title_patterns - identity = lambda { |x| x } [ [ /^(((?:\S*\s+\S*)+)\s+in\s+(\S+))$/, [ - [ :name, identity ], - [ :condition, identity ], - [ :target, identity ], + [ :name ], + [ :condition ], + [ :target ], ] ], [ /^(((?:\S*\s+\S*)+))$/, [ - [ :name, identity ], - [ :condition, identity ], + [ :name ], + [ :condition ], ] ], [ /(.*)/, [ - [ :name, identity ], + [ :name ], ] ] ] diff --git a/metadata.json b/metadata.json index 2c3edef..a682026 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "herculesteam-augeasproviders_ssh", - "version": "2.5.3", + "version": "3.0.0", "author": "Dominic Cleal, Raphael Pinson", "summary": "Augeas-based ssh types and providers for Puppet", "license": "Apache-2.0", @@ -43,9 +43,25 @@ "6", "7" ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "4", + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "6", + "7" + ] } ], "requirements": [ - { "name": "puppet", "version_requirement": ">= 2.7.0 < 5.0.0" } + { "name": "puppet", "version_requirement": ">= 4.10.4 < 6.0.0" } ] } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cee5c46..823c65b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -34,7 +34,7 @@ # ticket https://tickets.puppetlabs.com/browse/MODULES-823 # ver = Gem::Version.new(Puppet.version.split('-').first) -if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0") =~ ver +if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0") =~ ver || Gem::Requirement.new("~> 5.0") =~ ver puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" # libdir is only a single dir, so it can only workaround loading of one external module Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib"