diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d04747..38cacd4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -51,19 +51,34 @@ You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development system_tests release +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --with system_tests --without development release +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --with system_tests --without development release; bundle update; bundle clean +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" +``` + +### Note for OS X users + +`nproc` isn't a valid command unter OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" ``` ## Syntax and style @@ -160,7 +175,7 @@ created virtual machines will be in `.vagrant/beaker_vagrant_files`. Beaker also supports docker containers. We also use that in our automated CI pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: -``` +```sh PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker ``` diff --git a/.msync.yml b/.msync.yml index 5519891..23dfa32 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.7.0' +modulesync_config_version: '2.8.0' diff --git a/CHANGELOG.md b/CHANGELOG.md index c996078..c4cd63e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.0.0](https://github.com/voxpupuli/puppet-hiera/tree/v4.0.0) (2019-11-27) + +[Full Changelog](https://github.com/voxpupuli/puppet-hiera/compare/v3.4.1...v4.0.0) + +**Breaking changes:** + +- drop Ubuntu 14.04 support [\#273](https://github.com/voxpupuli/puppet-hiera/pull/273) ([bastelfreak](https://github.com/bastelfreak)) +- modulesync 2.7.0 and drop puppet 4 [\#249](https://github.com/voxpupuli/puppet-hiera/pull/249) ([bastelfreak](https://github.com/bastelfreak)) + +**Implemented enhancements:** + +- hiera.yaml is word readable. Allow setting different permissions to hide secrets [\#266](https://github.com/voxpupuli/puppet-hiera/pull/266) ([maxadamo](https://github.com/maxadamo)) + +**Closed issues:** + +- hiera.yaml is word readable, but it can contain secret tokens [\#265](https://github.com/voxpupuli/puppet-hiera/issues/265) +- Incompatible with Puppet-6 [\#263](https://github.com/voxpupuli/puppet-hiera/issues/263) +- Cannot install deep\_merge gem. [\#252](https://github.com/voxpupuli/puppet-hiera/issues/252) + +**Merged pull requests:** + +- allow puppetlabs/inifile 4.x [\#274](https://github.com/voxpupuli/puppet-hiera/pull/274) ([bastelfreak](https://github.com/bastelfreak)) +- Clean up acceptance spec helper [\#272](https://github.com/voxpupuli/puppet-hiera/pull/272) ([ekohl](https://github.com/ekohl)) +- Format options value as json if it is a hash [\#270](https://github.com/voxpupuli/puppet-hiera/pull/270) ([ZeroPointEnergy](https://github.com/ZeroPointEnergy)) +- Allow `puppetlabs/stdlib` 6.x [\#262](https://github.com/voxpupuli/puppet-hiera/pull/262) ([alexjfisher](https://github.com/alexjfisher)) + ## [v3.4.1](https://github.com/voxpupuli/puppet-hiera/tree/v3.4.1) (2019-05-01) [Full Changelog](https://github.com/voxpupuli/puppet-hiera/compare/v3.4.0...v3.4.1) @@ -18,6 +44,7 @@ These should not affect the functionality of the module. **Merged pull requests:** +- Release 3.4.1 [\#261](https://github.com/voxpupuli/puppet-hiera/pull/261) ([rnelson0](https://github.com/rnelson0)) - Allow `puppetlabs/inifile` 3.x [\#256](https://github.com/voxpupuli/puppet-hiera/pull/256) ([alexjfisher](https://github.com/alexjfisher)) ## [v3.4.0](https://github.com/voxpupuli/puppet-hiera/tree/v3.4.0) (2019-04-25) @@ -53,7 +80,6 @@ These should not affect the functionality of the module. - allow puppetlabs/stdlib 5.x [\#231](https://github.com/voxpupuli/puppet-hiera/pull/231) ([bastelfreak](https://github.com/bastelfreak)) - allow puppetlabs/inifile 2.x [\#228](https://github.com/voxpupuli/puppet-hiera/pull/228) ([bastelfreak](https://github.com/bastelfreak)) -- Remove docker nodesets [\#223](https://github.com/voxpupuli/puppet-hiera/pull/223) ([bastelfreak](https://github.com/bastelfreak)) - drop EOL OSs; fix puppet version range [\#222](https://github.com/voxpupuli/puppet-hiera/pull/222) ([bastelfreak](https://github.com/bastelfreak)) ## [v3.3.2](https://github.com/voxpupuli/puppet-hiera/tree/v3.3.2) (2018-03-28) @@ -66,6 +92,7 @@ These should not affect the functionality of the module. **Merged pull requests:** +- Remove docker nodesets [\#223](https://github.com/voxpupuli/puppet-hiera/pull/223) ([bastelfreak](https://github.com/bastelfreak)) - bump puppet to latest supported version 4.10.0 [\#217](https://github.com/voxpupuli/puppet-hiera/pull/217) ([bastelfreak](https://github.com/bastelfreak)) ## [v3.3.1](https://github.com/voxpupuli/puppet-hiera/tree/v3.3.1) (2017-12-09) @@ -90,7 +117,7 @@ These should not affect the functionality of the module. **Implemented enhancements:** -- Add datadir key for hiera5 hierarchy. [\#204](https://github.com/voxpupuli/puppet-hiera/pull/204) ([disappear89](https://github.com/disappear89)) +- Add datadir key for hiera5 hierarchy. [\#204](https://github.com/voxpupuli/puppet-hiera/pull/204) ([ThoTischner](https://github.com/ThoTischner)) **Closed issues:** @@ -214,9 +241,7 @@ These should not affect the functionality of the module. - Relicense BSD-2-Clause to Apache-2.0 [\#149](https://github.com/voxpupuli/puppet-hiera/pull/149) ([hunner](https://github.com/hunner)) - Modulesync 0.12.2 & Release 2.1.1 [\#148](https://github.com/voxpupuli/puppet-hiera/pull/148) ([bastelfreak](https://github.com/bastelfreak)) -- modulesync 0.11.1 [\#145](https://github.com/voxpupuli/puppet-hiera/pull/145) ([bastelfreak](https://github.com/bastelfreak)) - module is compatible with PE2016.2 [\#144](https://github.com/voxpupuli/puppet-hiera/pull/144) ([vchepkov](https://github.com/vchepkov)) -- modulesync 0.11.0 [\#143](https://github.com/voxpupuli/puppet-hiera/pull/143) ([bastelfreak](https://github.com/bastelfreak)) - Update metadata.json to not give dependency errors in puppet3.8 [\#142](https://github.com/voxpupuli/puppet-hiera/pull/142) ([cryptk](https://github.com/cryptk)) - modulesync 0.8.0 [\#139](https://github.com/voxpupuli/puppet-hiera/pull/139) ([bastelfreak](https://github.com/bastelfreak)) - modulesync 0.6.2 [\#137](https://github.com/voxpupuli/puppet-hiera/pull/137) ([bastelfreak](https://github.com/bastelfreak)) diff --git a/Gemfile b/Gemfile index 24dbb7f..9571ef3 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ group :test do gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-variable_contains_upcase', :require => false gem 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-topscope-variable-check', :require => false gem 'metadata-json-lint', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false diff --git a/manifests/deep_merge.pp b/manifests/deep_merge.pp index 0ae320d..4a3c318 100644 --- a/manifests/deep_merge.pp +++ b/manifests/deep_merge.pp @@ -11,11 +11,11 @@ # Copyright (C) 2016 Joseph Yaworski, unless otherwise noted. # class hiera::deep_merge { - $provider = $::hiera::provider - $deep_merge_version = $::hiera::deep_merge_version - $deep_merge_source = $::hiera::deep_merge_source - $deep_merge_name = $::hiera::deep_merge_name - $manage_package = $::hiera::manage_deep_merge_package + $provider = $hiera::provider + $deep_merge_version = $hiera::deep_merge_version + $deep_merge_source = $hiera::deep_merge_source + $deep_merge_name = $hiera::deep_merge_name + $manage_package = $hiera::manage_deep_merge_package if $manage_package { ::hiera::install { 'deep_merge': diff --git a/manifests/eyaml.pp b/manifests/eyaml.pp index 44486dc..c918fe8 100644 --- a/manifests/eyaml.pp +++ b/manifests/eyaml.pp @@ -11,19 +11,19 @@ # Copyright (C) 2014 Terri Haber, unless otherwise noted. # class hiera::eyaml { - $eyaml_name = $::hiera::eyaml_name - $provider = $::hiera::provider - $eyaml_version = $::hiera::eyaml_version - $eyaml_source = $::hiera::_eyaml_source + $eyaml_name = $hiera::eyaml_name + $provider = $hiera::provider + $eyaml_version = $hiera::eyaml_version + $eyaml_source = $hiera::_eyaml_source - $owner = $::hiera::eyaml_owner - $group = $::hiera::eyaml_group - $cmdpath = $::hiera::cmdpath - $confdir = $::hiera::confdir - $create_keys = $::hiera::create_keys - $_keysdir = $::hiera::_keysdir + $owner = $hiera::eyaml_owner + $group = $hiera::eyaml_group + $cmdpath = $hiera::cmdpath + $confdir = $hiera::confdir + $create_keys = $hiera::create_keys + $_keysdir = $hiera::_keysdir - $manage_package = $::hiera::manage_eyaml_package + $manage_package = $hiera::manage_eyaml_package if $manage_package { ::hiera::install { 'eyaml': diff --git a/manifests/eyaml_gpg.pp b/manifests/eyaml_gpg.pp index 8a184c1..9ce186d 100644 --- a/manifests/eyaml_gpg.pp +++ b/manifests/eyaml_gpg.pp @@ -3,21 +3,21 @@ # This calls install and configures hiera-eyaml-gpg # class hiera::eyaml_gpg { - $provider = $::hiera::provider - $eyaml_gpg_name = $::hiera::eyaml_gpg_name - $eyaml_gpg_version = $::hiera::eyaml_gpg_version - $eyaml_gpg_source = $::hiera::_eyaml_gpg_source + $provider = $hiera::provider + $eyaml_gpg_name = $hiera::eyaml_gpg_name + $eyaml_gpg_version = $hiera::eyaml_gpg_version + $eyaml_gpg_source = $hiera::_eyaml_gpg_source - $ruby_gpg_name = $::hiera::ruby_gpg_name - $ruby_gpg_version = $::hiera::ruby_gpg_version - $ruby_gpg_source = $::hiera::ruby_gpg_source + $ruby_gpg_name = $hiera::ruby_gpg_name + $ruby_gpg_version = $hiera::ruby_gpg_version + $ruby_gpg_source = $hiera::ruby_gpg_source - $owner = $::hiera::eyaml_owner - $group = $::hiera::eyaml_group - $cmdpath = $::hiera::cmdpath - $_keysdir = $::hiera::_keysdir + $owner = $hiera::eyaml_owner + $group = $hiera::eyaml_group + $cmdpath = $hiera::cmdpath + $_keysdir = $hiera::_keysdir - $manage_package = $::hiera::manage_eyaml_gpg_package + $manage_package = $hiera::manage_eyaml_gpg_package require hiera::eyaml diff --git a/manifests/init.pp b/manifests/init.pp index 4f84cb8..4198ba1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,30 +55,31 @@ # Copyright (C) 2016 Vox Pupuli, unless otherwise noted. # class hiera ( - Variant[Array, Array[Hash]] $hierarchy = $::hiera::params::hierarchy, - Optional[Enum['3','5']] $hiera_version = $::hiera::params::hiera_version, - Hiera::Hiera5_defaults $hiera5_defaults = $::hiera::params::hiera5_defaults, + Variant[Array, Array[Hash]] $hierarchy = $hiera::params::hierarchy, + Optional[Enum['3','5']] $hiera_version = $hiera::params::hiera_version, + Hiera::Hiera5_defaults $hiera5_defaults = $hiera::params::hiera5_defaults, $backends = ['yaml'], $backend_options = {}, - $hiera_yaml = $::hiera::params::hiera_yaml, + $hiera_yaml = $hiera::params::hiera_yaml, $create_symlink = true, - $datadir = $::hiera::params::datadir, + $datadir = $hiera::params::datadir, $datadir_manage = true, - $owner = $::hiera::params::owner, - $group = $::hiera::params::group, - $eyaml_owner = $::hiera::params::eyaml_owner, - $eyaml_group = $::hiera::params::eyaml_group, - $provider = $::hiera::params::provider, + $owner = $hiera::params::owner, + $group = $hiera::params::group, + $mode = $hiera::params::mode, + $eyaml_owner = $hiera::params::eyaml_owner, + $eyaml_group = $hiera::params::eyaml_group, + $provider = $hiera::params::provider, $eyaml = false, $eyaml_name = 'hiera-eyaml', $eyaml_version = undef, $eyaml_source = undef, $eyaml_datadir = undef, $eyaml_extension = undef, - $confdir = $::hiera::params::confdir, + $confdir = $hiera::params::confdir, $puppet_conf_manage = true, $logger = 'console', - $cmdpath = $::hiera::params::cmdpath, + $cmdpath = $hiera::params::cmdpath, $create_keys = true, $keysdir = undef, $deep_merge_name = 'deep_merge', @@ -87,13 +88,13 @@ $deep_merge_options = {}, $merge_behavior = undef, $extra_config = '', - $master_service = $::hiera::params::master_service, - $manage_package = $::hiera::params::manage_package, + $master_service = $hiera::params::master_service, + $manage_package = $hiera::params::manage_package, Boolean $manage_eyaml_package = true, Boolean $manage_deep_merge_package = true, Boolean $manage_eyaml_gpg_package = true, - $package_name = $::hiera::params::package_name, - $package_ensure = $::hiera::params::package_ensure, + $package_name = $hiera::params::package_name, + $package_ensure = $hiera::params::package_ensure, $eyaml_gpg_name = 'hiera-eyaml-gpg', $eyaml_gpg_version = undef, $eyaml_gpg_source = undef, @@ -144,7 +145,7 @@ File { owner => $owner, group => $group, - mode => '0644', + mode => $mode, } if ($datadir !~ /%\{.*\}/) and ($datadir_manage == true) { diff --git a/manifests/install.pp b/manifests/install.pp index 47ce6c7..56bd320 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -4,7 +4,7 @@ $provider, $gem_version = undef, $gem_source = undef, - $gem_install_options = $::hiera::gem_install_options, + $gem_install_options = $hiera::gem_install_options, ) { # $gem_install_options is typically used for specifying a proxy @@ -37,7 +37,7 @@ } $master_subscribe = Package[$gem_name] } - Service <| title == $::hiera::master_service |> { + Service <| title == $hiera::master_service |> { subscribe +> $master_subscribe, } } diff --git a/manifests/params.pp b/manifests/params.pp index d7ea973..623ec8f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -20,6 +20,7 @@ $package_ensure = 'present' $package_name = 'hiera' $hierarchy = [] + $mode = '0644' # Configure for AIO packaging. if $facts['pe_server_version'] { $master_service = 'pe-puppetserver' diff --git a/metadata.json b/metadata.json index b8893e7..599a5eb 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-hiera", - "version": "3.4.2-rc0", + "version": "4.0.1-rc0", "author": "Vox Pupuli", "summary": "Deploy hiera.yaml with hierarchy, and datadir", "license": "Apache-2.0", @@ -14,11 +14,11 @@ }, { "name": "puppetlabs/inifile", - "version_requirement": ">= 1.4.1 < 4.0.0" + "version_requirement": ">= 1.4.1 < 5.0.0" }, { "name": "puppetlabs/puppetserver_gem", - "version:requirement": ">= 1.0.0" + "version:requirement": ">= 1.0.0 < 2.0.0" } ], "operatingsystem_support": [ @@ -45,7 +45,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "14.04", "16.04" ] } diff --git a/spec/acceptance/hiera_spec.rb b/spec/acceptance/hiera_spec.rb index fa40c6f..d964f54 100644 --- a/spec/acceptance/hiera_spec.rb +++ b/spec/acceptance/hiera_spec.rb @@ -30,6 +30,7 @@ class { 'hiera': eyaml => true, merge_behavior => 'deep', puppet_conf_manage => true, + mode => '0640', hierarchy => [ 'virtual/%{::virtual}', 'nodes/%{::trusted.certname}', diff --git a/spec/classes/hiera_spec.rb b/spec/classes/hiera_spec.rb index 54b9d23..daff4da 100644 --- a/spec/classes/hiera_spec.rb +++ b/spec/classes/hiera_spec.rb @@ -261,12 +261,19 @@ let(:params) do { eyaml: true, + mode: '0640', merge_behavior: 'deeper' } end it { is_expected.to contain_class('hiera::eyaml') } it { is_expected.to contain_class('hiera::deep_merge') } + it 'has file mode 0640' do + is_expected.to contain_file('/dev/null/hiera.yaml').with( + 'ensure' => 'file', + 'mode' => '0640' + ) + end end describe 'check if version exists' do let(:params) do @@ -410,6 +417,29 @@ expect(content).to include(hierarchy_section) end end + describe 'hierarchy section with hash as an options value' do + let(:params) do + { + hiera_version: '5', + hiera5_defaults: { 'datadir' => 'data', 'data_hash' => 'yaml_data' }, + hierarchy: [{ + 'name' => 'some backend', + 'lookup_key' => 'some_lookup_key', + 'options' => { + 'hash_option' => { + 'some_key' => 'some_value' + } + } + }] + } + end + + it 'contains the option value as a hash' do + content = catalogue.resource('file', '/dev/null/hiera.yaml').send(:parameters)[:content] + options = YAML.load(content)['hierarchy'][0]['options'] + expect(options).to include('hash_option' => { 'some_key' => 'some_value' }) + end + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c53e703..f16fb15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,6 +7,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' +require 'bundler' include RspecPuppetFacts if File.exist?(File.join(__dir__, 'default_module_facts.yml')) @@ -31,6 +32,7 @@ add_filter '/spec' add_filter '/vendor' add_filter '/.vendor' + add_filter Bundler.configured_bundle_path.path end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 8b3f22a..81de7a3 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,5 +1,7 @@ require 'beaker-rspec' +require 'beaker-puppet' require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' def wait_for_master(max_retries) 1.upto(max_retries) do |retries| @@ -24,32 +26,23 @@ def make_site_pp(pp, path = File.join(master['puppetpath'], 'manifests')) end # rubocop:enable AbcSize -run_puppet_install_helper -unless ENV['RS_PROVISION'] == 'no' || ENV['BEAKER_provision'] == 'no' - if ENV['PUPPET_INSTALL_TYPE'] == 'agent' - pp = <<-EOS - package { 'puppetserver': ensure => present, } - service { 'puppetserver': ensure => running, } - EOS - apply_manifest_on(master, pp) - end -end +run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do - # Install module and dependencies - puppet_module_install(source: proj_root, module_name: 'hiera') + install_module + install_module_dependencies + install_module_from_forge('puppetlabs-puppetserver_gem', '>= 0') + hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1] - on host, puppet('module', 'install', 'puppetlabs-inifile'), acceptable_exit_codes: [0, 1] - on host, puppet('module', 'install', 'puppetlabs-puppetserver_gem'), acceptable_exit_codes: [0, 1] + if ENV['PUPPET_INSTALL_TYPE'] == 'agent' && ENV['BEAKER_provision'] != 'no' + host.install_package('puppetserver') + on host, puppet('resource', 'service', 'puppetserver', 'ensure=running') + end end end end diff --git a/templates/hiera.yaml.epp b/templates/hiera.yaml.epp index 6ae0a71..eca015c 100644 --- a/templates/hiera.yaml.epp +++ b/templates/hiera.yaml.epp @@ -75,6 +75,9 @@ hierarchy: - "<%= $value %>" <%- } -%> <%- } -%> + <%- elsif $value =~ Hash { -%> + <%= $key %>: <%= $value.to_json %> + <%- } -%> <%- else { -%> <%= $key %>: <%= $value %> <%- } -%>