diff --git a/.gitattributes b/.gitattributes index 2e05fd47..b313555d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -*.sh eol=lf +*.rb eol=lf diff --git a/.gitignore b/.gitignore index ef01482d..4ec62881 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage/ .idea/ *.iml *.swp +log/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a0443c..422c5b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ -======= -##2015-06-02 - Supported Release 2.0.1 +##Supported Release 1.2.5 +###Summary + +Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. + +##2015-07-21 - Supported Release 1.2.4 +###Summary + +This release includes some ruby path and lint fixes. + +####Bugfixes +- Use correct ruby path with PE and AIO +- Lint fixes +- Use correct ruby path on FreeBSD +- Test fixes + +##2015-06-02 - Supported Release 2.0.1 [YANKED] ###Summary This is a bugfix release. @@ -9,27 +24,24 @@ This is a bugfix release. - Fixes handling fragment target. - Fixes the defaulted force behavior to handle empty concats correctly. -======= -##2015-05-12 - Supported Release 2.0.0 +##2015-06-02 - Supported Release 1.2.3 ###Summary -This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments. - -####Features -- Re-implementation of concat to use native Type and Providers. +This release includes a README fix to document correct behavior of fragment target parameter. ####Bugfixes -- Fixes a bug in alpha ordering of fragments. +- README Fix to correctly document how a fragment $target param should work. -======= -##2015-06-02 - Supported Release 1.2.3 +##2015-05-12 - Supported Release 2.0.0 [YANKED] ###Summary -This release includes a README fix to document correct behavior of fragment target parameter. +This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments. -####Bugfixes +####Features +- Re-implementation of concat to use native Type and Providers. -- README Fix to correctly document how a fragment $target param should work. +####Bugfixes +- Fixes a bug in alpha ordering of fragments. ##2015-05-12 - Supported Release 1.2.2 ###Summary diff --git a/Gemfile b/Gemfile index 2b1b7cd8..bfe64b18 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ group :system_tests do gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false end diff --git a/README.md b/README.md index 8a041cee..3944be82 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,10 @@ All the parameters listed below are optional. Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'. +#####`backup_fragments` + +Specifies whether to backup concat fragments using the backup setting of the target concat file. Valid options: 'true' and 'false'. Default value: 'false'. + #####`ensure` Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'. @@ -172,6 +176,10 @@ Specifies a destination file for the combined fragments. Valid options: a string Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'. +#####`show_diff` + +Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure reporting methods. Valid options: 'true + #####`validate_cmd` Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined. @@ -187,9 +195,40 @@ If you set 'warn' to 'true', `concat` adds the following line with an `order` of ~~~ Before 2.0.0, this parameter would add a newline at the end of the warn -message. To improve flexibilty, this was removed. Please add it explicitely if +message. To improve flexibilty, this was removed. Please add it explicitly if you need it. +#####`selinux_ignore_defaults` + +See the `file` type's +[`selinux_ignore_defaults`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults) +documentention. + +#####`selrange` + +See the `file` type's +[`selrange`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange) +documentention. + +#####`selrole` + +See the `file` type's +[`selrole`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole) +documentention. + +#####`seltype` + +See the `file` type's +[`seltype`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype) +documentention. + +#####`seluser` + +See the `file` type's +[`seluser`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser) +documentention. + + ####Define: `concat::fragment` Except where noted, all the below parameters are optional. diff --git a/lib/puppet/type/concat_file.rb b/lib/puppet/type/concat_file.rb index 7bc47963..64964927 100644 --- a/lib/puppet/type/concat_file.rb +++ b/lib/puppet/type/concat_file.rb @@ -81,6 +81,26 @@ def exists? defaultto false end + # Inherit File parameters + newparam(:selinux_ignore_defaults) do + end + + newparam(:selrange) do + end + + newparam(:selrole) do + end + + newparam(:seltype) do + end + + newparam(:seluser) do + end + + newparam(:show_diff) do + end + # End file parameters + autorequire(:concat_fragment) do catalog.resources.collect do |r| if r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag] @@ -158,7 +178,18 @@ def generate :ensure => self[:ensure] == :absent ? :absent : :file, } - [:path, :owner, :group, :mode, :replace, :backup].each do |param| + [:path, + :owner, + :group, + :mode, + :replace, + :backup, + :selinux_ignore_defaults, + :selrange, + :selrole, + :seltype, + :seluser, + :show_diff].each do |param| unless self[param].nil? file_opts[param] = self[param] end diff --git a/manifests/init.pp b/manifests/init.pp index da02842b..8d7d95ac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,6 +16,9 @@ # Who will own the file # [*mode*] # The mode of the final file +# [*show_diff*] +# Use metaparam for files to show/hide diffs for reporting when using eyaml +# secrets. Defaults to true # [*warn*] # Adds a normal shell style comment top of the file indicating that it is # built by puppet. @@ -33,6 +36,10 @@ # [*ensure_newline*] # Specifies whether to ensure there's a new line at the end of each fragment. # Valid options: 'true' and 'false'. Default value: 'false'. +# [*selinux_ignore_defaults*] +# [*selrange*] +# [*selrole*] +# [*seltype*] # [*validate_cmd*] # Specifies a validation command to apply to the destination file. # Requires Puppet version 3.5 or newer. Valid options: a string to be passed @@ -40,27 +47,38 @@ # define concat( - $ensure = 'present', - $path = $name, - $owner = undef, - $group = undef, - $mode = '0644', - $warn = false, - $force = undef, - $backup = 'puppet', - $replace = true, - $order = 'alpha', - $ensure_newline = false, - $validate_cmd = undef, + $ensure = 'present', + $path = $name, + $owner = undef, + $group = undef, + $mode = '0644', + $warn = false, + $force = undef, + $show_diff = true, + $backup = 'puppet', + $replace = true, + $order = 'alpha', + $ensure_newline = false, + $validate_cmd = undef, + $selinux_ignore_defaults = undef, + $selrange = undef, + $selrole = undef, + $seltype = undef, + $seluser = undef ) { validate_re($ensure, '^present$|^absent$') validate_absolute_path($path) - validate_string($owner) - validate_string($group) validate_string($mode) + if ! (is_string($owner) or is_integer($owner)) { + fail("\$owner must be a string or integer, got ${owner}") + } + if ! (is_string($group) or is_integer($group)) { + fail("\$group must be a string or integer, got ${group}") + } if ! (is_string($warn) or $warn == true or $warn == false) { fail('$warn is not a string or boolean') } + validate_bool($show_diff) if ! is_bool($backup) and ! is_string($backup) { fail('$backup must be string or bool!') } @@ -75,6 +93,13 @@ if $force != undef { warning('The $force parameter to concat is deprecated and has no effect.') } + if $selinux_ignore_defaults { + validate_bool($selinux_ignore_defaults) + } + validate_string($selrange) + validate_string($selrole) + validate_string($seltype) + validate_string($seluser) $safe_name = regsubst($name, '[/:\n\s\(\)]', '_', 'G') $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n" @@ -96,16 +121,22 @@ if $ensure == 'present' { concat_file { $name: - tag => $safe_name, - path => $path, - owner => $owner, - group => $group, - mode => $mode, - replace => $replace, - backup => $backup, - order => $order, - ensure_newline => $ensure_newline, - validate_cmd => $validate_cmd, + tag => $safe_name, + path => $path, + owner => $owner, + group => $group, + mode => $mode, + selinux_ignore_defaults => $selinux_ignore_defaults, + selrange => $selrange, + selrole => $selrole, + seltype => $seltype, + seluser => $seluser, + replace => $replace, + backup => $backup, + show_diff => $show_diff, + order => $order, + ensure_newline => $ensure_newline, + validate_cmd => $validate_cmd, } if $_append_header { diff --git a/metadata.json b/metadata.json index 31d9144d..886d22df 100644 --- a/metadata.json +++ b/metadata.json @@ -7,6 +7,9 @@ "source": "https://github.com/puppetlabs/puppetlabs-concat", "project_page": "https://github.com/puppetlabs/puppetlabs-concat", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"} + ], "operatingsystem_support": [ { "operatingsystem": "RedHat", @@ -97,14 +100,11 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.7.0 < 4.0.0" + "version_requirement": ">= 3.7.0 < 2015.4.0" }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": ">= 3.0.0 < 5.0.0" } - ], - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"} ] } diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index f84a38fd..da417be3 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -5,28 +5,40 @@ username = 'root' groupname = 'system' scriptname = 'concatfragments.rb' - vardir = default['puppetvardir'] + vardir = default.puppet['vardir'] + if vardir.nil? or vardir == '' + vardir = '/opt/puppetlabs/puppet/cache' + end when 'Darwin' username = 'root' groupname = 'wheel' scriptname = 'concatfragments.rb' - vardir = default['puppetvardir'] + vardir = default.puppet['vardir'] + if vardir.nil? or vardir == '' + vardir = '/opt/puppetlabs/puppet/cache' + end when 'windows' username = 'Administrator' groupname = 'Administrators' scriptname = 'concatfragments.rb' - result = on default, "echo #{default['puppetvardir']}" + result = on default, "echo #{default.puppet['vardir']}" vardir = result.raw_output.chomp when 'Solaris' username = 'root' groupname = 'root' scriptname = 'concatfragments.rb' - vardir = default['puppetvardir'] + vardir = default.puppet['vardir'] + if vardir.nil? or vardir == '' + vardir = '/opt/puppetlabs/puppet/cache' + end else username = 'root' groupname = 'root' scriptname = 'concatfragments.rb' - vardir = default['puppetvardir'] + vardir = default.puppet['vardir'] + if vardir.nil? or vardir == '' + vardir = '/opt/puppetlabs/puppet/cache' + end end describe 'basic concat test' do diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml index 2ad90b86..6d110a64 100644 --- a/spec/acceptance/nodesets/centos-59-x64.yml +++ b/spec/acceptance/nodesets/centos-59-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: el-5-x86_64 box : centos-59-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-59-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/centos-64-x64-pe.yml b/spec/acceptance/nodesets/centos-64-x64-pe.yml index 7d9242f1..8e20d74e 100644 --- a/spec/acceptance/nodesets/centos-64-x64-pe.yml +++ b/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -6,7 +6,7 @@ HOSTS: - dashboard platform: el-6-x86_64 box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: pe diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml index 06398354..63a66373 100644 --- a/spec/acceptance/nodesets/centos-64-x64.yml +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: el-6-x86_64 box : centos-64-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml index 4e2cb809..e0677fae 100644 --- a/spec/acceptance/nodesets/centos-65-x64.yml +++ b/spec/acceptance/nodesets/centos-65-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: el-6-x86_64 box : centos-65-x64-vbox436-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-65-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: type: foss diff --git a/spec/acceptance/nodesets/debian-607-x64.yml b/spec/acceptance/nodesets/debian-607-x64.yml index 4c8be42d..cfbcb0d1 100644 --- a/spec/acceptance/nodesets/debian-607-x64.yml +++ b/spec/acceptance/nodesets/debian-607-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: debian-6-amd64 box : debian-607-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/debian-607-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml index 19181c12..ead9c629 100644 --- a/spec/acceptance/nodesets/debian-70rc1-x64.yml +++ b/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: debian-7-amd64 box : debian-70rc1-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/debian-70rc1-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml index 3e6a3a9d..55c874a2 100644 --- a/spec/acceptance/nodesets/debian-73-x64.yml +++ b/spec/acceptance/nodesets/debian-73-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: debian-7-amd64 box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/debian-73-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 4e2cb809..b31fe275 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,10 +1,10 @@ HOSTS: - centos-65-x64: + centos-66-x64: roles: - master platform: el-6-x86_64 - box : centos-65-x64-vbox436-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + box : puppetlabs/centos-6.6-64-nocm + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-6.6-64-nocm hypervisor : vagrant CONFIG: - type: foss + type: git diff --git a/spec/acceptance/nodesets/fedora-18-x64.yml b/spec/acceptance/nodesets/fedora-18-x64.yml index 624b5371..89d57a38 100644 --- a/spec/acceptance/nodesets/fedora-18-x64.yml +++ b/spec/acceptance/nodesets/fedora-18-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: fedora-18-x86_64 box : fedora-18-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/fedora-18-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/sles-11-x64.yml b/spec/acceptance/nodesets/sles-11-x64.yml index 41abe213..1681ae45 100644 --- a/spec/acceptance/nodesets/sles-11-x64.yml +++ b/spec/acceptance/nodesets/sles-11-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: sles-11-x64 box : sles-11sp1-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/sles-11sp1-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss diff --git a/spec/acceptance/nodesets/sles-11sp1-x64.yml b/spec/acceptance/nodesets/sles-11sp1-x64.yml index 554c37a5..604d6f93 100644 --- a/spec/acceptance/nodesets/sles-11sp1-x64.yml +++ b/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: sles-11-x86_64 box : sles-11sp1-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/sles-11sp1-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml index 5ca1514e..7f5e198b 100644 --- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: ubuntu-10.04-amd64 box : ubuntu-server-10044-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml index d065b304..05bdde77 100644 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -4,7 +4,7 @@ HOSTS: - master platform: ubuntu-12.04-amd64 box : ubuntu-server-12042-x64-vbox4210-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + box_url : https://atlas.hashicorp.com/puppetlabs/boxes/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index 042425f9..6f9f9fd5 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -1,42 +1,42 @@ -require 'spec_helper_acceptance' - -describe 'quoted paths' do - basedir = default.tmpdir('concat') - - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/concat test': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - context 'path with blanks' do - pp = <<-EOS - concat { '#{basedir}/concat test/foo': - } - concat::fragment { '1': - target => '#{basedir}/concat test/foo', - content => 'string1', - } - concat::fragment { '2': - target => '#{basedir}/concat test/foo', - content => 'string2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/concat test/foo") do - it { should be_file } - its(:content) { should match /string1string2/ } - end - end -end +require 'spec_helper_acceptance' + +describe 'quoted paths' do + basedir = default.tmpdir('concat') + + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/concat test': + ensure => directory, + } + EOS + apply_manifest(pp) + end + + context 'path with blanks' do + pp = <<-EOS + concat { '#{basedir}/concat test/foo': + } + concat::fragment { '1': + target => '#{basedir}/concat test/foo', + content => 'string1', + } + concat::fragment { '2': + target => '#{basedir}/concat test/foo', + content => 'string2', + } + EOS + + it 'applies the manifest twice with no stderr' do + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{basedir}/concat test/foo") do + it { should be_file } + its(:content) { should match /string1string2/ } + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 1293aeb9..c6a670ae 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,23 +1,12 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' require 'acceptance/specinfra_stubs' +require 'beaker/puppet_install_helper' -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - # This will install the latest available package on el and deb based - # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { - :default_action => 'gem_install', - :version => (ENV['PUPPET_VERSION'] || '3.8.1'), - } - - if default.is_pe?; then - install_pe; - else - install_puppet(foss_opts); - end +run_puppet_install_helper +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' hosts.each do |host| - on hosts, "mkdir -p #{host['distmoduledir']}" if host['platform'] =~ /sles-1/i || host['platform'] =~ /solaris-1/i get_deps = <<-EOS package{'wget':} diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 317b02cd..a2d4c6c8 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -96,6 +96,51 @@ end end # source => + context 'order =>' do + ['', '42', 'a', 'z'].each do |order| + context '\'\'' do + it_behaves_like 'fragment', 'motd_header', { + :order => order, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:params) {{ :order => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /is not a string or integer/) + end + end + + context '123:456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => '123:456', :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + context '123/456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => '123/456', :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + context '123\n456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => "123\n456", :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + end # order => + context 'more than one content source' do context 'source and content' do let(:title) { 'motd_header' } @@ -108,7 +153,7 @@ end it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Can't use 'source' and 'content' at the same time/) + expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m) end end end # more than one content source diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index b2254f4e..28709803 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -41,13 +41,18 @@ if p[:ensure] == 'present' it do should contain_concat(title).with(file_defaults.merge({ - :ensure => 'present', - :owner => p[:owner], - :group => p[:group], - :mode => p[:mode], - :path => p[:path], - :backup => p[:backup], - :replace => p[:replace], + :ensure => 'present', + :owner => p[:owner], + :group => p[:group], + :mode => p[:mode], + :path => p[:path], + :backup => p[:backup], + :replace => p[:replace], + :selinux_ignore_defaults => p[:selinux_ignore_defaults], + :selrange => p[:selrange], + :selrole => p[:selrole], + :seltype => p[:seltype], + :seluser => p[:seluser], })) end else @@ -130,11 +135,15 @@ it_behaves_like 'concat', '/etc/foo.bar', { :owner => 'apenny' } end + context '1000' do + it_behaves_like 'concat', '/etc/foo.bar', { :owner => 1000 } + end + context 'false' do let(:title) { '/etc/foo.bar' } let(:params) {{ :owner => false }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /\$owner must be a string or integer/) end end end # owner => @@ -144,11 +153,15 @@ it_behaves_like 'concat', '/etc/foo.bar', { :group => 'apenny' } end + context '1000' do + it_behaves_like 'concat', '/etc/foo.bar', { :group => 1000 } + end + context 'false' do let(:title) { '/etc/foo.bar' } let(:params) {{ :group => false }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /\$group must be a string or integer/) end end end # group => @@ -195,6 +208,22 @@ end end # warn => + context 'show_diff =>' do + [true, false].each do |show_diff| + context show_diff do + it_behaves_like 'concat', '/etc/foo.bar', { :show_diff => show_diff } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :show_diff => 123 }} + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # show_diff => + context 'backup =>' do context 'reverse' do it_behaves_like 'concat', '/etc/foo.bar', { :backup => 'reverse' } @@ -266,18 +295,61 @@ end # ensure_newline => context 'validate_cmd =>' do - context '/usr/bin/test -e %' do - it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } + if Puppet::Util::Package::versioncmp(Puppet::version, '3.5.0') > 0 + context '/usr/bin/test -e %' do + it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } + end + + [ 1234, true ].each do |cmd| + context cmd do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :validate_cmd => cmd }} + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) + end + end + end + end + end # validate_cmd => + + context 'selinux_ignore_defaults =>' do + let(:title) { '/etc/foo.bar' } + + [true, false].each do |v| + context v do + it_behaves_like 'concat', '/etc/foo.bar', { :selinux_ignore_defaults => v } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :selinux_ignore_defaults => 123 }} + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/) + end end + end # selinux_ignore_defaults => + + [ + :selrange, + :selrole, + :seltype, + :seluser, + ].each do |p| + context " #{p} =>" do + let(:title) { '/etc/foo.bar' } - [ 1234, true ].each do |cmd| - context cmd do + context 'foo' do + it_behaves_like 'concat', '/etc/foo.bar', { p => 'foo' } + end + + context 'false' do let(:title) { '/etc/foo.bar' } - let(:params) {{ :validate_cmd => cmd }} + let(:params) {{ p => false }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) + expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) end end - end - end # validate_cmd => + end # #{p} => + end end diff --git a/tests/fragment.pp b/tests/fragment.pp index a2dfaca2..16bf3b6e 100644 --- a/tests/fragment.pp +++ b/tests/fragment.pp @@ -1,9 +1,10 @@ concat { 'testconcat': - ensure => present, - path => '/tmp/concat', - owner => 'root', - group => 'root', - mode => '0664', + ensure => present, + path => '/tmp/concat', + owner => 'root', + group => 'root', + mode => '0664', + show_diff => true, } concat::fragment { '1':