Commit 40c42e30 authored by Ken Barber's avatar Ken Barber

PDB-308 Drop 2.7.x support

This patch removes support for Puppet 2.7.x in several ways:

* New check for every entry point in terminus will return an error if the
  version of Puppet is not supported. This is done in a 'soft' manner to
  avoid Puppet from not working.
* Documentation now only references Puppet 3
* Documentation now states only latest version of Puppet is supported
* Packaging now has hard dependencies on the latest version of Puppet
* Contrib gemspec has been updated
* Gemfile for tests have been updated
Signed-off-by: default avatarKen Barber <ken@bob.sh>
parent 04b90918
...@@ -7,14 +7,9 @@ group :test do ...@@ -7,14 +7,9 @@ group :test do
gem 'rspec', '2.13.0' gem 'rspec', '2.13.0'
gem 'puppetlabs_spec_helper', '0.4.1', :require => false gem 'puppetlabs_spec_helper', '0.4.1', :require => false
gem 'puppet', :require => false gem 'puppet', '>= 3.4.2', :require => false
gem 'mocha', '~> 1.0' gem 'mocha', '~> 1.0'
# Since newer versions of rake are not supported, we pin
if RUBY_VERSION == '1.8.5'
gem 'rake', '<= 0.8.7'
end
end end
group :acceptance do group :acceptance do
......
...@@ -64,6 +64,10 @@ ENV['PATH'] = "/opt/puppet/bin:" + ENV['PATH'] if @pe ...@@ -64,6 +64,10 @@ ENV['PATH'] = "/opt/puppet/bin:" + ENV['PATH'] if @pe
@osfamily = (Facter.value(:osfamily) || "").downcase @osfamily = (Facter.value(:osfamily) || "").downcase
# Specific minimum pinning for Puppet & Facter versions
@puppetminversion = "3.4.2"
@facterminversion = "1.6.11"
if @pe if @pe
@install_dir = "/opt/puppet/share/puppetdb" @install_dir = "/opt/puppet/share/puppetdb"
@etc_dir = "/etc/puppetlabs/puppetdb" @etc_dir = "/etc/puppetlabs/puppetdb"
......
...@@ -17,4 +17,5 @@ Gem::Specification.new do |gem| ...@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"] gem.require_paths = ["lib"]
gem.add_runtime_dependency 'json' gem.add_runtime_dependency 'json'
gem.add_runtime_dependency 'puppet', '>= 3.4.2'
end end
...@@ -4,19 +4,19 @@ layout: default ...@@ -4,19 +4,19 @@ layout: default
canonical: "/puppetdb/latest/api/wire_format/catalog_format.html" canonical: "/puppetdb/latest/api/wire_format/catalog_format.html"
--- ---
[containment]: /puppet/2.7/reference/lang_containment.html [containment]: /puppet/3/reference/lang_containment.html
[relationship]: /puppet/2.7/reference/lang_relationships.html [relationship]: /puppet/3/reference/lang_relationships.html
[chain]: /puppet/2.7/reference/lang_relationships.html#chaining-arrows [chain]: /puppet/3/reference/lang_relationships.html#chaining-arrows
[metaparameters]: /puppet/2.7/reference/lang_relationships.html#relationship-metaparameters [metaparameters]: /puppet/3/reference/lang_relationships.html#relationship-metaparameters
[require]: /puppet/2.7/reference/lang_relationships.html#the-require-function [require]: /puppet/3/reference/lang_relationships.html#the-require-function
[resource_ref]: /puppet/2.7/reference/lang_datatypes.html#resource-references [resource_ref]: /puppet/3/reference/lang_datatypes.html#resource-references
[numbers]: /puppet/2.7/reference/lang_datatypes.html#numbers [numbers]: /puppet/3/reference/lang_datatypes.html#numbers
[undef]: /puppet/2.7/reference/lang_datatypes.html#undef [undef]: /puppet/3/reference/lang_datatypes.html#undef
[namevar]: /puppet/2.7/reference/lang_resources.html#namenamevar [namevar]: /puppet/3/reference/lang_resources.html#namenamevar
[resource]: /puppet/2.7/reference/lang_resources.html [resource]: /puppet/3/reference/lang_resources.html
[title]: /puppet/2.7/reference/lang_resources.html#title [title]: /puppet/3/reference/lang_resources.html#title
[type]: /puppet/2.7/reference/lang_resources.html#type [type]: /puppet/3/reference/lang_resources.html#type
[attributes]: /puppet/2.7/reference/lang_resources.html#attributes [attributes]: /puppet/3/reference/lang_resources.html#attributes
[replace3]: ../commands.html#replace-catalog-version-3 [replace3]: ../commands.html#replace-catalog-version-3
[replace2]: ../commands.html#replace-catalog-version-2 [replace2]: ../commands.html#replace-catalog-version-2
[replace1]: ../commands.html#replace-catalog-version-1 [replace1]: ../commands.html#replace-catalog-version-1
......
...@@ -11,7 +11,7 @@ canonical: "/puppetdb/latest/community_add_ons.html" ...@@ -11,7 +11,7 @@ canonical: "/puppetdb/latest/community_add_ons.html"
[dashboard]: ./maintain_and_tune.html#monitor-the-performance-dashboard [dashboard]: ./maintain_and_tune.html#monitor-the-performance-dashboard
[query]: https://github.com/dalen/puppet-puppetdbquery [query]: https://github.com/dalen/puppet-puppetdbquery
[exports]: http://forge.puppetlabs.com/zack/exports [exports]: http://forge.puppetlabs.com/zack/exports
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
[Jason Hancock --- nagios-puppetdb][nagios] [Jason Hancock --- nagios-puppetdb][nagios]
----- -----
......
...@@ -4,7 +4,7 @@ layout: default ...@@ -4,7 +4,7 @@ layout: default
canonical: "/puppetdb/latest/connect_puppet_apply.html" canonical: "/puppetdb/latest/connect_puppet_apply.html"
--- ---
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
[package]: /references/latest/type.html#package [package]: /references/latest/type.html#package
[file]: /references/latest/type.html#file [file]: /references/latest/type.html#file
[yumrepo]: /references/latest/type.html#yumrepo [yumrepo]: /references/latest/type.html#yumrepo
...@@ -12,12 +12,12 @@ canonical: "/puppetdb/latest/connect_puppet_apply.html" ...@@ -12,12 +12,12 @@ canonical: "/puppetdb/latest/connect_puppet_apply.html"
[puppetdb_download]: http://downloads.puppetlabs.com/puppetdb [puppetdb_download]: http://downloads.puppetlabs.com/puppetdb
[puppetdb_conf]: /guides/configuring.html#puppetdbconf [puppetdb_conf]: /guides/configuring.html#puppetdbconf
[routes_yaml]: /guides/configuring.html#routesyaml [routes_yaml]: /guides/configuring.html#routesyaml
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
[jetty]: ./configure.html#jetty-http-settings [jetty]: ./configure.html#jetty-http-settings
[settings_namespace]: /puppet/2.7/reference/lang_variables.html#master-set-variables [settings_namespace]: /puppet/3/reference/lang_variables.html#master-set-variables
[ssl_script]: ./install_from_source.html#step-3-option-a-run-the-ssl-configuration-script [ssl_script]: ./install_from_source.html#step-3-option-a-run-the-ssl-configuration-script
> Note: To use PuppetDB, the nodes at your site must be running Puppet 2.7.12 or later. > Note: To use PuppetDB, the nodes at your site must be running Puppet 3.4.2 or later.
PuppetDB can also be used with standalone Puppet deployments where each node runs `puppet apply`. Once connected to PuppetDB, `puppet apply` will do the following: PuppetDB can also be used with standalone Puppet deployments where each node runs `puppet apply`. Once connected to PuppetDB, `puppet apply` will do the following:
......
...@@ -7,7 +7,7 @@ canonical: "/puppetdb/latest/connect_puppet_master.html" ...@@ -7,7 +7,7 @@ canonical: "/puppetdb/latest/connect_puppet_master.html"
[puppetdb_download]: http://downloads.puppetlabs.com/puppetdb [puppetdb_download]: http://downloads.puppetlabs.com/puppetdb
[puppetdb_conf]: /guides/configuring.html#puppetdbconf [puppetdb_conf]: /guides/configuring.html#puppetdbconf
[routes_yaml]: /guides/configuring.html#routesyaml [routes_yaml]: /guides/configuring.html#routesyaml
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
[install_via_module]: ./install_via_module.html [install_via_module]: ./install_via_module.html
[report_processors]: http://docs.puppetlabs.com/guides/reporting.html [report_processors]: http://docs.puppetlabs.com/guides/reporting.html
[event]: ./api/query/v3/event.html [event]: ./api/query/v3/event.html
...@@ -15,7 +15,7 @@ canonical: "/puppetdb/latest/connect_puppet_master.html" ...@@ -15,7 +15,7 @@ canonical: "/puppetdb/latest/connect_puppet_master.html"
[store_report]: ./api/commands.html#store-report-version-1 [store_report]: ./api/commands.html#store-report-version-1
[report_format]: ./api/wire_format/report_format.html [report_format]: ./api/wire_format/report_format.html
> Note: To use PuppetDB, your site's puppet master(s) must be running Puppet 2.7.12 or later . > Note: To use PuppetDB, your site's puppet master(s) must be running Puppet 3.4.2 or later .
After PuppetDB is installed and running, you should configure your puppet master(s) to use it. Once connected to PuppetDB, puppet masters will do the following: After PuppetDB is installed and running, you should configure your puppet master(s) to use it. Once connected to PuppetDB, puppet masters will do the following:
......
...@@ -4,7 +4,7 @@ layout: default ...@@ -4,7 +4,7 @@ layout: default
canonical: "/puppetdb/latest/index.html" canonical: "/puppetdb/latest/index.html"
--- ---
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
[inventory]: /guides/inventory_service.html [inventory]: /guides/inventory_service.html
[connect]: ./connect_puppet_master.html [connect]: ./connect_puppet_master.html
[apply]: ./connect_puppet_apply.html [apply]: ./connect_puppet_apply.html
...@@ -12,8 +12,8 @@ canonical: "/puppetdb/latest/index.html" ...@@ -12,8 +12,8 @@ canonical: "/puppetdb/latest/index.html"
[install_from_packages]: ./install_from_packages.html [install_from_packages]: ./install_from_packages.html
[install_advanced]: ./install_from_source.html [install_advanced]: ./install_from_source.html
[scaling]: ./scaling_recommendations.html [scaling]: ./scaling_recommendations.html
[facts]: /puppet/2.7/reference/lang_variables.html#facts [facts]: /puppet/3/reference/lang_variables.html#facts
[catalog]: /puppet/2.7/reference/lang_summary.html#compilation-and-catalogs [catalog]: /puppet/3/reference/lang_summary.html#compilation-and-catalogs
[releasenotes]: ./release_notes.html [releasenotes]: ./release_notes.html
[github]: https://github.com/puppetlabs/puppetdb [github]: https://github.com/puppetlabs/puppetdb
[redmine]: http://projects.puppetlabs.com/projects/puppetdb/issues [redmine]: http://projects.puppetlabs.com/projects/puppetdb/issues
...@@ -86,9 +86,9 @@ If you're willing to do some manual configuration, PuppetDB can run on any Unix- ...@@ -86,9 +86,9 @@ If you're willing to do some manual configuration, PuppetDB can run on any Unix-
[See here for advanced installation instructions.][install_advanced] [See here for advanced installation instructions.][install_advanced]
### Puppet 2.7.12 ### Puppet 3.4.2
Your site's puppet masters must be running Puppet 2.7.12 or later. [You will need to connect your puppet masters to PuppetDB after installing it][connect]. If you wish to use PuppetDB with [standalone nodes that are running puppet apply][apply], every node must be running 2.7.12 or later. Your site's puppet masters must be running Puppet 3.4.2 or later. [You will need to connect your puppet masters to PuppetDB after installing it][connect]. If you wish to use PuppetDB with [standalone nodes that are running puppet apply][apply], every node must be running 3.4.2 or later.
> #### Note about Puppet Enterprise > #### Note about Puppet Enterprise
> >
......
...@@ -4,7 +4,7 @@ layout: default ...@@ -4,7 +4,7 @@ layout: default
canonical: "/puppetdb/latest/using.html" canonical: "/puppetdb/latest/using.html"
--- ---
[exported]: /puppet/2.7/reference/lang_exported.html [exported]: /puppet/3/reference/lang_exported.html
Currently, the main use for PuppetDB is to enable advanced features in Puppet. We expect additional applications to be built on PuppetDB as it becomes more widespread. Currently, the main use for PuppetDB is to enable advanced features in Puppet. We expect additional applications to be built on PuppetDB as it becomes more widespread.
......
%global realname puppetdb %global realname puppetdb
%global realversion <%= Pkg::Config.version %> %global realversion <%= Pkg::Config.version %>
%global rpmversion <%= Pkg::Config.rpmversion %> %global rpmversion <%= Pkg::Config.rpmversion %>
%global puppetminversion <%= @puppetminversion %>
%global facterminversion <%= @facterminversion %>
%define __jar_repack 0 %define __jar_repack 0
...@@ -84,17 +86,17 @@ Group: System Environment/Daemons ...@@ -84,17 +86,17 @@ Group: System Environment/Daemons
%endif %endif
<% if @pe -%> <% if @pe -%>
BuildRequires: pe-facter >= 1.6.2, pe-puppet BuildRequires: pe-facter >= %{facterminversion}, pe-puppet
BuildRequires: pe-rubygem-rake BuildRequires: pe-rubygem-rake
BuildRequires: pe-ruby BuildRequires: pe-ruby
Requires: pe-puppet >= 2.7.12 Requires: pe-puppet >= %{puppetminversion}
<% else -%> <% else -%>
BuildRequires: facter >= 1.6.8 BuildRequires: facter >= %{facterminversion}
BuildRequires: puppet >= 2.7.12 BuildRequires: puppet >= %{puppetminversion}
BuildRequires: rubygem-rake BuildRequires: rubygem-rake
BuildRequires: ruby BuildRequires: ruby
Requires: puppet >= 2.7.12 Requires: puppet >= %{puppetminversion}
Requires: facter >= 1.6.8 Requires: facter >= %{facterminversion}
<% end -%> <% end -%>
BuildArch: noarch BuildArch: noarch
%if 0%{?suse_version} %if 0%{?suse_version}
...@@ -134,9 +136,9 @@ Group: System/Libraries ...@@ -134,9 +136,9 @@ Group: System/Libraries
Group: Development/Libraries Group: Development/Libraries
%endif %endif
<% if @pe -%> <% if @pe -%>
Requires: pe-puppet >= 2.7.12 Requires: pe-puppet >= %{puppetminversion}
<% else -%> <% else -%>
Requires: puppet >= 2.7.12 Requires: puppet >= %{puppetminversion}
Requires: rubygem-json Requires: rubygem-json
<% end -%> <% end -%>
......
...@@ -3,9 +3,9 @@ Section: utils ...@@ -3,9 +3,9 @@ Section: utils
Priority: optional Priority: optional
Maintainer: Puppet Labs <info@puppetlabs.com> Maintainer: Puppet Labs <info@puppetlabs.com>
<% if @pe -%> <% if @pe -%>
Build-Depends: debhelper (>= 7.0.0~), cdbs, bc, mawk, lsb-release, pe-rubygem-rake, pe-facter, pe-puppet Build-Depends: debhelper (>= 7.0.0~), cdbs, bc, mawk, lsb-release, pe-rubygem-rake, pe-facter (>= <%= @facterminversion %>), pe-puppet (>= <%= @puppetminversion %>)
<% else -%> <% else -%>
Build-Depends: debhelper (>= 7.0.0~), cdbs, bc, mawk, lsb-release, rake, facter, puppet Build-Depends: debhelper (>= 7.0.0~), cdbs, bc, mawk, lsb-release, rake, facter (>= <%= @facterminversion %>), puppet (>= <%= @puppetminversion %>)
<% end -%> <% end -%>
Standards-Version: 3.9.1 Standards-Version: 3.9.1
Homepage: http://puppetlabs.com Homepage: http://puppetlabs.com
...@@ -13,9 +13,9 @@ Homepage: http://puppetlabs.com ...@@ -13,9 +13,9 @@ Homepage: http://puppetlabs.com
Package: <%= @name %> Package: <%= @name %>
Architecture: all Architecture: all
<% if @pe -%> <% if @pe -%>
Depends: ${misc:Depends}, pe-java, adduser, pe-puppet Depends: ${misc:Depends}, pe-java, adduser, pe-puppet (>= <%= @puppetminversion %>)
<% else -%> <% else -%>
Depends: ${misc:Depends}, java7-runtime-headless | j2re1.7 | java6-runtime-headless, adduser, puppet (>= 2.7.12) Depends: ${misc:Depends}, java7-runtime-headless | j2re1.7 | java6-runtime-headless, adduser, puppet (>= <%= @puppetminversion %>)
Suggests: postgresql Suggests: postgresql
<% end -%> <% end -%>
Description:PuppetDB Centralized Storage. Description:PuppetDB Centralized Storage.
...@@ -23,8 +23,8 @@ Description:PuppetDB Centralized Storage. ...@@ -23,8 +23,8 @@ Description:PuppetDB Centralized Storage.
Package: <%= @name %>-terminus Package: <%= @name %>-terminus
Architecture: all Architecture: all
<% if @pe -%> <% if @pe -%>
Depends: ${misc:Depends}, pe-puppet Depends: ${misc:Depends}, pe-puppet (>= <%= @puppetminversion %>)
<% else -%> <% else -%>
Depends: ${misc:Depends}, puppet-common, libjson-ruby | ruby-json Depends: ${misc:Depends}, puppet-common (>= <%= @puppetminversion %>), libjson-ruby | ruby-json
<% end -%> <% end -%>
Description:Connect Puppet to PuppetDB by setting up a terminus for PuppetDB. Description:Connect Puppet to PuppetDB by setting up a terminus for PuppetDB.
...@@ -16,6 +16,8 @@ Puppet::Face.define(:node, '0.0.1') do ...@@ -16,6 +16,8 @@ Puppet::Face.define(:node, '0.0.1') do
DESC DESC
when_invoked do |*args| when_invoked do |*args|
Puppet::Util::Puppetdb::GlobalCheck.run
opts = args.pop opts = args.pop
raise ArgumentError, "Please provide at least one node for deactivation" if args.empty? raise ArgumentError, "Please provide at least one node for deactivation" if args.empty?
......
...@@ -14,6 +14,8 @@ Puppet::Face.define(:node, '0.0.1') do ...@@ -14,6 +14,8 @@ Puppet::Face.define(:node, '0.0.1') do
require 'puppet/util/puppetdb' require 'puppet/util/puppetdb'
require 'json' require 'json'
Puppet::Util::Puppetdb::GlobalCheck.run
opts = args.pop opts = args.pop
raise ArgumentError, "Please provide at least one node" if args.empty? raise ArgumentError, "Please provide at least one node" if args.empty?
......
...@@ -22,6 +22,9 @@ Puppet::Face.define(:storeconfigs, '0.0.1') do ...@@ -22,6 +22,9 @@ Puppet::Face.define(:storeconfigs, '0.0.1') do
DESC DESC
when_invoked do |options| when_invoked do |options|
require 'puppet/util/puppetdb/global_check'
Puppet::Util::Puppetdb::GlobalCheck.run
require 'puppet/rails' require 'puppet/rails'
tmpdir = Dir.mktmpdir tmpdir = Dir.mktmpdir
...@@ -100,15 +103,16 @@ Puppet::Face.define(:storeconfigs, '0.0.1') do ...@@ -100,15 +103,16 @@ Puppet::Face.define(:storeconfigs, '0.0.1') do
File.expand_path("storeconfigs-#{timestamp.strftime('%Y%m%d%H%M%S')}.tar") File.expand_path("storeconfigs-#{timestamp.strftime('%Y%m%d%H%M%S')}.tar")
end end
# Execute a command using Puppet's execution static method.
#
# @param command [Array<String>, String] the command to execute. If it is
# an Array the first element should be the executable and the rest of the
# elements should be the individual arguments to that executable.
# @return [Puppet::Util::Execution::ProcessOutput] output as specified by options
# @raise [Puppet::ExecutionFailure] if the executed chiled process did not exit with status == 0 and `failonfail` is
# `true`.
def execute(command) def execute(command)
# Puppet::Util::Execution is the preferred way to do this in newer Puppets, Puppet::Util::Execution.execute(command)
# but isn't available in older versions. For the sake of not getting
# deprecation warnings, we choose intelligently.
if Puppet::Util::Execution.respond_to?(:execute)
Puppet::Util::Execution.execute(command)
else
Puppet::Util.execute(command)
end
end end
def node_to_catalog_hash(node) def node_to_catalog_hash(node)
......
...@@ -6,6 +6,11 @@ class Puppet::Resource::Catalog::Puppetdb < Puppet::Indirector::REST ...@@ -6,6 +6,11 @@ class Puppet::Resource::Catalog::Puppetdb < Puppet::Indirector::REST
include Puppet::Util::Puppetdb include Puppet::Util::Puppetdb
include Puppet::Util::Puppetdb::CommandNames include Puppet::Util::Puppetdb::CommandNames
# Run initial checks
def initialize
Puppet::Util::Puppetdb::GlobalCheck.run
end
def save(request) def save(request)
catalog = munge_catalog(request.instance, extract_extra_request_data(request)) catalog = munge_catalog(request.instance, extract_extra_request_data(request))
......
...@@ -7,6 +7,11 @@ class Puppet::Node::Facts::Puppetdb < Puppet::Indirector::REST ...@@ -7,6 +7,11 @@ class Puppet::Node::Facts::Puppetdb < Puppet::Indirector::REST
include Puppet::Util::Puppetdb include Puppet::Util::Puppetdb
include Puppet::Util::Puppetdb::CommandNames include Puppet::Util::Puppetdb::CommandNames
# Run initial checks
def initialize
Puppet::Util::Puppetdb::GlobalCheck.run
end
def save(request) def save(request)
facts = request.instance.dup facts = request.instance.dup
facts.values = facts.values.dup facts.values = facts.values.dup
......
...@@ -5,6 +5,11 @@ require 'puppet/util/puppetdb' ...@@ -5,6 +5,11 @@ require 'puppet/util/puppetdb'
class Puppet::Node::Puppetdb < Puppet::Indirector::REST class Puppet::Node::Puppetdb < Puppet::Indirector::REST
include Puppet::Util::Puppetdb include Puppet::Util::Puppetdb
# Run initial checks
def initialize
Puppet::Util::Puppetdb::GlobalCheck.run
end
def find(request) def find(request)
end end
......
...@@ -5,6 +5,11 @@ require 'json' ...@@ -5,6 +5,11 @@ require 'json'
class Puppet::Resource::Puppetdb < Puppet::Indirector::REST class Puppet::Resource::Puppetdb < Puppet::Indirector::REST
include Puppet::Util::Puppetdb include Puppet::Util::Puppetdb
# Run initial checks
def initialize
Puppet::Util::Puppetdb::GlobalCheck.run
end
def search(request) def search(request)
type = request.key type = request.key
host = request.options[:host] host = request.options[:host]
......
...@@ -2,10 +2,11 @@ require 'puppet' ...@@ -2,10 +2,11 @@ require 'puppet'
require 'puppet/util/puppetdb' require 'puppet/util/puppetdb'
require 'puppet/util/puppetdb/command_names' require 'puppet/util/puppetdb/command_names'
Puppet::Reports.register_report(:puppetdb) do Puppet::Reports.register_report(:puppetdb) do
include Puppet::Util::Puppetdb include Puppet::Util::Puppetdb
Puppet::Util::Puppetdb::GlobalCheck.run
CommandStoreReport = Puppet::Util::Puppetdb::CommandNames::CommandStoreReport CommandStoreReport = Puppet::Util::Puppetdb::CommandNames::CommandStoreReport
desc <<-DESC desc <<-DESC
......
require 'puppet/util' require 'puppet/util'
require 'puppet/util/logging' require 'puppet/util/logging'
require 'puppet/util/puppetdb/global_check'
require 'puppet/util/puppetdb/command_names' require 'puppet/util/puppetdb/command_names'
require 'puppet/util/puppetdb/command' require 'puppet/util/puppetdb/command'
require 'puppet/util/puppetdb/config' require 'puppet/util/puppetdb/config'
......
require 'semver'
require 'puppet/version'
require 'puppet/error'
module Puppet::Util::Puppetdb
# Global checks for version support and other validations before the terminus
# is used.
#
class GlobalCheck
# Validate that the support for the version of Puppet we are running on is
# still maintained.
#
# @param minimum [String] minimum version for operation
# @throws [Puppet::Error] raised if current version is unsupported
# @api private
def self.puppet_version_check(minimum)
minimum_version = ::SemVer.new(minimum)
puppet_version = ::SemVer.new(Puppet.version)
if (puppet_version <=> minimum_version) == -1 then
raise Puppet::Error, "You are attempting to use puppetdb-terminus on an unsupported version of Puppet (#{puppet_version}) the minimum supported version is #{minimum_version}"
end
end
# Run all checks
#
# @throws [Puppet::Error] raised for any validation errors
def self.run
self.puppet_version_check("3.4.2")
end
end
end
require 'spec_helper'
require 'puppet/util/puppetdb'
describe Puppet::Util::Puppetdb::GlobalCheck do
describe "#puppet_version_check" do
it 'should throw exception if we are running an older version' do
expect {
Puppet::Util::Puppetdb::GlobalCheck.puppet_version_check("100.0.0")
}.to raise_error(Puppet::Error, /You are attempting to use puppetdb-terminus on an unsupported version of Puppet/)
end
it 'should do nothing for newer versions' do
Puppet::Util::Puppetdb::GlobalCheck.puppet_version_check("1.0.0")
end
end
describe "#run" do
it 'should do nothing as tests should only run on valid versions' do
Puppet::Util::Puppetdb::GlobalCheck.run
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment