From 52887ebcf62a976ebf92a26c07a7ab74ed108cb6 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 5 Mar 2015 19:09:50 -0800 Subject: [PATCH] Add eyaml gem version param --- CHANGELOG.md | 5 +++-- README.md | 5 ++++- manifests/eyaml.pp | 29 ++++++++++++++++++++--------- manifests/init.pp | 1 + 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9496e..6484499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ All notable changes to this project will be documented in this file. ## [1.2.0] - 2015-03-05 ### Features: -- Added `hiera::eyaml::create_keys` param to disable pkcs7 key generation with +- Added `hiera::create_keys` param to disable pkcs7 key generation with hiera-eyaml -- Added `hiera::eyaml::gem_source` param to specify source of hiera-eyaml gem +- Added `hiera::gem_source` param to specify source of hiera-eyaml gem +- Added `hiera::eyaml_version` param to specify the version of eyaml ### Bugfixes: - Change Modulefile to metadata.json diff --git a/README.md b/README.md index 5a059c5..e5a17c8 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,9 @@ The following parameters are available for the hiera class: * `eyaml_extension` The file extension for the eyaml backend. Default: `undef`, backend defaults to `'.eyaml'` +* `eyaml_version` + The version of hiera-eyaml to install. Accepts 'installed', 'latest', '2.0.7', etc + Default: `undef` * `confdir` The path to Puppet's confdir. Default: @@ -182,7 +185,7 @@ The following parameters are available for the hiera class: ## Limitations -The pe-puppetserver service must be restarted after hiera-eyaml is installed; this module will not do it for you. +The pe-puppetserver service must be restarted after hiera-eyaml is installed; this module will not do it for you. The `eyaml_version` parameter does not currently modify the eyaml version of the command-line gem on pe-puppetserver. ## Development diff --git a/manifests/eyaml.pp b/manifests/eyaml.pp index 43ace1d..77d9552 100644 --- a/manifests/eyaml.pp +++ b/manifests/eyaml.pp @@ -11,17 +11,22 @@ # Copyright (C) 2014 Terri Haber, unless otherwise noted. # class hiera::eyaml ( - $provider = $hiera::params::provider, - $owner = $hiera::owner, - $group = $hiera::group, - $cmdpath = $hiera::cmdpath, - $confdir = $hiera::confdir, - $create_keys = $hiera::create_keys, - $gem_source = $hiera::gem_source, + $provider = $hiera::params::provider, + $owner = $hiera::owner, + $group = $hiera::group, + $cmdpath = $hiera::cmdpath, + $confdir = $hiera::confdir, + $create_keys = $hiera::create_keys, + $eyaml_version = $hiera::eyaml_version, + $gem_source = $hiera::gem_source, ) inherits hiera::params { + $package_ensure = $eyaml_version ? { + undef => 'installed', + default => $eyaml_version, + } package { 'hiera-eyaml': - ensure => installed, + ensure => $package_ensure, provider => $provider, source => $gem_source, } @@ -29,8 +34,14 @@ # The puppetserver gem wouldn't install the commandline util, so we do # that here #XXX Pre-puppet 4.0.0 version (PUP-1073) + #BUG This can't actually update the gem version if already installed. + if $eyaml_version =~ /^\d+\.\d+\.\d+$/ { + $gem_flag = "--version ${eyaml_version}" + } else { + $gem_flag = undef + } exec { 'install pe_gem': - command => '/opt/puppet/bin/gem install hiera-eyaml', + command => "/opt/puppet/bin/gem install hiera-eyaml ${gem_flag}", creates => '/opt/puppet/bin/eyaml', } #XXX Post-puppet 4.0.0 diff --git a/manifests/init.pp b/manifests/init.pp index 5aa5fa3..cbeec19 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,6 +54,7 @@ $cmdpath = ['/opt/puppet/bin', '/usr/bin', '/usr/local/bin'], $create_keys = true, $gem_source = undef, + $eyaml_version = undef, $merge_behavior = undef, $extra_config = '', ) inherits hiera::params {