From 85da0f7e2a878e11a9071588d52f60bc406512c3 Mon Sep 17 00:00:00 2001 From: floatingatoll Date: Tue, 22 Jan 2013 12:27:16 -0800 Subject: [PATCH 001/202] Style guideline fix for README example's mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit puppet-lint reports that 644 should be '0644', per http://puppet-lint.com/checks/file_mode/ --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 8ee04d7..3df097a 100644 --- a/README.markdown +++ b/README.markdown @@ -34,7 +34,7 @@ class motd { concat{$motd: owner => root, group => root, - mode => 644 + mode => '0644', } concat::fragment{"motd_header": From 4ec1d5df0d326d703e33252386653d9e6806db51 Mon Sep 17 00:00:00 2001 From: Raphael Lorenzeto Date: Sun, 24 Feb 2013 08:28:19 -0300 Subject: [PATCH 002/202] Adding more helpful message for 'pluginsync = true'. --- README.markdown | 3 ++- manifests/setup.pp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 3df097a..567fb9c 100644 --- a/README.markdown +++ b/README.markdown @@ -80,7 +80,8 @@ manifest files. Known Issues: ------------- * Since puppet-concat now relies on a fact for the concat directory, - you will need to set up pluginsync = true for at least the first run. + you will need to set up pluginsync = true on the [master] section of your + node's '/etc/puppet/puppet.conf' for at least the first run. You have this issue if puppet fails to run on the client and you have a message similar to "err: Failed to apply catalog: Parameter path failed: File diff --git a/manifests/setup.pp b/manifests/setup.pp index fc6cb93..5e90bfa 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -22,7 +22,7 @@ class concat::setup { if $::concat_basedir { $concatdir = $::concat_basedir } else { - fail ("\$concat_basedir not defined. Try running again with pluginsync enabled") + fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] section of your node's '/etc/puppet/puppet.conf'.") } $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1') From 4396d601d61effe987594a4a272882ea201f35ed Mon Sep 17 00:00:00 2001 From: Wijnand Modderman-Lenstra Date: Thu, 28 Feb 2013 13:00:11 +0100 Subject: [PATCH 003/202] Move away from defining resource defaults, we can just pass $source and $content directly to the file resource Using the case statement does not properly notify the file resource about changes, leading to unexpected results when generating fragments from Puppet templates. This patch fixes that issue. --- manifests/fragment.pp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index cf55f8b..3b4f58d 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -13,7 +13,7 @@ # - group Owner of the file # - backup Controls the filebucketing behavior of the final file and # see File type reference for its use. Defaults to 'puppet' -define concat::fragment($target, $content='', $source='', $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') { +define concat::fragment($target, $content=undef, $source=undef, $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') { $safe_name = regsubst($name, '[/\n]', '_', 'GM') $safe_target_name = regsubst($target, '[/\n]', '_', 'GM') $concatdir = $concat::setup::concatdir @@ -21,32 +21,26 @@ define concat::fragment($target, $content='', $source='', $order=10, $ensure = ' # if content is passed, use that, else if source is passed use that # if neither passed, but $ensure is in symlink form, make a symlink - case $content { - '': { - case $source { - '': { - case $ensure { - '', 'absent', 'present', 'file', 'directory': { - crit('No content, source or symlink specified') - } - default: { - #do nothing, make puppet-lint happy. - } - } - } - default: { File{ source => $source } } + case $ensure { + '', 'absent', 'present', 'file', 'directory': { + if ! ($content or $source) { + crit('No content, source or symlink specified') } + }, + default: { + # do nothing, make puppet-lint happy } - default: { File{ content => $content } } } file{"${fragdir}/fragments/${order}_${safe_name}": - ensure => $ensure, - mode => $mode, - owner => $owner, - group => $group, - backup => $backup, - alias => "concat_fragment_${name}", - notify => Exec["concat_${target}"] + ensure => $ensure, + mode => $mode, + owner => $owner, + group => $group, + source => $source, + content => $content, + backup => $backup, + alias => "concat_fragment_${name}", + notify => Exec["concat_${target}"] } } From 8e83e57a29bf3626de1238ae6165b988ae6da174 Mon Sep 17 00:00:00 2001 From: Maxence Dunnewind Date: Wed, 13 Mar 2013 14:25:47 +0100 Subject: [PATCH 004/202] remove unneeded ',' --- manifests/fragment.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 3b4f58d..f289712 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -26,7 +26,7 @@ define concat::fragment($target, $content=undef, $source=undef, $order=10, $ensu if ! ($content or $source) { crit('No content, source or symlink specified') } - }, + } default: { # do nothing, make puppet-lint happy } From 03650cc0ca082825737ef11e3db4582e64eac857 Mon Sep 17 00:00:00 2001 From: Andy Bohne Date: Mon, 8 Apr 2013 10:42:53 -0400 Subject: [PATCH 005/202] Added -r flag to read so that filenames with \ will be read correctly --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index c939797..9b0be41 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -112,7 +112,7 @@ else fi # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir -find fragments/ -type f -follow | sort ${SORTARG} | while read fragfile; do +find fragments/ -type f -follow | sort ${SORTARG} | while read -r fragfile; do cat "$fragfile" >> "fragments.concat" done From f1579e50ca57d9aff61b04a135b10b65ed3dddda Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sun, 28 Apr 2013 13:57:28 +0200 Subject: [PATCH 006/202] Allow WARNMSG to contain/start with '#' Previosuly this error was being displayed: 108: [: x#: unexpected operator --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 9b0be41..8aad3ab 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -105,7 +105,7 @@ fi cd ${WORKDIR} -if [ x${WARNMSG} = "x" ]; then +if [ "x${WARNMSG}" = "x" ]; then : > "fragments.concat" else printf '%s\n' "$WARNMSG" > "fragments.concat" From 688655eb7be14dc8de906a78bb5a8097b6295e4a Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 9 May 2013 21:24:22 +0200 Subject: [PATCH 007/202] RDoc cleanup --- README | 94 ++++++++++++++++++++ lib/facter/concat_basedir.rb | 6 ++ manifests/fragment.pp | 49 ++++++++--- manifests/init.pp | 162 +++++++++-------------------------- manifests/setup.pp | 17 ++-- 5 files changed, 188 insertions(+), 140 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..81bdedb --- /dev/null +++ b/README @@ -0,0 +1,94 @@ +== Module: concat + +A system to construct files using fragments from other files or templates. + +This requires at least puppet 0.25 to work correctly as we use some +enhancements in recursive directory management and regular expressions +to do the work here. + +=== Usage: + +The basic use case is as below: + + concat{"/etc/named.conf": + notify => Service["named"] + } + + concat::fragment{"foo.com_config": + target => "/etc/named.conf", + order => 10, + content => template("named_conf_zone.erb") + } + + # add a fragment not managed by puppet so local users + # can add content to managed file + concat::fragment{"foo.com_user_config": + target => "/etc/named.conf", + order => 12, + ensure => "/etc/named.conf.local" + } + +This will use the template named_conf_zone.erb to build a single +bit of config up and put it into the fragments dir. The file +will have an number prefix of 10, you can use the order option +to control that and thus control the order the final file gets built in. + +You can also specify a path and use a different name for your resources: + + # You can make this something dynamic, based on whatever parameters your + # module/class for example. + $vhost_file = '/etc/httpd/vhosts/01-my-vhost.conf' + + concat{'apache-vhost-myvhost': + path => $vhost_file, + } + + # We don't care where the file is located, just what to put in it. + concat::fragment {'apache-vhost-myvhost-main': + target => 'apache-vhost-myvhost', + content => '', + order => 01, + } + + concat::fragment {'apache-vhost-myvhost-close': + target => 'apache-vhost-myvhost', + content => '', + order => 99, + } + +=== Setup: + +The class concat::setup uses the fact concat_basedir to define the variable +$concatdir, where all the temporary files and fragments will be +durably stored. The fact concat_basedir will be set up on the client to +/concat, so you will be able to run different setup/flavours +of puppet clients. +However, since this requires the file lib/facter/concat_basedir.rb to be +deployed on the clients, so you will have to set "pluginsync = true" on +both the master and client, at least for the first run. + +There's some regular expression magic to figure out the puppet version but +if you're on an older 0.24 version just set $puppetversion = 24 + +=== Detail: + +We use a helper shell script called concatfragments.sh that gets placed +in /concat/bin to do the concatenation. While this might +seem more complex than some of the one-liner alternatives you might find on +the net we do a lot of error checking and safety checks in the script to avoid +problems that might be caused by complex escaping errors etc. + +=== License: + +Apache Version 2 + +=== Latest: + +http://github.com/ripienaar/puppet-concat/ + +=== Contact: + +* R.I.Pienaar +* Volcane on freenode +* @ripienaar on twitter +* www.devco.net diff --git a/lib/facter/concat_basedir.rb b/lib/facter/concat_basedir.rb index 02e9c5b..ef5a689 100644 --- a/lib/facter/concat_basedir.rb +++ b/lib/facter/concat_basedir.rb @@ -1,3 +1,9 @@ +# == Fact: concat_basedir +# +# A custom fact that sets the default location for fragments +# +# "${::vardir}/concat/" +# Facter.add("concat_basedir") do setcode do File.join(Puppet[:vardir],"concat") diff --git a/manifests/fragment.pp b/manifests/fragment.pp index f289712..a6831f8 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -1,19 +1,40 @@ +# == Define: concat::fragment +# # Puts a file fragment into a directory previous setup using concat # -# OPTIONS: -# - target The file that these fragments belong to -# - content If present puts the content into the file -# - source If content was not specified, use the source -# - order By default all files gets a 10_ prefix in the directory -# you can set it to anything else using this to influence the -# order of the content in the file -# - ensure Present/Absent or destination to a file to include another file -# - mode Mode for the file -# - owner Owner of the file -# - group Owner of the file -# - backup Controls the filebucketing behavior of the final file and -# see File type reference for its use. Defaults to 'puppet' -define concat::fragment($target, $content=undef, $source=undef, $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') { +# === Options: +# +# [*target*] +# The file that these fragments belong to +# [*content*] +# If present puts the content into the file +# [*source*] +# If content was not specified, use the source +# [*order*] +# By default all files gets a 10_ prefix in the directory you can set it to +# anything else using this to influence the order of the content in the file +# [*ensure*] +# Present/Absent or destination to a file to include another file +# [*mode*] +# Mode for the file +# [*owner*] +# Owner of the file +# [*group*] +# Owner of the file +# [*backup*] +# Controls the filebucketing behavior of the final file and see File type +# reference for its use. Defaults to 'puppet' +# +define concat::fragment( + $target, + $content=undef, + $source=undef, + $order=10, + $ensure = 'present', + $mode = '0644', + $owner = $::id, + $group = $concat::setup::root_group, + $backup = 'puppet') { $safe_name = regsubst($name, '[/\n]', '_', 'GM') $safe_target_name = regsubst($target, '[/\n]', '_', 'GM') $concatdir = $concat::setup::concatdir diff --git a/manifests/init.pp b/manifests/init.pp index b309059..cba8223 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,128 +1,50 @@ -# A system to construct files using fragments from other files or templates. +# == Define: concat # -# This requires at least puppet 0.25 to work correctly as we use some -# enhancements in recursive directory management and regular expressions -# to do the work here. -# -# USAGE: -# The basic use case is as below: -# -# concat{"/etc/named.conf": -# notify => Service["named"] -# } -# -# concat::fragment{"foo.com_config": -# target => "/etc/named.conf", -# order => 10, -# content => template("named_conf_zone.erb") -# } -# -# # add a fragment not managed by puppet so local users -# # can add content to managed file -# concat::fragment{"foo.com_user_config": -# target => "/etc/named.conf", -# order => 12, -# ensure => "/etc/named.conf.local" -# } -# -# This will use the template named_conf_zone.erb to build a single -# bit of config up and put it into the fragments dir. The file -# will have an number prefix of 10, you can use the order option -# to control that and thus control the order the final file gets built in. -# -# You can also specify a path and use a different name for your resources: -# -# # You can make this something dynamic, based on whatever parameters your -# # module/class for example. -# $vhost_file = '/etc/httpd/vhosts/01-my-vhost.conf' -# -# concat{'apache-vhost-myvhost': -# path => $vhost_file, -# } -# -# # We don't care where the file is located, just what to put in it. -# concat::fragment {'apache-vhost-myvhost-main': -# target => 'apache-vhost-myvhost', -# content => '', -# order => 01, -# } -# -# concat::fragment {'apache-vhost-myvhost-close': -# target => 'apache-vhost-myvhost', -# content => '', -# order => 99, -# } -# -# -# SETUP: -# The class concat::setup uses the fact concat_basedir to define the variable -# $concatdir, where all the temporary files and fragments will be -# durably stored. The fact concat_basedir will be set up on the client to -# /concat, so you will be able to run different setup/flavours -# of puppet clients. -# However, since this requires the file lib/facter/concat_basedir.rb to be -# deployed on the clients, so you will have to set "pluginsync = true" on -# both the master and client, at least for the first run. -# -# There's some regular expression magic to figure out the puppet version but -# if you're on an older 0.24 version just set $puppetversion = 24 -# -# DETAIL: -# We use a helper shell script called concatfragments.sh that gets placed -# in /concat/bin to do the concatenation. While this might -# seem more complex than some of the one-liner alternatives you might find on -# the net we do a lot of error checking and safety checks in the script to avoid -# problems that might be caused by complex escaping errors etc. -# -# LICENSE: -# Apache Version 2 -# -# LATEST: -# http://github.com/ripienaar/puppet-concat/ -# -# CONTACT: -# R.I.Pienaar -# Volcane on freenode -# @ripienaar on twitter -# www.devco.net - - # Sets up so that you can use fragments to build a final config file, # -# OPTIONS: -# - path The path to the final file. Use this in case you want to -# differentiate between the name of a resource and the file path. -# Note: Use the name you provided in the target of your -# fragments. -# - mode The mode of the final file -# - owner Who will own the file -# - group Who will own the file -# - force Enables creating empty files if no fragments are present -# - warn Adds a normal shell style comment top of the file indicating -# that it is built by puppet -# - backup Controls the filebucketing behavior of the final file and -# see File type reference for its use. Defaults to 'puppet' -# - replace Whether to replace a file that already exists on the local -# system +# === Options: # -# ACTIONS: -# - Creates fragment directories if it didn't exist already -# - Executes the concatfragments.sh script to build the final file, this -# script will create directory/fragments.concat. Execution happens only -# when: -# * The directory changes -# * fragments.concat != final destination, this means rebuilds will happen -# whenever someone changes or deletes the final file. Checking is done -# using /usr/bin/cmp. -# * The Exec gets notified by something else - like the concat::fragment -# define -# - Copies the file over to the final destination using a file resource +# [*path*] +# The path to the final file. Use this in case you want to differentiate +# between the name of a resource and the file path. Note: Use the name you +# provided in the target of your fragments. +# [*mode*] +# The mode of the final file +# [*owner*] +# Who will own the file +# [*group*] +# Who will own the file +# [*force*] +# Enables creating empty files if no fragments are present +# [*warn*] +# Adds a normal shell style comment top of the file indicating that it is +# built by puppet +# [*backup*] +# Controls the filebucketing behavior of the final file and see File type +# reference for its use. Defaults to 'puppet' +# [*replace*] +# Whether to replace a file that already exists on the local system +# +# === Actions: +# * Creates fragment directories if it didn't exist already +# * Executes the concatfragments.sh script to build the final file, this +# script will create directory/fragments.concat. Execution happens only +# when: +# * The directory changes +# * fragments.concat != final destination, this means rebuilds will happen +# whenever someone changes or deletes the final file. Checking is done +# using /usr/bin/cmp. +# * The Exec gets notified by something else - like the concat::fragment +# define +# * Copies the file over to the final destination using a file resource +# +# === Aliases: +# +# * The exec can notified using Exec["concat_/path/to/file"] or +# Exec["concat_/path/to/directory"] +# * The final file can be referened as File["/path/to/file"] or +# File["concat_/path/to/file"] # -# ALIASES: -# - The exec can notified using Exec["concat_/path/to/file"] or -# Exec["concat_/path/to/directory"] -# - The final file can be referened as File["/path/to/file"] or -# File["concat_/path/to/file"] define concat( $path = $name, $owner = $::id, diff --git a/manifests/setup.pp b/manifests/setup.pp index 5e90bfa..2d29bf8 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -1,17 +1,22 @@ +# === Class: concat::setup +# # Sets up the concat system. # -# $concatdir is where the fragments live and is set on the fact concat_basedir. -# Since puppet should always manage files in $concatdir and they should -# not be deleted ever, /tmp is not an option. +# [$concatdir] +# is where the fragments live and is set on the fact concat_basedir. +# Since puppet should always manage files in $concatdir and they should +# not be deleted ever, /tmp is not an option. # -# $puppetversion should be either 24 or 25 to enable a 24 compatible -# mode, in 24 mode you might see phantom notifies this is a side effect -# of the method we use to clear the fragments directory. +# [$puppetversion] +# should be either 24 or 25 to enable a 24 compatible +# mode, in 24 mode you might see phantom notifies this is a side effect +# of the method we use to clear the fragments directory. # # The regular expression below will try to figure out your puppet version # but this code will only work in 0.24.8 and newer. # # It also copies out the concatfragments.sh file to ${concatdir}/bin +# class concat::setup { $id = $::id $root_group = $id ? { From 78e547025bcc7ee943b93dccb43c515cb9c5a213 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 22 May 2013 00:03:56 +0200 Subject: [PATCH 008/202] sort always with LANG=C somehowe puppet leaks then LANG into execs, which can give different ordering depending with which LANG puppet is executed. Which is likely different between a logged in admin and cron --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 9b0be41..2128ed8 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -112,7 +112,7 @@ else fi # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir -find fragments/ -type f -follow | sort ${SORTARG} | while read -r fragfile; do +find fragments/ -type f -follow | LANG=C sort ${SORTARG} | while read -r fragfile; do cat "$fragfile" >> "fragments.concat" done From 1d403b6763ddc42de3bd4a9dcb4fbf98d2e78dee Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 8 Aug 2013 08:44:31 -0700 Subject: [PATCH 009/202] Add rspec-system tests. --- .nodeset.yml | 35 +++++++++++++++++++++++ .travis.yml | 36 ++++++++++++++++++------ Gemfile | 21 ++++++++++++++ Rakefile | 2 +- spec/spec_helper_system.rb | 25 +++++++++++++++++ spec/system/basic_spec.rb | 13 +++++++++ spec/system/concat_spec.rb | 55 +++++++++++++++++++++++++++++++++++++ spec/system/empty_spec.rb | 27 ++++++++++++++++++ spec/system/replace_spec.rb | 37 +++++++++++++++++++++++++ spec/system/warn_spec.rb | 41 +++++++++++++++++++++++++++ 10 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 .nodeset.yml create mode 100644 Gemfile create mode 100644 spec/spec_helper_system.rb create mode 100644 spec/system/basic_spec.rb create mode 100644 spec/system/concat_spec.rb create mode 100644 spec/system/empty_spec.rb create mode 100644 spec/system/replace_spec.rb create mode 100644 spec/system/warn_spec.rb diff --git a/.nodeset.yml b/.nodeset.yml new file mode 100644 index 0000000..cbd0d57 --- /dev/null +++ b/.nodeset.yml @@ -0,0 +1,35 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' + 'sles-11sp1-x64': + nodes: + "main.foo.vm": + prefab: 'sles-11sp1-x64' diff --git a/.travis.yml b/.travis.yml index 9d1c0cc..ad51c64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,32 @@ -language: ruby -rvm: - - 1.8.7 -script: - - "rake lint" - - "rake spec" +--- branches: only: - master +language: ruby +bundler_args: --without development +script: bundle exec rake spec SPEC_OPTS='--format documentation' +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng + - .forge-releng/publish +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 env: - - PUPPET_VERSION=2.7.11 -gemfile: .gemfile + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.2.0" + global: +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" +notifications: + email: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..783e522 --- /dev/null +++ b/Gemfile @@ -0,0 +1,21 @@ +source 'https://rubygems.org' + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-system-puppet', :require => false + gem 'puppet-lint', :require => false + gem 'serverspec', :require => false + gem 'rspec-system-serverspec', :require => false + gem 'pry', :require => false + gem 'vagrant-wrapper', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Rakefile b/Rakefile index 14f1c24..bb60173 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,2 @@ -require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' +require 'rspec-system/rake_task' diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb new file mode 100644 index 0000000..bf66a53 --- /dev/null +++ b/spec/spec_helper_system.rb @@ -0,0 +1,25 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' +require 'rspec-system-serverspec/helpers' +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS +include RSpecSystemPuppet::Helpers + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # Install puppet + puppet_install + + # Install modules and dependencies + puppet_module_install(:source => proj_root, :module_name => 'concat') + end +end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb new file mode 100644 index 0000000..39ac746 --- /dev/null +++ b/spec/system/basic_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper_system' + +# Here we put the more basic fundamental tests, ultra obvious stuff. +describe "basic tests:" do + context 'make sure we have copied the module across' do + # No point diagnosing any more if the module wasn't copied properly + context shell 'ls /etc/puppet/modules/concat' do + its(:stdout) { should =~ /Modulefile/ } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + end +end diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb new file mode 100644 index 0000000..af360d6 --- /dev/null +++ b/spec/system/concat_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end + + # Test that all the relevant bits exist on disk after it + # concats. + describe file('/var/lib/puppet/concat') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do + it { should be_file } + end + + end +end diff --git a/spec/system/empty_spec.rb b/spec/system/empty_spec.rb new file mode 100644 index 0000000..83dae01 --- /dev/null +++ b/spec/system/empty_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + force => true, + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should_not contain '1\n2' } + end + end +end diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb new file mode 100644 index 0000000..7f11e5f --- /dev/null +++ b/spec/system/replace_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper_system' + + +describe 'file should not replace' do + shell('echo "file exists" >> /tmp/file') + context 'should fail' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + replace => false, + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + end +end diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb new file mode 100644 index 0000000..872058b --- /dev/null +++ b/spec/system/warn_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + warn => true, + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end +end From 3d60c9ef6162425c0bf9eb2004d9da375965efc9 Mon Sep 17 00:00:00 2001 From: Spencer Krum Date: Sat, 13 Jul 2013 13:41:14 -0700 Subject: [PATCH 010/202] Refactor loop to use for-do instead of while-read. This for loop around find removes the need for the read statement. The read statement isn't portable to solaris, because Read has no -r option in /bin/sh on solaris. This should resolve Issue #45. --- files/concatfragments.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 2128ed8..8fb8973 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -112,9 +112,14 @@ else fi # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir -find fragments/ -type f -follow | LANG=C sort ${SORTARG} | while read -r fragfile; do - cat "$fragfile" >> "fragments.concat" +IFS_BACKUP=$IFS +IFS=' +' +for fragfile in `find fragments/ -type f -follow | LANG=C sort ${SORTARG}` +do + cat $fragfile >> concat.fragment done +IFS=$IFS_BACKUP if [ x${TEST} = "x" ]; then # This is a real run, copy the file to outfile From 3defb6e1c122bd7e058583ef475ff212d5f1d907 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 6 Aug 2013 19:26:50 -0400 Subject: [PATCH 011/202] Ability to control if fragments should always have a newline at the end. --- files/concatfragments.sh | 6 ++++++ manifests/init.pp | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 12b815e..05b6527 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -44,6 +44,7 @@ TEST="" FORCE="" WARN="" SORTARG="" +ENSURE_NEW_LINE="" PATH=/sbin:/usr/sbin:/bin:/usr/bin @@ -59,6 +60,7 @@ while getopts "o:s:d:tnw:f" options; do w ) WARNMSG="$OPTARG";; f ) FORCE="true";; t ) TEST="true";; + l ) ENSURE_NEW_LINE="true";; * ) echo "Specify output file with -o and fragments directory with -d" exit 1;; esac @@ -111,6 +113,10 @@ else printf '%s\n' "$WARNMSG" > "fragments.concat" fi +if [ x${ENSURE_NEW_LINE} != x ]; then + find fragments/ -type f -follow -print0 | xargs -0 -I '{}' sh -c 'if [ -n "$(tail -c 1 < {} )" ]; then echo >> {} ; fi' +fi + # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir IFS_BACKUP=$IFS IFS=' diff --git a/manifests/init.pp b/manifests/init.pp index cba8223..2ecafcd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,7 +55,8 @@ define concat( $backup = 'puppet', $replace = true, $gnu = undef, - $order='alpha' + $order='alpha', + $ensure_new_line = false ) { include concat::setup @@ -108,6 +109,18 @@ define concat( } } + case $ensure_new_line { + 'true', true, yes, on: { + $newlineflag = '-l' + } + 'false', false, no, off: { + $newlineflag = '' + } + default: { + fail("Improper 'ensure_new_line' value given to concat: ${ensure_new_line}") + } + } + File { owner => $::id, group => $group, @@ -155,7 +168,7 @@ define concat( exec { "concat_${name}": alias => "concat_${fragdir}", - command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}", + command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", notify => File[$name], require => [ File[$fragdir], @@ -163,7 +176,7 @@ define concat( File["${fragdir}/fragments.concat"], ], subscribe => File[$fragdir], - unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}", + unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", } if $::id == 'root' { From 5b483999cc36663ec620c8dd4ff63972a008eee0 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 6 Aug 2013 20:26:43 -0400 Subject: [PATCH 012/202] Add -l to getopts --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 05b6527..cd7b758 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -52,7 +52,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin ## http://nexenta.org/projects/site/wiki/Personalities unset SUN_PERSONALITY -while getopts "o:s:d:tnw:f" options; do +while getopts "o:s:d:tnw:fl" options; do case $options in o ) OUTFILE=$OPTARG;; d ) WORKDIR=$OPTARG;; From 871e0b7de19f807a3f5d4b0f5669da564ea6999d Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Wed, 7 Aug 2013 10:48:57 -0400 Subject: [PATCH 013/202] new_line -> newline --- files/concatfragments.sh | 6 +++--- manifests/init.pp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index cd7b758..13b468e 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -44,7 +44,7 @@ TEST="" FORCE="" WARN="" SORTARG="" -ENSURE_NEW_LINE="" +ENSURE_NEWLINE="" PATH=/sbin:/usr/sbin:/bin:/usr/bin @@ -60,7 +60,7 @@ while getopts "o:s:d:tnw:fl" options; do w ) WARNMSG="$OPTARG";; f ) FORCE="true";; t ) TEST="true";; - l ) ENSURE_NEW_LINE="true";; + l ) ENSURE_NEWLINE="true";; * ) echo "Specify output file with -o and fragments directory with -d" exit 1;; esac @@ -113,7 +113,7 @@ else printf '%s\n' "$WARNMSG" > "fragments.concat" fi -if [ x${ENSURE_NEW_LINE} != x ]; then +if [ x${ENSURE_NEWLINE} != x ]; then find fragments/ -type f -follow -print0 | xargs -0 -I '{}' sh -c 'if [ -n "$(tail -c 1 < {} )" ]; then echo >> {} ; fi' fi diff --git a/manifests/init.pp b/manifests/init.pp index 2ecafcd..ed4068b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -56,7 +56,7 @@ define concat( $replace = true, $gnu = undef, $order='alpha', - $ensure_new_line = false + $ensure_newline = false ) { include concat::setup @@ -109,7 +109,7 @@ define concat( } } - case $ensure_new_line { + case $ensure_newline { 'true', true, yes, on: { $newlineflag = '-l' } @@ -117,7 +117,7 @@ define concat( $newlineflag = '' } default: { - fail("Improper 'ensure_new_line' value given to concat: ${ensure_new_line}") + fail("Improper 'ensure_newline' value given to concat: ${ensure_newline}") } } From 3728ba33d4a245ba00d77764ab182aa7943cfa34 Mon Sep 17 00:00:00 2001 From: plantigrade Date: Fri, 9 Aug 2013 15:08:56 +0200 Subject: [PATCH 014/202] Update concatfragments.sh ... fix broken behavior introduced in 3d60c9ef6162425c0bf9eb2004d9da375965efc9 --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 12b815e..771655c 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -117,7 +117,7 @@ IFS=' ' for fragfile in `find fragments/ -type f -follow | LANG=C sort ${SORTARG}` do - cat $fragfile >> concat.fragment + cat $fragfile >> "fragments.concat" done IFS=$IFS_BACKUP From 1830a686e7f8915d976d53dad7c64e336a071062 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Fri, 9 Aug 2013 10:19:00 -0400 Subject: [PATCH 015/202] Fix spec tests --- spec/defines/init_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/defines/init_spec.rb b/spec/defines/init_spec.rb index 172929a..ace50f0 100644 --- a/spec/defines/init_spec.rb +++ b/spec/defines/init_spec.rb @@ -49,7 +49,7 @@ describe 'concat' do should contain_exec("concat_/etc/foo.bar").with_command( "#{basedir}/bin/concatfragments.sh " + "-o #{basedir}/_etc_foo.bar/fragments.concat.out " + - "-d #{basedir}/_etc_foo.bar " + "-d #{basedir}/_etc_foo.bar " ) end end @@ -105,7 +105,7 @@ describe 'concat' do should contain_exec("concat_foobar").with_command( "#{basedir}/bin/concatfragments.sh " + "-o #{basedir}/foobar/fragments.concat.out " + - "-d #{basedir}/foobar " + "-d #{basedir}/foobar " ) end From 542371033235a01ac9bf32db68c11149a24b8c61 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 9 Aug 2013 09:02:24 -0700 Subject: [PATCH 016/202] Release 1.0.0. This commits changes all the references to volcane to point to puppetlabs to free him from any more stray tech support requests as well. --- CHANGELOG | 26 ++++++++++++++++++++++++++ Modulefile | 12 ++++++------ README | 7 ++----- README.markdown | 2 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 139a638..f8141d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,29 @@ +2013-08-09 1.0.0 + +Summary: + +Many new features and bugfixes in this release, and if you're a heavy concat +user you should test carefully before upgrading. The features should all be +backwards compatible but only light testing has been done from our side before +this release. + +Features: +- New parameters in concat: + - `replace`: specify if concat should replace existing files. + - `ensure_newline`: controls if fragments should contain a newline at the end. +- Improved README documentation. +- Add rspec:system tests (rake spec:system to test concat) + +Bugfixes +- Gracefully handle \n in a fragment resource name. +- Adding more helpful message for 'pluginsync = true' +- Allow passing `source` and `content` directly to file resource, rather than +defining resource defaults. +- Added -r flag to read so that filenames with \ will be read correctly. +- sort always uses LANG=C. +- Allow WARNMSG to contain/start with '#'. +- Replace while-read pattern with for-do in order to support Solaris. + CHANGELOG: - 2010/02/19 - initial release - 2010/03/12 - add support for 0.24.8 and newer diff --git a/Modulefile b/Modulefile index 3815edd..cb6bc2e 100644 --- a/Modulefile +++ b/Modulefile @@ -1,8 +1,8 @@ -name 'ripienaar-concat' -version '0.2.0' -source 'git://github.com/ripienaar/puppet-concat.git' -author 'R.I.Pienaar' -license 'Apache' +name 'puppetlabs-concat' +version '1.0.0-rc1' +source 'git://github.com/puppetlabs/puppetlabs-concat.git' +author 'Puppetlabs' +license 'Apache 2.0' summary 'Concat module' description 'Concat module' -project_page 'http://github.com/ripienaar/puppet-concat' +project_page 'http://github.com/puppetlabs/puppetlabs-concat' diff --git a/README b/README index 81bdedb..650141c 100644 --- a/README +++ b/README @@ -84,11 +84,8 @@ Apache Version 2 === Latest: -http://github.com/ripienaar/puppet-concat/ +http://github.com/puppetlabs/puppetlabs-concat/ === Contact: -* R.I.Pienaar -* Volcane on freenode -* @ripienaar on twitter -* www.devco.net +Puppetlabs, via our puppet-users@ mailing list. diff --git a/README.markdown b/README.markdown index 567fb9c..c9a52b3 100644 --- a/README.markdown +++ b/README.markdown @@ -151,4 +151,4 @@ Contributors: Contact: -------- -R.I.Pienaar / rip@devco.net / @ripienaar / http://devco.net +puppet-users@ mailing list. From 8584aa9637ef810ee1d30bb65335d04ee4963e63 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 14 Aug 2013 18:50:04 -0400 Subject: [PATCH 017/202] Release 1.0.0. --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index cb6bc2e..8515b17 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.0-rc1' +version '1.0.0' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From d05da952ca21d4f91040d5bb9a6c5261bf8d83cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Lespez?= Date: Sat, 17 Aug 2013 18:35:44 +0200 Subject: [PATCH 018/202] Add an ensure parameter to concat define This parameter controls whether ressources associated to concat should be present or absent. --- manifests/init.pp | 114 ++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index ed4068b..d132e43 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,6 +4,8 @@ # # === Options: # +# [*ensure*] +# Present/Absent # [*path*] # The path to the final file. Use this in case you want to differentiate # between the name of a resource and the file path. Note: Use the name you @@ -46,6 +48,7 @@ # File["concat_/path/to/file"] # define concat( + $ensure = 'present', $path = $name, $owner = $::id, $group = $concat::setup::root_group, @@ -56,7 +59,7 @@ define concat( $replace = true, $gnu = undef, $order='alpha', - $ensure_newline = false + $ensure_newline = false, ) { include concat::setup @@ -129,60 +132,81 @@ define concat( replace => $replace } - file { $fragdir: - ensure => directory, - } - $source_real = $version ? { 24 => 'puppet:///concat/null', default => undef, } - file { "${fragdir}/fragments": - ensure => directory, - force => true, - ignore => ['.svn', '.git', '.gitignore'], - notify => Exec["concat_${name}"], - purge => true, - recurse => true, - source => $source_real, - } + if $ensure == 'present' { + file { $fragdir: + ensure => directory, + } - file { "${fragdir}/fragments.concat": - ensure => present, - } + file { "${fragdir}/fragments": + ensure => directory, + force => true, + ignore => ['.svn', '.git', '.gitignore'], + notify => Exec["concat_${name}"], + purge => true, + recurse => true, + source => $source_real, + } - file { "${fragdir}/${concat_name}": - ensure => present, - } + file { "${fragdir}/fragments.concat": + ensure => present, + } - file { $name: - ensure => present, - path => $path, - alias => "concat_${name}", - group => $group, - mode => $mode, - owner => $owner, - source => "${fragdir}/${concat_name}", - } + file { "${fragdir}/${concat_name}": + ensure => present, + } - exec { "concat_${name}": - alias => "concat_${fragdir}", - command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", - notify => File[$name], - require => [ - File[$fragdir], - File["${fragdir}/fragments"], - File["${fragdir}/fragments.concat"], - ], - subscribe => File[$fragdir], - unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", - } + file { $name: + ensure => present, + path => $path, + alias => "concat_${name}", + group => $group, + mode => $mode, + owner => $owner, + source => "${fragdir}/${concat_name}", + } - if $::id == 'root' { - Exec["concat_${name}"] { - user => root, - group => $group, + exec { "concat_${name}": + alias => "concat_${fragdir}", + command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", + notify => File[$name], + require => [ + File[$fragdir], + File["${fragdir}/fragments"], + File["${fragdir}/fragments.concat"], + ], + subscribe => File[$fragdir], + unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", + } + + if $::id == 'root' { + Exec["concat_${name}"] { + user => root, + group => $group, + } + } + } + else { + file { + [ $fragdir, + "${fragdir}/fragments", + "${fragdir}/fragments.concat", + "${fragdir}/${concat_name}" ]: + ensure => absent, + backup => false, + force => true; + $name: + ensure => absent, + } + + exec { "concat_${name}": + alias => "concat_${fragdir}", + command => 'true', + path => '/bin:/usr/bin' } } } From 64c278490ca756746d21d2ecc3dea72d2a115f12 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 24 Sep 2013 17:12:27 -0400 Subject: [PATCH 019/202] Ensure that ::setup runs before ::fragment in all cases. --- Gemfile | 1 - manifests/setup.pp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 783e522..d5738af 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ group :development, :test do gem 'serverspec', :require => false gem 'rspec-system-serverspec', :require => false gem 'pry', :require => false - gem 'vagrant-wrapper', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/manifests/setup.pp b/manifests/setup.pp index 2d29bf8..15be696 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -52,4 +52,8 @@ class concat::setup { '/usr/local/bin/concatfragments.sh': ensure => absent; } + + # Ensure we run setup first. + Class['concat::setup'] -> Concat::Fragment<| |> + } From bb16039347d2d529d90a12b7bd4392d00fe063ab Mon Sep 17 00:00:00 2001 From: Aaron Blew Date: Fri, 27 Sep 2013 00:24:58 -0700 Subject: [PATCH 020/202] Help message for pluginsync now references the correct section of the config --- README.markdown | 2 +- manifests/setup.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index c9a52b3..9580c9d 100644 --- a/README.markdown +++ b/README.markdown @@ -80,7 +80,7 @@ manifest files. Known Issues: ------------- * Since puppet-concat now relies on a fact for the concat directory, - you will need to set up pluginsync = true on the [master] section of your + you will need to set up pluginsync = true on both the master and client node's '/etc/puppet/puppet.conf' for at least the first run. You have this issue if puppet fails to run on the client and you have a message similar to diff --git a/manifests/setup.pp b/manifests/setup.pp index 15be696..55d7197 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -27,7 +27,7 @@ class concat::setup { if $::concat_basedir { $concatdir = $::concat_basedir } else { - fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] section of your node's '/etc/puppet/puppet.conf'.") + fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node's '/etc/puppet/puppet.conf'.") } $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1') From c89863cf7ce3ef157dc8b4add04d3e1b9a766195 Mon Sep 17 00:00:00 2001 From: petems Date: Wed, 2 Oct 2013 13:53:00 +0100 Subject: [PATCH 021/202] Updated .gitignore for spec generated files --- .gitignore | 7 ++++++- spec/fixtures/manifests/site.pp | 0 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 spec/fixtures/manifests/site.pp diff --git a/.gitignore b/.gitignore index 5fff1d9..7f449ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -pkg +.pkg +Gemfile.lock +vendor +spec/fixtures +.rspec_system +.bundle \ No newline at end of file diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29..0000000 From 556702601f2436ca21e1edd1a71edc096b5d769e Mon Sep 17 00:00:00 2001 From: Paul Chechetin Date: Tue, 15 Oct 2013 22:42:56 +0400 Subject: [PATCH 022/202] Add Travis badge Inspired by #75 --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 9580c9d..844133f 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,7 @@ What is it? =========== +[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-concat.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-concat) + A Puppet module that can construct files from fragments. From cdb6d6b007d797f95d8263e5b67fa2e4e40e73b6 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 15 Oct 2013 14:07:51 -0700 Subject: [PATCH 023/202] remove undocumented requirement to include concat::setup in manifest Unless the class `concat::setup` has been manually included into the manifest before using the `concat` / `concat::fragment` defined types, the puppet master will generate this warning while compiling the catalog. Tue Oct 15 14:05:06 -0700 2013 Scope(Concat[/etc/exports]) (warning): Could not look up qualified variable 'concat::setup::root_group'; class concat::setup has not been evaluated The need to `include concat::setup` directly into the manifest has never been part of the documented API. --- README.markdown | 4 +++ manifests/fragment.pp | 14 ++++++++--- manifests/init.pp | 13 +++++++--- manifests/setup.pp | 3 --- spec/defines/concat_fragment_spec.rb | 37 ++++++++++++++++++++++++++++ spec/defines/init_spec.rb | 6 ----- 6 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 spec/defines/concat_fragment_spec.rb diff --git a/README.markdown b/README.markdown index 9580c9d..5e950b7 100644 --- a/README.markdown +++ b/README.markdown @@ -149,6 +149,10 @@ Contributors: * Configurable paths +**Joshua Hoblitt** + + * Remove requirement to manually include `concat::setup` in the manifest + Contact: -------- puppet-users@ mailing list. diff --git a/manifests/fragment.pp b/manifests/fragment.pp index a6831f8..1d883cb 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -33,13 +33,21 @@ define concat::fragment( $ensure = 'present', $mode = '0644', $owner = $::id, - $group = $concat::setup::root_group, - $backup = 'puppet') { + $group = undef, + $backup = 'puppet' +) { + include concat::setup + $safe_name = regsubst($name, '[/\n]', '_', 'GM') $safe_target_name = regsubst($target, '[/\n]', '_', 'GM') $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_target_name}" + $safe_group = $group ? { + undef => $concat::setup::root_group, + default => $group, + } + # if content is passed, use that, else if source is passed use that # if neither passed, but $ensure is in symlink form, make a symlink case $ensure { @@ -57,7 +65,7 @@ define concat::fragment( ensure => $ensure, mode => $mode, owner => $owner, - group => $group, + group => $safe_group, source => $source, content => $content, backup => $backup, diff --git a/manifests/init.pp b/manifests/init.pp index d132e43..214c929 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -51,7 +51,7 @@ define concat( $ensure = 'present', $path = $name, $owner = $::id, - $group = $concat::setup::root_group, + $group = undef, $mode = '0644', $warn = false, $force = false, @@ -70,6 +70,11 @@ define concat( $concat_name = 'fragments.concat.out' $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' + $safe_group = $group ? { + undef => $concat::setup::root_group, + default => $safe_group, + } + case $warn { 'true', true, yes, on: { $warnmsg = $default_warn_message @@ -126,7 +131,7 @@ define concat( File { owner => $::id, - group => $group, + group => $safe_group, mode => $mode, backup => $backup, replace => $replace @@ -164,7 +169,7 @@ define concat( ensure => present, path => $path, alias => "concat_${name}", - group => $group, + group => $safe_group, mode => $mode, owner => $owner, source => "${fragdir}/${concat_name}", @@ -186,7 +191,7 @@ define concat( if $::id == 'root' { Exec["concat_${name}"] { user => root, - group => $group, + group => $safe_group, } } } diff --git a/manifests/setup.pp b/manifests/setup.pp index 55d7197..4dc5129 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -53,7 +53,4 @@ class concat::setup { ensure => absent; } - # Ensure we run setup first. - Class['concat::setup'] -> Concat::Fragment<| |> - } diff --git a/spec/defines/concat_fragment_spec.rb b/spec/defines/concat_fragment_spec.rb new file mode 100644 index 0000000..8a37247 --- /dev/null +++ b/spec/defines/concat_fragment_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe 'concat::fragment', :type => :defne do + let(:title) { 'motd_header' } + + let(:facts) do + { + :concat_basedir => '/var/lib/puppet/concat', + :id => 'root', + } + end + + let :pre_condition do + "concat{ '/etc/motd': }" + end + + context 'target => /etc/motd' do + let(:params) {{ :target => '/etc/motd' }} + it do + should contain_class('concat::setup') + should contain_concat('/etc/motd') + should contain_concat__fragment('motd_header').with({ + :target => '/etc/motd', + }) + should contain_file('/var/lib/puppet/concat/_etc_motd/fragments/10_motd_header' ).with({ + :ensure => 'present', + :mode => '0644', + :owner => 'root', + :group => 0, + :source => nil, + :content => nil, + :backup => 'puppet', + :alias => 'concat_fragment_motd_header', + }) + end + end +end diff --git a/spec/defines/init_spec.rb b/spec/defines/init_spec.rb index ace50f0..4195d55 100644 --- a/spec/defines/init_spec.rb +++ b/spec/defines/init_spec.rb @@ -7,9 +7,6 @@ describe 'concat' do :concat_basedir => '/var/lib/puppet/concat', :id => 'root', } } - let :pre_condition do - 'include concat::setup' - end directories = [ "#{basedir}/_etc_foo.bar", @@ -63,9 +60,6 @@ describe 'concat' do :concat_basedir => '/var/lib/puppet/concat', :id => 'root', } } - let :pre_condition do - 'include concat::setup' - end directories = [ "#{basedir}/foobar", From acf67807e333a54fa8d13298137d9b0da8283960 Mon Sep 17 00:00:00 2001 From: JustinHook Date: Sat, 19 Oct 2013 22:30:44 +0100 Subject: [PATCH 024/202] Added .gitattributes to maintain line endings for .sh files --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2e05fd4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh eol=lf From fbb8f40594a4b6d4085128161d4973e28e3c91f8 Mon Sep 17 00:00:00 2001 From: Graham Bleach Date: Tue, 22 Oct 2013 12:36:19 +0100 Subject: [PATCH 025/202] Fix group ownership on files. And add a test to stop it being broken again. --- manifests/init.pp | 2 +- spec/defines/init_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 214c929..25c2ff5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -72,7 +72,7 @@ define concat( $safe_group = $group ? { undef => $concat::setup::root_group, - default => $safe_group, + default => $group, } case $warn { diff --git a/spec/defines/init_spec.rb b/spec/defines/init_spec.rb index 4195d55..d19ea2d 100644 --- a/spec/defines/init_spec.rb +++ b/spec/defines/init_spec.rb @@ -106,4 +106,26 @@ describe 'concat' do end +describe 'concat' do + let(:title) { '/etc/foo.bar' } + let(:params) { { + :group => 'something', + :owner => 'someone', + :mode => '0755' + } } + let(:facts) { { + :concat_basedir => '/var/lib/puppet/concat', + :id => 'root', + } } + + it do + should contain_file("/etc/foo.bar").with( { + 'ensure' => 'present', + 'owner' => 'someone', + 'group' => 'something', + 'mode' => '0755', + } ) + end +end + # vim:sw=2:ts=2:expandtab:textwidth=79 From 987eaec7ab49e15e7517a91a5d052255dd7ff541 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 22 Oct 2013 08:53:18 -0700 Subject: [PATCH 026/202] improve whitespace consistency + remove semicolon resource compression Per http://docs.puppetlabs.com/guides/style_guide.html#resources resource compression with the "semicolon syntax" is now considered bad practice. --- manifests/fragment.pp | 24 ++++----- manifests/init.pp | 115 ++++++++++++++++++++++-------------------- manifests/setup.pp | 16 +++--- 3 files changed, 80 insertions(+), 75 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 1d883cb..05e6ef4 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -27,21 +27,21 @@ # define concat::fragment( $target, - $content=undef, - $source=undef, - $order=10, - $ensure = 'present', - $mode = '0644', - $owner = $::id, - $group = undef, - $backup = 'puppet' + $content = undef, + $source = undef, + $order = 10, + $ensure = 'present', + $mode = '0644', + $owner = $::id, + $group = undef, + $backup = 'puppet' ) { include concat::setup - $safe_name = regsubst($name, '[/\n]', '_', 'GM') + $safe_name = regsubst($name, '[/\n]', '_', 'GM') $safe_target_name = regsubst($target, '[/\n]', '_', 'GM') - $concatdir = $concat::setup::concatdir - $fragdir = "${concatdir}/${safe_target_name}" + $concatdir = $concat::setup::concatdir + $fragdir = "${concatdir}/${safe_target_name}" $safe_group = $group ? { undef => $concat::setup::root_group, @@ -61,7 +61,7 @@ define concat::fragment( } } - file{"${fragdir}/fragments/${order}_${safe_name}": + file { "${fragdir}/fragments/${order}_${safe_name}": ensure => $ensure, mode => $mode, owner => $owner, diff --git a/manifests/init.pp b/manifests/init.pp index 25c2ff5..0ce8a96 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -48,26 +48,26 @@ # File["concat_/path/to/file"] # define concat( - $ensure = 'present', - $path = $name, - $owner = $::id, - $group = undef, - $mode = '0644', - $warn = false, - $force = false, - $backup = 'puppet', - $replace = true, - $gnu = undef, - $order='alpha', + $ensure = 'present', + $path = $name, + $owner = $::id, + $group = undef, + $mode = '0644', + $warn = false, + $force = false, + $backup = 'puppet', + $replace = true, + $gnu = undef, + $order = 'alpha', $ensure_newline = false, ) { include concat::setup - $safe_name = regsubst($name, '/', '_', 'G') - $concatdir = $concat::setup::concatdir - $version = $concat::setup::majorversion - $fragdir = "${concatdir}/${safe_name}" - $concat_name = 'fragments.concat.out' + $safe_name = regsubst($name, '/', '_', 'G') + $concatdir = $concat::setup::concatdir + $version = $concat::setup::majorversion + $fragdir = "${concatdir}/${safe_name}" + $concat_name = 'fragments.concat.out' $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' $safe_group = $group ? { @@ -76,10 +76,10 @@ define concat( } case $warn { - 'true', true, yes, on: { + 'true', true, 'yes', 'on': { $warnmsg = $default_warn_message } - 'false', false, no, off: { + 'false', false, 'no', 'off': { $warnmsg = '' } default: { @@ -94,10 +94,10 @@ define concat( } case $force { - 'true', true, yes, on: { + 'true', true, 'yes', 'on': { $forceflag = '-f' } - 'false', false, no, off: { + 'false', false, 'no', 'off': { $forceflag = '' } default: { @@ -106,10 +106,10 @@ define concat( } case $order { - numeric: { + 'numeric': { $orderflag = '-n' } - alpha: { + 'alpha': { $orderflag = '' } default: { @@ -118,10 +118,10 @@ define concat( } case $ensure_newline { - 'true', true, yes, on: { + 'true', true, 'yes', 'on': { $newlineflag = '-l' } - 'false', false, no, off: { + 'false', false, 'no', 'off': { $newlineflag = '' } default: { @@ -148,44 +148,44 @@ define concat( } file { "${fragdir}/fragments": - ensure => directory, - force => true, - ignore => ['.svn', '.git', '.gitignore'], - notify => Exec["concat_${name}"], - purge => true, - recurse => true, - source => $source_real, + ensure => directory, + force => true, + ignore => ['.svn', '.git', '.gitignore'], + notify => Exec["concat_${name}"], + purge => true, + recurse => true, + source => $source_real, } file { "${fragdir}/fragments.concat": - ensure => present, + ensure => present, } file { "${fragdir}/${concat_name}": - ensure => present, + ensure => present, } file { $name: - ensure => present, - path => $path, - alias => "concat_${name}", - group => $safe_group, - mode => $mode, - owner => $owner, - source => "${fragdir}/${concat_name}", + ensure => present, + path => $path, + alias => "concat_${name}", + group => $safe_group, + mode => $mode, + owner => $owner, + source => "${fragdir}/${concat_name}", } exec { "concat_${name}": - alias => "concat_${fragdir}", - command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", - notify => File[$name], - require => [ + alias => "concat_${fragdir}", + command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", + notify => File[$name], + require => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"], ], - subscribe => File[$fragdir], - unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", + subscribe => File[$fragdir], + unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", } if $::id == 'root' { @@ -196,16 +196,19 @@ define concat( } } else { - file { - [ $fragdir, - "${fragdir}/fragments", - "${fragdir}/fragments.concat", - "${fragdir}/${concat_name}" ]: - ensure => absent, - backup => false, - force => true; - $name: - ensure => absent, + file { [ + $fragdir, + "${fragdir}/fragments", + "${fragdir}/fragments.concat", + "${fragdir}/${concat_name}" + ]: + ensure => absent, + backup => false, + force => true, + } + + file { $name: + ensure => absent, } exec { "concat_${name}": diff --git a/manifests/setup.pp b/manifests/setup.pp index 4dc5129..1982c61 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -27,7 +27,7 @@ class concat::setup { if $::concat_basedir { $concatdir = $::concat_basedir } else { - fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node's '/etc/puppet/puppet.conf'.") + fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1') @@ -36,21 +36,23 @@ class concat::setup { default => 'puppet:///modules/concat/concatfragments.sh' } - file{"${concatdir}/bin/concatfragments.sh": + file { "${concatdir}/bin/concatfragments.sh": owner => $id, group => $root_group, mode => '0755', - source => $fragments_source; + source => $fragments_source, + } - [ $concatdir, "${concatdir}/bin" ]: + file { [ $concatdir, "${concatdir}/bin" ]: ensure => directory, owner => $id, group => $root_group, - mode => '0750'; + mode => '0750', + } ## Old versions of this module used a different path. - '/usr/local/bin/concatfragments.sh': - ensure => absent; + file { '/usr/local/bin/concatfragments.sh': + ensure => absent, } } From e4a53b6755c8169d0373caa212bcdf7c94ef1f4d Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 22 Oct 2013 09:27:53 -0700 Subject: [PATCH 027/202] remove unused $gnu param from define concat --- manifests/init.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0ce8a96..cf7f755 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -57,7 +57,6 @@ define concat( $force = false, $backup = 'puppet', $replace = true, - $gnu = undef, $order = 'alpha', $ensure_newline = false, ) { From eaf8407941ddaade508de8f1b14b7115eb6761ca Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 22 Oct 2013 12:43:43 -0700 Subject: [PATCH 028/202] validate define concat params + split warn param In addition, the warn param has been split into a warn (a bool) and warn_message (a string). --- .fixtures.yml | 4 + Modulefile | 1 + manifests/init.pp | 99 ++++---- spec/defines/init_spec.rb | 470 +++++++++++++++++++++++++++++--------- 4 files changed, 412 insertions(+), 162 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 2d6fee0..f7f1eba 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,7 @@ fixtures: + repositories: + 'stdlib': + repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' + ref: '3.0.0' symlinks: 'concat': '#{source_dir}' diff --git a/Modulefile b/Modulefile index 8515b17..249438e 100644 --- a/Modulefile +++ b/Modulefile @@ -6,3 +6,4 @@ license 'Apache 2.0' summary 'Concat module' description 'Concat module' project_page 'http://github.com/puppetlabs/puppetlabs-concat' +dependency 'puppetlabs/stdlib', '>= 3.0.0' diff --git a/manifests/init.pp b/manifests/init.pp index cf7f755..319f94f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,22 +10,27 @@ # The path to the final file. Use this in case you want to differentiate # between the name of a resource and the file path. Note: Use the name you # provided in the target of your fragments. -# [*mode*] -# The mode of the final file # [*owner*] # Who will own the file # [*group*] # Who will own the file +# [*mode*] +# The mode of the final file # [*force*] # Enables creating empty files if no fragments are present # [*warn*] # Adds a normal shell style comment top of the file indicating that it is # built by puppet +# [*warn_message*] +# A custom message string that overides the default. +# [*force*] # [*backup*] # Controls the filebucketing behavior of the final file and see File type # reference for its use. Defaults to 'puppet' # [*replace*] # Whether to replace a file that already exists on the local system +# [*order*] +# [*ensure_newline*] # # === Actions: # * Creates fragment directories if it didn't exist already @@ -54,12 +59,26 @@ define concat( $group = undef, $mode = '0644', $warn = false, + $warn_message = undef, $force = false, $backup = 'puppet', $replace = true, $order = 'alpha', $ensure_newline = false, ) { + validate_re($ensure, '^present$|^absent$') + validate_absolute_path($path) + validate_string($owner) + validate_string($group) + validate_string($mode) + validate_bool($warn) + validate_string($warn_message) + validate_bool($force) + validate_string($backup) + validate_bool($replace) + validate_re($order, '^alpha$|^numeric$') + validate_bool($ensure_newline) + include concat::setup $safe_name = regsubst($name, '/', '_', 'G') @@ -74,62 +93,38 @@ define concat( default => $group, } - case $warn { - 'true', true, 'yes', 'on': { - $warnmsg = $default_warn_message - } - 'false', false, 'no', 'off': { - $warnmsg = '' - } - default: { - $warnmsg = $warn + if $warn == true { + $use_warn_message = $warn_message ? { + undef => $default_warn_message, + default => $warn_message, } + } else { + $use_warn_message = undef } - $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G') + $warnmsg_escaped = regsubst($use_warn_message, "'", "'\\\\''", 'G') $warnflag = $warnmsg_escaped ? { '' => '', default => "-w '${warnmsg_escaped}'" } - case $force { - 'true', true, 'yes', 'on': { - $forceflag = '-f' - } - 'false', false, 'no', 'off': { - $forceflag = '' - } - default: { - fail("Improper 'force' value given to concat: ${force}") - } + $forceflag = $force ? { + true => '-f', + false => '', } - case $order { - 'numeric': { - $orderflag = '-n' - } - 'alpha': { - $orderflag = '' - } - default: { - fail("Improper 'order' value given to concat: ${order}") - } + $orderflag = $order ? { + 'numeric' => '-n', + 'alpha' => '', } - case $ensure_newline { - 'true', true, 'yes', 'on': { - $newlineflag = '-l' - } - 'false', false, 'no', 'off': { - $newlineflag = '' - } - default: { - fail("Improper 'ensure_newline' value given to concat: ${ensure_newline}") - } + $newlineflag = $ensure_newline ? { + true => '-l', + false => '', } File { - owner => $::id, + owner => $owner, group => $safe_group, mode => $mode, backup => $backup, @@ -168,23 +163,23 @@ define concat( ensure => present, path => $path, alias => "concat_${name}", - group => $safe_group, - mode => $mode, - owner => $owner, source => "${fragdir}/${concat_name}", } + # remove extra whitespace from string interopolation to make testing easier + $command = strip(regsubst("${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + exec { "concat_${name}": - alias => "concat_${fragdir}", - command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", - notify => File[$name], - require => [ + alias => "concat_${fragdir}", + command => $command, + notify => File[$name], + subscribe => File[$fragdir], + unless => "${command} -t", + require => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"], ], - subscribe => File[$fragdir], - unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", } if $::id == 'root' { diff --git a/spec/defines/init_spec.rb b/spec/defines/init_spec.rb index d19ea2d..116e518 100644 --- a/spec/defines/init_spec.rb +++ b/spec/defines/init_spec.rb @@ -1,131 +1,381 @@ require 'spec_helper' -describe 'concat' do - basedir = '/var/lib/puppet/concat' - let(:title) { '/etc/foo.bar' } - let(:facts) { { - :concat_basedir => '/var/lib/puppet/concat', - :id => 'root', - } } +describe 'concat', :type => :define do - directories = [ - "#{basedir}/_etc_foo.bar", - "#{basedir}/_etc_foo.bar/fragments", - ] + shared_examples 'concat' do |title, params={}| + id = 'root' - directories.each do |dirs| - it do - should contain_file(dirs).with({ - 'ensure' => 'directory', - 'backup' => 'puppet', - 'group' => 0, - 'mode' => '0644', - 'owner' => 'root', - }) + # default param values + p = { + :ensure => 'present', + :path => title, + :owner => id, + :group => '0', + :mode => '0644', + :warn => false, + :warn_message => nil, + :force => false, + :backup => 'puppet', + :replace => true, + :order => 'alpha', + :ensure_newline => false, + }.merge(params) + + safe_name = title.gsub('/', '_') + concatdir = '/var/lib/puppet/concat' + fragdir = "#{concatdir}/#{safe_name}" + concat_name = 'fragments.concat.out' + default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' + + file_defaults = { + :owner => p[:owner], + :group => p[:group], + :mode => p[:mode], + :backup => p[:backup], + :replace => p[:replace], + } + + let(:title) { title } + let(:params) { params } + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + } + end + + if p[:ensure] == 'present' + it do + should contain_file(fragdir).with(file_defaults.merge({ + :ensure => 'directory', + })) + end + + it do + should contain_file("#{fragdir}/fragments").with(file_defaults.merge({ + :ensure => 'directory', + :force => true, + :ignore => ['.svn', '.git', '.gitignore'], + :purge => true, + :recurse => true, + :source => nil, # true for all but for puppet 24 + })) + end + + [ + "#{fragdir}/fragments.concat", + "#{fragdir}/#{concat_name}", + ].each do |file| + it do + should contain_file(file).with(file_defaults.merge({ + :ensure => 'present', + })) + end + end + + it do + should contain_file(title).with(file_defaults.merge({ + :ensure => 'present', + :path => p[:path], + :alias => "concat_#{title}", + :source => "#{fragdir}/#{concat_name}", + })) + end + + cmd = "#{concatdir}/bin/concatfragments.sh " + + "-o #{concatdir}/#{safe_name}/fragments.concat.out " + + "-d #{concatdir}/#{safe_name}" + + # flag order: fragdir, warnflag, forceflag, orderflag, newlineflag + if p[:warn] + message = p[:warn_message] || default_warn_message + cmd += " -w \'#{message}\'" + end + + cmd += " -f" if p[:force] + cmd += " -n" if p[:order] == 'numeric' + cmd += " -l" if p[:ensure_newline] == true + + it do + should contain_exec("concat_#{title}").with({ + :alias => "concat_#{fragdir}", + :command => cmd, + :unless => "#{cmd} -t", + }) + + if id == 'root' + should contain_exec("concat_#{title}").with({ + :user => 'root', + :group => p[:group], + }) + end + end + else + [ + fragdir, + "#{fragdir}/fragments", + "#{fragdir}/fragments.concat", + "#{fragdir}/#{concat_name}", + ].each do |file| + it do + should contain_file(file).with(file_defaults.merge({ + :ensure => 'absent', + :backup => false, + :force => true, + })) + end + end + + it do + should contain_file(title).with(file_defaults.merge({ + :ensure => 'absent', + })) + end + + it do + should contain_file(title).with(file_defaults.merge({ + :ensure => 'absent', + })) + end + + it do + should contain_exec("concat_#{title}").with({ + :alias => "concat_#{fragdir}", + :command => 'true', + :path => '/bin:/usr/bin', + }) + end end end - files = [ - "/etc/foo.bar", - "#{basedir}/_etc_foo.bar/fragments.concat", - ] + context 'title' do + context 'without path param' do + # title/name is the default value for the path param. therefore, the + # title must be an absolute path unless path is specified + ['/foo', '/foo/bar', '/foo/bar/baz'].each do |title| + context title do + it_behaves_like 'concat', '/etc/foo.bar' + end + end - files.each do |file| - it do - should contain_file(file).with({ - 'ensure' => 'present', - 'backup' => 'puppet', - 'group' => 0, - 'mode' => '0644', - 'owner' => 'root', - }) + ['./foo', 'foo', 'foo/bar'].each do |title| + context title do + let(:title) { title } + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + end + end + end end - end - it do - should contain_exec("concat_/etc/foo.bar").with_command( - "#{basedir}/bin/concatfragments.sh " + - "-o #{basedir}/_etc_foo.bar/fragments.concat.out " + - "-d #{basedir}/_etc_foo.bar " - ) - end -end - -describe 'concat' do - - basedir = '/var/lib/puppet/concat' - let(:title) { 'foobar' } - let(:target) { '/etc/foo.bar' } - let(:facts) { { - :concat_basedir => '/var/lib/puppet/concat', - :id => 'root', - } } - - directories = [ - "#{basedir}/foobar", - "#{basedir}/foobar/fragments", - ] - - directories.each do |dirs| - it do - should contain_file(dirs).with({ - 'ensure' => 'directory', - 'backup' => 'puppet', - 'group' => 0, - 'mode' => '0644', - 'owner' => 'root', - }) + context 'with path param' do + ['./foo', 'foo', 'foo/bar'].each do |title| + context title do + it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } + end + end end - end + end # title => - files = [ - "foobar", - "#{basedir}/foobar/fragments.concat", - ] - - files.each do |file| - it do - should contain_file(file).with({ - 'ensure' => 'present', - 'backup' => 'puppet', - 'group' => 0, - 'mode' => '0644', - 'owner' => 'root', - }) + context 'ensure =>' do + ['present', 'absent'].each do |ens| + context ens do + it_behaves_like 'concat', '/etc/foo.bar', { :ensure => ens } + end end - end - it do - should contain_exec("concat_foobar").with_command( - "#{basedir}/bin/concatfragments.sh " + - "-o #{basedir}/foobar/fragments.concat.out " + - "-d #{basedir}/foobar " - ) - end + context 'invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :ensure => 'invalid' }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^present$|^absent$"')}/) + end + end + end # ensure => + context 'path =>' do + context '/foo' do + it_behaves_like 'concat', '/etc/foo.bar', { :path => '/foo' } + end -end + ['./foo', 'foo', 'foo/bar', false].each do |path| + context path do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :path => path }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + end + end + end + end # path => -describe 'concat' do - let(:title) { '/etc/foo.bar' } - let(:params) { { - :group => 'something', - :owner => 'someone', - :mode => '0755' - } } - let(:facts) { { - :concat_basedir => '/var/lib/puppet/concat', - :id => 'root', - } } + context 'owner =>' do + context 'apenney' do + it_behaves_like 'concat', '/etc/foo.bar', { :owner => 'apenny' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :owner => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # owner => + + context 'group =>' do + context 'apenney' do + it_behaves_like 'concat', '/etc/foo.bar', { :group => 'apenny' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :group => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # group => + + context 'mode =>' do + context '1755' do + it_behaves_like 'concat', '/etc/foo.bar', { :mode => '1755' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :mode => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # mode => + + context 'warn =>' do + [true, false].each do |warn| + context warn do + it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :warn => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # warn => + + context 'warn_message =>' do + context '# ashp replaced your file' do + # should do nothing unless warn == true; + # but we can't presently test that because concatfragments.sh isn't run + # from rspec-puppet tests + context 'warn =>' do + context 'true' do + it_behaves_like 'concat', '/etc/foo.bar', { + :warn => true, + :warn_message => '# ashp replaced your file' + } + end + + context 'false' do + it_behaves_like 'concat', '/etc/foo.bar', { + :warn => false, + :warn_message => '# ashp replaced your file' + } + end + end + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :warn_message => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # warn_message => + + context 'force =>' do + [true, false].each do |force| + context force do + it_behaves_like 'concat', '/etc/foo.bar', { :force => force } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :force => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # force => + + context 'backup =>' do + context 'reverse' do + it_behaves_like 'concat', '/etc/foo.bar', { :backup => 'reverse' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :backup => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # backup => + + context 'replace =>' do + [true, false].each do |replace| + context replace do + it_behaves_like 'concat', '/etc/foo.bar', { :replace => replace } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :replace => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # replace => + + context 'order =>' do + ['alpha', 'numeric'].each do |order| + context order do + it_behaves_like 'concat', '/etc/foo.bar', { :order => order } + end + end + + context 'invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :order => 'invalid' }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^alpha$|^numeric$"')}/) + end + end + end # order => + + context 'ensure_newline =>' do + [true, false].each do |ensure_newline| + context 'true' do + it_behaves_like 'concat', '/etc/foo.bar', { :ensure_newline => ensure_newline} + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :ensure_newline => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # ensure_newline => - it do - should contain_file("/etc/foo.bar").with( { - 'ensure' => 'present', - 'owner' => 'someone', - 'group' => 'something', - 'mode' => '0755', - } ) - end end # vim:sw=2:ts=2:expandtab:textwidth=79 From 7b992f79e3754f25b379ed680603a21dd56ced75 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 07:41:38 -0700 Subject: [PATCH 029/202] validate define concat::fragment params --- README.markdown | 3 + manifests/fragment.pp | 10 ++ spec/defines/concat_fragment_spec.rb | 252 ++++++++++++++++++++++++--- 3 files changed, 239 insertions(+), 26 deletions(-) diff --git a/README.markdown b/README.markdown index 0be06d3..cecdcc8 100644 --- a/README.markdown +++ b/README.markdown @@ -154,6 +154,9 @@ Contributors: **Joshua Hoblitt** * Remove requirement to manually include `concat::setup` in the manifest + * Style improvements + * Parameter validation / refactor parameter handling + * Test coverage Contact: -------- diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 05e6ef4..8250ba7 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -36,6 +36,16 @@ define concat::fragment( $group = undef, $backup = 'puppet' ) { + validate_absolute_path($target) + validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') + validate_string($content) + validate_string($source) + validate_string($order) + validate_string($mode) + validate_string($owner) + validate_string($group) + validate_string($backup) + include concat::setup $safe_name = regsubst($name, '[/\n]', '_', 'GM') diff --git a/spec/defines/concat_fragment_spec.rb b/spec/defines/concat_fragment_spec.rb index 8a37247..15feba8 100644 --- a/spec/defines/concat_fragment_spec.rb +++ b/spec/defines/concat_fragment_spec.rb @@ -1,37 +1,237 @@ require 'spec_helper' -describe 'concat::fragment', :type => :defne do - let(:title) { 'motd_header' } +describe 'concat::fragment', :type => :define do - let(:facts) do - { - :concat_basedir => '/var/lib/puppet/concat', - :id => 'root', - } - end + shared_examples 'fragment' do |title, params={}| + id = 'root' - let :pre_condition do - "concat{ '/etc/motd': }" - end + p = { + :content => nil, + :source => nil, + :order => 10, + :ensure => 'present', + :mode => '0644', + :owner => id, + :group => nil, + :backup => 'puppet', + }.merge(params) + + safe_name = title.gsub(/[\/\n]/, '_') + safe_target_name = p[:target].gsub(/[\/\n]/, '_') + concatdir = '/var/lib/puppet/concat' + fragdir = "#{concatdir}/#{safe_target_name}" + if p[:group].nil? + safe_group = id == 'root' ? 0 : id + else + safe_group = p[:group] + end + + let(:title) { title } + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + } + end + let(:params) { params } + let(:pre_condition) do + "concat{ '#{p[:target]}': }" + end - context 'target => /etc/motd' do - let(:params) {{ :target => '/etc/motd' }} it do should contain_class('concat::setup') - should contain_concat('/etc/motd') - should contain_concat__fragment('motd_header').with({ - :target => '/etc/motd', - }) - should contain_file('/var/lib/puppet/concat/_etc_motd/fragments/10_motd_header' ).with({ - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 0, - :source => nil, - :content => nil, - :backup => 'puppet', - :alias => 'concat_fragment_motd_header', + should contain_concat(p[:target]) + should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ + :ensure => p[:ensure], + :mode => p[:mode], + :owner => p[:owner], + :group => safe_group, + :source => p[:source], + :content => p[:content], + :backup => p[:backup], + :alias => "concat_fragment_#{title}", }) end end + + context 'target =>' do + context '/etc/motd' do + it_behaves_like 'fragment', 'motd_header', { + :target => '/etc/motd', + } + end + + ['./etc/motd', 'etc/motd', false].each do |target| + context target do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :target => target }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + end + end + end + end # target => + + context 'ensure =>' do + ['', 'present', 'absent', 'file', 'directory'].each do |ens| + context ens do + it_behaves_like 'fragment', 'motd_header', { + :ensure => ens, + :target => '/etc/motd', + } + end + end + + context 'invalid' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^$|^present$|^absent$|^file$|^directory$"')}/) + end + end + end # ensure => + + context 'content =>' do + ['', 'ashp is our hero'].each do |content| + context content do + it_behaves_like 'fragment', 'motd_header', { + :content => content, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :content => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # content => + + context 'source =>' do + ['', '/foo/bar'].each do |source| + context source do + it_behaves_like 'fragment', 'motd_header', { + :source => source, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :source => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + 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(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :order => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # order => + + context 'mode =>' do + context '1755' do + it_behaves_like 'fragment', 'motd_header', { + :mode => '1755', + :target => '/etc/motd', + } + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :mode => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # mode => + + context 'owner =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :owner => 'apenny', + :target => '/etc/motd', + } + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :owner => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # owner => + + context 'group =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :group => 'apenny', + :target => '/etc/motd', + } + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :group => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # group => + + context 'backup =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :backup => 'apenny', + :target => '/etc/motd', + } + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:params) {{ :backup => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # backup => + end From d7498a4e25a9c140474f1f05278aa50fc4ad3e07 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 07:44:06 -0700 Subject: [PATCH 030/202] add tests for class concat::setup --- spec/unit/classes/concat_setup_spec.rb | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 spec/unit/classes/concat_setup_spec.rb diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb new file mode 100644 index 0000000..21df97d --- /dev/null +++ b/spec/unit/classes/concat_setup_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +describe 'concat::setup', :type => :class do + + shared_examples 'setup' do |id='root', concatdir='/foo'| + let(:facts) {{ :id => id, :concat_basedir => concatdir }} + + it do + should contain_file("#{concatdir}/bin/concatfragments.sh").with({ + :owner => id, + :group => id == 'root' ? 0 : id, + :mode => '0755', + :source => 'puppet:///modules/concat/concatfragments.sh', + }) + end + + [concatdir, "#{concatdir}/bin"].each do |file| + it do + should contain_file(file).with({ + :ensure => 'directory', + :owner => id, + :group => id == 'root' ? 0 : id, + :mode => '0750', + }) + end + end + + it do + should contain_file('/usr/local/bin/concatfragments.sh').with({ + :ensure => 'absent', + }) + end + end + + context 'facts' do + + context 'id =>' do + context 'root' do + it_behaves_like 'setup', 'root' + end + + context 'apenny' do + it_behaves_like 'setup', 'apenny' + end + end + + context 'concat_basedir =>' do + context '/foo' do + it_behaves_like 'setup', 'root', '/foo' + end + + context 'undef' do + let(:facts) {{ :id => 'root' }} + it 'should fail' do + expect { + should + }.to raise_error(Puppet::Error, /#{Regexp.escape('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')}/) + end + end + end + + end # facts +end From 6e554e1a2664aa05cc58e3257f4a036436fe2bc4 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 05:19:56 -0700 Subject: [PATCH 031/202] add stdlib to rspec-system tests --- spec/spec_helper_system.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index bf66a53..0924e47 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -21,5 +21,6 @@ RSpec.configure do |c| # Install modules and dependencies puppet_module_install(:source => proj_root, :module_name => 'concat') + shell('puppet module install puppetlabs-stdlib') end end From cca940184492490c43a7fa5d92f14269cee53c44 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 07:08:22 -0700 Subject: [PATCH 032/202] remove puppet 0.24 support Introduction of stdlib functions makes support of puppet < 2.7 impractical. --- manifests/init.pp | 7 ------- manifests/setup.pp | 16 +--------------- spec/defines/init_spec.rb | 1 - 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 319f94f..5843457 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -83,7 +83,6 @@ define concat( $safe_name = regsubst($name, '/', '_', 'G') $concatdir = $concat::setup::concatdir - $version = $concat::setup::majorversion $fragdir = "${concatdir}/${safe_name}" $concat_name = 'fragments.concat.out' $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' @@ -131,11 +130,6 @@ define concat( replace => $replace } - $source_real = $version ? { - 24 => 'puppet:///concat/null', - default => undef, - } - if $ensure == 'present' { file { $fragdir: ensure => directory, @@ -148,7 +142,6 @@ define concat( notify => Exec["concat_${name}"], purge => true, recurse => true, - source => $source_real, } file { "${fragdir}/fragments.concat": diff --git a/manifests/setup.pp b/manifests/setup.pp index 1982c61..463e963 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -7,14 +7,6 @@ # Since puppet should always manage files in $concatdir and they should # not be deleted ever, /tmp is not an option. # -# [$puppetversion] -# should be either 24 or 25 to enable a 24 compatible -# mode, in 24 mode you might see phantom notifies this is a side effect -# of the method we use to clear the fragments directory. -# -# The regular expression below will try to figure out your puppet version -# but this code will only work in 0.24.8 and newer. -# # It also copies out the concatfragments.sh file to ${concatdir}/bin # class concat::setup { @@ -30,17 +22,11 @@ class concat::setup { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } - $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1') - $fragments_source = $majorversion ? { - 24 => 'puppet:///concat/concatfragments.sh', - default => 'puppet:///modules/concat/concatfragments.sh' - } - file { "${concatdir}/bin/concatfragments.sh": owner => $id, group => $root_group, mode => '0755', - source => $fragments_source, + source => 'puppet:///modules/concat/concatfragments.sh', } file { [ $concatdir, "${concatdir}/bin" ]: diff --git a/spec/defines/init_spec.rb b/spec/defines/init_spec.rb index 116e518..8cabdfa 100644 --- a/spec/defines/init_spec.rb +++ b/spec/defines/init_spec.rb @@ -58,7 +58,6 @@ describe 'concat', :type => :define do :ignore => ['.svn', '.git', '.gitignore'], :purge => true, :recurse => true, - :source => nil, # true for all but for puppet 24 })) end From 86522e1eb255835a4d5ccac0ab8879b0b58893cd Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 10:34:44 -0700 Subject: [PATCH 033/202] make class concat::setup a private class --- manifests/setup.pp | 6 +++++- spec/unit/classes/concat_setup_spec.rb | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index 463e963..f465a25 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -1,6 +1,6 @@ # === Class: concat::setup # -# Sets up the concat system. +# Sets up the concat system. This is a private class. # # [$concatdir] # is where the fragments live and is set on the fact concat_basedir. @@ -10,6 +10,10 @@ # It also copies out the concatfragments.sh file to ${concatdir}/bin # class concat::setup { + if $caller_module_name != $module_name { + fail("Use of private class ${name} by ${caller_module_name}") + } + $id = $::id $root_group = $id ? { root => 0, diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 21df97d..350d5a7 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -33,6 +33,11 @@ describe 'concat::setup', :type => :class do end context 'facts' do + # concat::setup is a private module so we need pretend that we are calling + # it from elsewhere in the same module + let(:pre_condition) do + "$caller_module_name = 'concat'" + end context 'id =>' do context 'root' do @@ -52,12 +57,17 @@ describe 'concat::setup', :type => :class do context 'undef' do let(:facts) {{ :id => 'root' }} it 'should fail' do - expect { - should - }.to raise_error(Puppet::Error, /#{Regexp.escape('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')}/) + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')}/) end end end end # facts + + context 'called from another module namespace' do + let(:facts) {{ :id => 'root', :concat_basedir => '/foo' }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /Use of private class concat::setup/) + end + end end From 4d7a9157663000721dc01ab0e1887b80d64d552e Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 10:36:17 -0700 Subject: [PATCH 034/202] use $owner instead of $id to avoid confusion with $::id --- manifests/setup.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index f465a25..f3793b2 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -14,10 +14,10 @@ class concat::setup { fail("Use of private class ${name} by ${caller_module_name}") } - $id = $::id - $root_group = $id ? { + $owner = $::id + $root_group = $owner ? { root => 0, - default => $id + default => $owner } if $::concat_basedir { @@ -27,7 +27,7 @@ class concat::setup { } file { "${concatdir}/bin/concatfragments.sh": - owner => $id, + owner => $owner, group => $root_group, mode => '0755', source => 'puppet:///modules/concat/concatfragments.sh', @@ -35,7 +35,7 @@ class concat::setup { file { [ $concatdir, "${concatdir}/bin" ]: ensure => directory, - owner => $id, + owner => $owner, group => $root_group, mode => '0750', } From 89dc9a9f718d2c1dccf046d84669208a5ba7e4d2 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 10:49:53 -0700 Subject: [PATCH 035/202] mv spec/defines -> spec/unit/defines To be more consistent with other PL modules --- spec/{ => unit}/defines/concat_fragment_spec.rb | 0 spec/{defines/init_spec.rb => unit/defines/concat_spec.rb} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename spec/{ => unit}/defines/concat_fragment_spec.rb (100%) rename spec/{defines/init_spec.rb => unit/defines/concat_spec.rb} (100%) diff --git a/spec/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb similarity index 100% rename from spec/defines/concat_fragment_spec.rb rename to spec/unit/defines/concat_fragment_spec.rb diff --git a/spec/defines/init_spec.rb b/spec/unit/defines/concat_spec.rb similarity index 100% rename from spec/defines/init_spec.rb rename to spec/unit/defines/concat_spec.rb From b6ee7e40e5c5e6ec2d6bc5c1ce79eda658faa46f Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 12:18:09 -0700 Subject: [PATCH 036/202] compatibility fixes for ruby 1.8.7 / puppet 2.7 --- manifests/init.pp | 2 +- spec/unit/classes/concat_setup_spec.rb | 5 ++++- spec/unit/defines/concat_fragment_spec.rb | 4 +++- spec/unit/defines/concat_spec.rb | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5843457..f32cfff 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -64,7 +64,7 @@ define concat( $backup = 'puppet', $replace = true, $order = 'alpha', - $ensure_newline = false, + $ensure_newline = false ) { validate_re($ensure, '^present$|^absent$') validate_absolute_path($path) diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 350d5a7..f502713 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -2,7 +2,10 @@ require 'spec_helper' describe 'concat::setup', :type => :class do - shared_examples 'setup' do |id='root', concatdir='/foo'| + shared_examples 'setup' do |id, concatdir| + id = 'root' if id.nil? + concatdir = '/foo' if concatdir.nil? + let(:facts) {{ :id => id, :concat_basedir => concatdir }} it do diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 15feba8..296631f 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' describe 'concat::fragment', :type => :define do - shared_examples 'fragment' do |title, params={}| + shared_examples 'fragment' do |title, params| + params = {} if params.nil? + id = 'root' p = { diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 8cabdfa..f8cb8f6 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' describe 'concat', :type => :define do - shared_examples 'concat' do |title, params={}| + shared_examples 'concat' do |title, params| + params = {} if params.nil? + id = 'root' # default param values From 4d884d32426b085215121f148752e41e5e1e15f2 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 23 Oct 2013 15:42:44 -0700 Subject: [PATCH 037/202] only backup target concat file + remove backup param from concat::fragment Disable filebucket backup of all file resources except for the the target file that's being concatenated. --- manifests/fragment.pp | 6 ++---- manifests/init.pp | 7 ++++--- manifests/setup.pp | 4 ++++ spec/unit/classes/concat_setup_spec.rb | 3 +++ spec/unit/defines/concat_fragment_spec.rb | 21 +-------------------- spec/unit/defines/concat_spec.rb | 10 +++------- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 8250ba7..1f90b38 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -33,8 +33,7 @@ define concat::fragment( $ensure = 'present', $mode = '0644', $owner = $::id, - $group = undef, - $backup = 'puppet' + $group = undef ) { validate_absolute_path($target) validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') @@ -44,7 +43,6 @@ define concat::fragment( validate_string($mode) validate_string($owner) validate_string($group) - validate_string($backup) include concat::setup @@ -78,7 +76,7 @@ define concat::fragment( group => $safe_group, source => $source, content => $content, - backup => $backup, + backup => false, alias => "concat_fragment_${name}", notify => Exec["concat_${target}"] } diff --git a/manifests/init.pp b/manifests/init.pp index f32cfff..f0356f7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -126,8 +126,8 @@ define concat( owner => $owner, group => $safe_group, mode => $mode, - backup => $backup, - replace => $replace + replace => $replace, + backup => false, } if $ensure == 'present' { @@ -157,6 +157,7 @@ define concat( path => $path, alias => "concat_${name}", source => "${fragdir}/${concat_name}", + backup => $backup, } # remove extra whitespace from string interopolation to make testing easier @@ -190,12 +191,12 @@ define concat( "${fragdir}/${concat_name}" ]: ensure => absent, - backup => false, force => true, } file { $name: ensure => absent, + backup => $backup, } exec { "concat_${name}": diff --git a/manifests/setup.pp b/manifests/setup.pp index f3793b2..0359f2b 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -26,6 +26,10 @@ class concat::setup { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } + File { + backup => false, + } + file { "${concatdir}/bin/concatfragments.sh": owner => $owner, group => $root_group, diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index f502713..a000c06 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -14,6 +14,7 @@ describe 'concat::setup', :type => :class do :group => id == 'root' ? 0 : id, :mode => '0755', :source => 'puppet:///modules/concat/concatfragments.sh', + :backup => false, }) end @@ -24,6 +25,7 @@ describe 'concat::setup', :type => :class do :owner => id, :group => id == 'root' ? 0 : id, :mode => '0750', + :backup => false, }) end end @@ -31,6 +33,7 @@ describe 'concat::setup', :type => :class do it do should contain_file('/usr/local/bin/concatfragments.sh').with({ :ensure => 'absent', + :backup => false, }) end end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 296631f..b7147b2 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -50,8 +50,8 @@ describe 'concat::fragment', :type => :define do :group => safe_group, :source => p[:source], :content => p[:content], - :backup => p[:backup], :alias => "concat_fragment_#{title}", + :backup => false, }) end end @@ -217,23 +217,4 @@ describe 'concat::fragment', :type => :define do end end # group => - context 'backup =>' do - context 'apenny' do - it_behaves_like 'fragment', 'motd_header', { - :backup => 'apenny', - :target => '/etc/motd', - } - end - - context 'false' do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} - let(:params) {{ :backup => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # backup => - end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index f8cb8f6..5ec0786 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -33,7 +33,7 @@ describe 'concat', :type => :define do :owner => p[:owner], :group => p[:group], :mode => p[:mode], - :backup => p[:backup], + :backup => false, :replace => p[:replace], } @@ -80,6 +80,7 @@ describe 'concat', :type => :define do :path => p[:path], :alias => "concat_#{title}", :source => "#{fragdir}/#{concat_name}", + :backup => p[:backup], })) end @@ -130,12 +131,7 @@ describe 'concat', :type => :define do it do should contain_file(title).with(file_defaults.merge({ :ensure => 'absent', - })) - end - - it do - should contain_file(title).with(file_defaults.merge({ - :ensure => 'absent', + :backup => p[:backup], })) end From aa0180d69ab45fca3310cc5344d0bf153cfd9d83 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 24 Oct 2013 08:48:37 -0700 Subject: [PATCH 038/202] remove default owner/user and group values The use of $::id to set the default user/owner and group has caused multiple bugs in the past, is incorrectly used to infer the egid, introduces a dependency on the `id` fact, and provides no functionally that can't be accomplished by passing `undef` or not setting the respective params on the file & exec types. A possible alternative would be to introduce a dep on the $::gid fact but that would mean the entire module would depend on a version of facter than hasn't shipped yet (unworkable) or to add a gid/egid fact into this module (ugly). --- manifests/fragment.pp | 9 ++---- manifests/init.pp | 21 ++++---------- manifests/setup.pp | 12 +------- spec/unit/classes/concat_setup_spec.rb | 26 ++++------------- spec/unit/defines/concat_fragment_spec.rb | 34 ++++++++--------------- spec/unit/defines/concat_spec.rb | 22 ++++----------- 6 files changed, 29 insertions(+), 95 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 1f90b38..a3d0101 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -32,7 +32,7 @@ define concat::fragment( $order = 10, $ensure = 'present', $mode = '0644', - $owner = $::id, + $owner = undef, $group = undef ) { validate_absolute_path($target) @@ -51,11 +51,6 @@ define concat::fragment( $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_target_name}" - $safe_group = $group ? { - undef => $concat::setup::root_group, - default => $group, - } - # if content is passed, use that, else if source is passed use that # if neither passed, but $ensure is in symlink form, make a symlink case $ensure { @@ -73,7 +68,7 @@ define concat::fragment( ensure => $ensure, mode => $mode, owner => $owner, - group => $safe_group, + group => $group, source => $source, content => $content, backup => false, diff --git a/manifests/init.pp b/manifests/init.pp index f0356f7..6396605 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,7 +55,7 @@ define concat( $ensure = 'present', $path = $name, - $owner = $::id, + $owner = undef, $group = undef, $mode = '0644', $warn = false, @@ -87,11 +87,6 @@ define concat( $concat_name = 'fragments.concat.out' $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' - $safe_group = $group ? { - undef => $concat::setup::root_group, - default => $group, - } - if $warn == true { $use_warn_message = $warn_message ? { undef => $default_warn_message, @@ -124,7 +119,7 @@ define concat( File { owner => $owner, - group => $safe_group, + group => $group, mode => $mode, replace => $replace, backup => false, @@ -166,6 +161,8 @@ define concat( exec { "concat_${name}": alias => "concat_${fragdir}", command => $command, + user => $owner, + group => $group, notify => File[$name], subscribe => File[$fragdir], unless => "${command} -t", @@ -175,15 +172,7 @@ define concat( File["${fragdir}/fragments.concat"], ], } - - if $::id == 'root' { - Exec["concat_${name}"] { - user => root, - group => $safe_group, - } - } - } - else { + } else { file { [ $fragdir, "${fragdir}/fragments", diff --git a/manifests/setup.pp b/manifests/setup.pp index 0359f2b..2e744e1 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -14,12 +14,6 @@ class concat::setup { fail("Use of private class ${name} by ${caller_module_name}") } - $owner = $::id - $root_group = $owner ? { - root => 0, - default => $owner - } - if $::concat_basedir { $concatdir = $::concat_basedir } else { @@ -31,17 +25,13 @@ class concat::setup { } file { "${concatdir}/bin/concatfragments.sh": - owner => $owner, - group => $root_group, mode => '0755', source => 'puppet:///modules/concat/concatfragments.sh', } file { [ $concatdir, "${concatdir}/bin" ]: ensure => directory, - owner => $owner, - group => $root_group, - mode => '0750', + mode => '0755', } ## Old versions of this module used a different path. diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index a000c06..47c4069 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -2,16 +2,13 @@ require 'spec_helper' describe 'concat::setup', :type => :class do - shared_examples 'setup' do |id, concatdir| - id = 'root' if id.nil? + shared_examples 'setup' do |concatdir| concatdir = '/foo' if concatdir.nil? - let(:facts) {{ :id => id, :concat_basedir => concatdir }} + let(:facts) {{ :concat_basedir => concatdir }} it do should contain_file("#{concatdir}/bin/concatfragments.sh").with({ - :owner => id, - :group => id == 'root' ? 0 : id, :mode => '0755', :source => 'puppet:///modules/concat/concatfragments.sh', :backup => false, @@ -22,9 +19,7 @@ describe 'concat::setup', :type => :class do it do should contain_file(file).with({ :ensure => 'directory', - :owner => id, - :group => id == 'root' ? 0 : id, - :mode => '0750', + :mode => '0755', :backup => false, }) end @@ -45,23 +40,12 @@ describe 'concat::setup', :type => :class do "$caller_module_name = 'concat'" end - context 'id =>' do - context 'root' do - it_behaves_like 'setup', 'root' - end - - context 'apenny' do - it_behaves_like 'setup', 'apenny' - end - end - context 'concat_basedir =>' do context '/foo' do - it_behaves_like 'setup', 'root', '/foo' + it_behaves_like 'setup', '/foo' end context 'undef' do - let(:facts) {{ :id => 'root' }} it 'should fail' do expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')}/) end @@ -71,7 +55,7 @@ describe 'concat::setup', :type => :class do end # facts context 'called from another module namespace' do - let(:facts) {{ :id => 'root', :concat_basedir => '/foo' }} + let(:facts) {{ :concat_basedir => '/foo' }} it 'should fail' do expect { should }.to raise_error(Puppet::Error, /Use of private class concat::setup/) end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index b7147b2..57d9ecf 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -5,15 +5,13 @@ describe 'concat::fragment', :type => :define do shared_examples 'fragment' do |title, params| params = {} if params.nil? - id = 'root' - p = { :content => nil, :source => nil, :order => 10, :ensure => 'present', :mode => '0644', - :owner => id, + :owner => nil, :group => nil, :backup => 'puppet', }.merge(params) @@ -22,19 +20,9 @@ describe 'concat::fragment', :type => :define do safe_target_name = p[:target].gsub(/[\/\n]/, '_') concatdir = '/var/lib/puppet/concat' fragdir = "#{concatdir}/#{safe_target_name}" - if p[:group].nil? - safe_group = id == 'root' ? 0 : id - else - safe_group = p[:group] - end let(:title) { title } - let(:facts) do - { - :concat_basedir => concatdir, - :id => id, - } - end + let(:facts) {{ :concat_basedir => concatdir }} let(:params) { params } let(:pre_condition) do "concat{ '#{p[:target]}': }" @@ -47,7 +35,7 @@ describe 'concat::fragment', :type => :define do :ensure => p[:ensure], :mode => p[:mode], :owner => p[:owner], - :group => safe_group, + :group => p[:group], :source => p[:source], :content => p[:content], :alias => "concat_fragment_#{title}", @@ -66,7 +54,7 @@ describe 'concat::fragment', :type => :define do ['./etc/motd', 'etc/motd', false].each do |target| context target do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :target => target }} it 'should fail' do @@ -88,7 +76,7 @@ describe 'concat::fragment', :type => :define do context 'invalid' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} it 'should fail' do @@ -109,7 +97,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :content => false, :target => '/etc/motd' }} it 'should fail' do @@ -130,7 +118,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :source => false, :target => '/etc/motd' }} it 'should fail' do @@ -151,7 +139,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :order => false, :target => '/etc/motd' }} it 'should fail' do @@ -170,7 +158,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :mode => false, :target => '/etc/motd' }} it 'should fail' do @@ -189,7 +177,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :owner => false, :target => '/etc/motd' }} it 'should fail' do @@ -208,7 +196,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }} + let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :group => false, :target => '/etc/motd' }} it 'should fail' do diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 5ec0786..7e69b4f 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -5,14 +5,12 @@ describe 'concat', :type => :define do shared_examples 'concat' do |title, params| params = {} if params.nil? - id = 'root' - # default param values p = { :ensure => 'present', :path => title, - :owner => id, - :group => '0', + :owner => nil, + :group => nil, :mode => '0644', :warn => false, :warn_message => nil, @@ -39,12 +37,7 @@ describe 'concat', :type => :define do let(:title) { title } let(:params) { params } - let(:facts) do - { - :concat_basedir => concatdir, - :id => id, - } - end + let(:facts) {{ :concat_basedir => concatdir }} if p[:ensure] == 'present' it do @@ -102,15 +95,10 @@ describe 'concat', :type => :define do should contain_exec("concat_#{title}").with({ :alias => "concat_#{fragdir}", :command => cmd, + :user => p[:owner], + :group => p[:group], :unless => "#{cmd} -t", }) - - if id == 'root' - should contain_exec("concat_#{title}").with({ - :user => 'root', - :group => p[:group], - }) - end end else [ From 2ec19b80f909ac7be8b3c626d80f08a6ee307987 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 24 Oct 2013 09:34:31 -0700 Subject: [PATCH 039/202] remove purging of /usr/local/bin/concatfragments.sh The hard coded path of `/usr/local/bin/concatfragments.sh` hasn't been used for "a long time" so there's no reason to carry the cleanup around any longer. --- manifests/setup.pp | 6 ------ spec/unit/classes/concat_setup_spec.rb | 7 ------- 2 files changed, 13 deletions(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index 2e744e1..35f0a42 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -33,10 +33,4 @@ class concat::setup { ensure => directory, mode => '0755', } - - ## Old versions of this module used a different path. - file { '/usr/local/bin/concatfragments.sh': - ensure => absent, - } - } diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 47c4069..f41fa2a 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -24,13 +24,6 @@ describe 'concat::setup', :type => :class do }) end end - - it do - should contain_file('/usr/local/bin/concatfragments.sh').with({ - :ensure => 'absent', - :backup => false, - }) - end end context 'facts' do From ac9bb8d853283ec37b7341c43ee097f409d044b9 Mon Sep 17 00:00:00 2001 From: Paul Chechetin Date: Wed, 16 Oct 2013 13:07:31 +0400 Subject: [PATCH 040/202] Replace LANG => LC_ALL --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 570d553..88fe0e7 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -121,7 +121,7 @@ fi IFS_BACKUP=$IFS IFS=' ' -for fragfile in `find fragments/ -type f -follow | LANG=C sort ${SORTARG}` +for fragfile in `find fragments/ -type f -follow | LC_ALL=C sort ${SORTARG}` do cat $fragfile >> "fragments.concat" done From b09be245d45669975e4b53f647529c13cbe5cd1d Mon Sep 17 00:00:00 2001 From: Luis Fernandez Alvarez Date: Mon, 2 Sep 2013 13:49:40 +0200 Subject: [PATCH 041/202] Add Windows support - It adds a ruby version of the bash script. - Refactor setup.pp to include new variables. - Generalizes command execution according to variables in setup.pp. --- files/concatfragments.rb | 138 +++++++++++++++++++++++++++++++++++++++ manifests/fragment.pp | 4 +- manifests/init.pp | 20 ++++-- manifests/setup.pp | 16 ++++- 4 files changed, 170 insertions(+), 8 deletions(-) create mode 100755 files/concatfragments.rb diff --git a/files/concatfragments.rb b/files/concatfragments.rb new file mode 100755 index 0000000..5f267a4 --- /dev/null +++ b/files/concatfragments.rb @@ -0,0 +1,138 @@ +# Script to concat files to a config file. +# +# Given a directory like this: +# /path/to/conf.d +# |-- fragments +# | |-- 00_named.conf +# | |-- 10_domain.net +# | `-- zz_footer +# +# The script supports a test option that will build the concat file to a temp location and +# use /usr/bin/cmp to verify if it should be run or not. This would result in the concat happening +# twice on each run but gives you the option to have an unless option in your execs to inhibit rebuilds. +# +# Without the test option and the unless combo your services that depend on the final file would end up +# restarting on each run, or in other manifest models some changes might get missed. +# +# OPTIONS: +# -o The file to create from the sources +# -d The directory where the fragments are kept +# -t Test to find out if a build is needed, basically concats the files to a temp +# location and compare with what's in the final location, return codes are designed +# for use with unless on an exec resource +# -w Add a shell style comment at the top of the created file to warn users that it +# is generated by puppet +# -f Enables the creation of empty output files when no fragments are found +# -n Sort the output numerically rather than the default alpha sort +# +# the command: +# +# concatfragments.rb -o /path/to/conffile.cfg -d /path/to/conf.d +# +# creates /path/to/conf.d/fragments.concat and copies the resulting +# file to /path/to/conffile.cfg. The files will be sorted alphabetically +# pass the -n switch to sort numerically. +# +# The script does error checking on the various dirs and files to make +# sure things don't fail. +require 'optparse' +require 'fileutils' + +settings = { + :outfile => "", + :workdir => "", + :test => false, + :force => false, + :warn => "", + :sortarg => "" +} + +OptionParser.new do |opts| + opts.banner = "Usage: #{$0} [options]" + opts.separator "" + opts.separator "Specific options:" + + opts.on("-o", "--outfile OUTFILE", String, "The file to create from the sources") do |o| + settings[:outfile] = o + end + + opts.on("-d", "--workdir WORKDIR", String, "The directory where the fragments are kept") do |d| + settings[:workdir] = d + end + + opts.on("-t", "--test", "Test to find out if a build is needed") do + settings[:test] = true + end + + opts.separator "Other options:" + opts.on("-w", "--warn WARNMSG", String, + "Add a shell style comment at the top of the created file to warn users that it is generated by puppet") do |w| + settings[:warn] = w + end + + opts.on("-f", "--force", "Enables the creation of empty output files when no fragments are found") do + settings[:force] = true + end + + opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do + settings[:sortarg] = "-n" + end +end.parse! + +# do we have -o? +raise 'Please specify an output file with -o' unless !settings[:outfile].empty? + +# do we have -d? +raise 'Please specify fragments directory with -d' unless !settings[:workdir].empty? + +# can we write to -o? +if File.file?(settings[:outfile]) + if !File.writable?(settings[:outfile]) + raise "Cannot write to #{settings[:outfile]}" + end +else + if !File.writable?(File.dirname(settings[:outfile])) + raise "Cannot write to dirname #{File.dirname(settings[:outfile])} to create #{settings[:outfile]}" + end +end + +# do we have a fragments subdir inside the work dir? +if !File.directory?(File.join(settings[:workdir], "fragments")) && !File.executable?(File.join(settings[:workdir], "fragments")) + raise "Cannot access the fragments directory" +end + +# are there actually any fragments? +if (Dir.entries(File.join(settings[:workdir], "fragments")) - %w{ . .. }).empty? + if !settings[:force] + raise "The fragments directory is empty, cowardly refusing to make empty config files" + end +end + +Dir.chdir(settings[:workdir]) + +if settings[:warn].empty? + File.open("fragments.concat", 'w') {|f| f.write("") } +else + File.open("fragments.concat", 'w') {|f| f.write("#{settings[:warn]}\n") } +end + +# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir +open('fragments.concat', 'a') do |f| + Dir.entries("fragments").sort.each{ |entry| + if File.file?(File.join("fragments", entry)) + f << File.read(File.join("fragments", entry)) + end + } +end + +if !settings[:test] + # This is a real run, copy the file to outfile + FileUtils.cp 'fragments.concat', settings[:outfile] +else + # Just compare the result to outfile to help the exec decide + if FileUtils.cmp 'fragments.concat', settings[:outfile] + exit 0 + else + exit 1 + end +end diff --git a/manifests/fragment.pp b/manifests/fragment.pp index a3d0101..0fb6099 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -46,8 +46,8 @@ define concat::fragment( include concat::setup - $safe_name = regsubst($name, '[/\n]', '_', 'GM') - $safe_target_name = regsubst($target, '[/\n]', '_', 'GM') + $safe_name = regsubst($name, '[/:\n]', '_', 'GM') + $safe_target_name = regsubst($target, '[/:\n]', '_', 'GM') $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_target_name}" diff --git a/manifests/init.pp b/manifests/init.pp index 6396605..4a4a480 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -81,10 +81,11 @@ define concat( include concat::setup - $safe_name = regsubst($name, '/', '_', 'G') + $safe_name = regsubst($name, '[/:]', '_', 'G') $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_name}" $concat_name = 'fragments.concat.out' + $script_command = $concat::setup::script_command $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' if $warn == true { @@ -156,7 +157,7 @@ define concat( } # remove extra whitespace from string interopolation to make testing easier - $command = strip(regsubst("${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + $command = strip(regsubst("${script_command} -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) exec { "concat_${name}": alias => "concat_${fragdir}", @@ -166,6 +167,7 @@ define concat( notify => File[$name], subscribe => File[$fragdir], unless => "${command} -t", + path => $::path, require => [ File[$fragdir], File["${fragdir}/fragments"], @@ -188,10 +190,20 @@ define concat( backup => $backup, } + $absent_exec_command = $::kernel ? { + 'windows' => 'cmd.exe /c exit 0', + default => 'true', + } + + $absent_exec_path = $::kernel ? { + 'windows' => $::path, + default => '/bin:/usr/bin', + } + exec { "concat_${name}": alias => "concat_${fragdir}", - command => 'true', - path => '/bin:/usr/bin' + command => $absent_exec_command, + path => $absent_exec_path } } } diff --git a/manifests/setup.pp b/manifests/setup.pp index 35f0a42..fbb7be6 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -20,13 +20,25 @@ class concat::setup { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } + $script_name = $::kernel ? { + 'windows' => "concatfragments.rb", + default => "concatfragments.sh" + } + + $script_path = "${concatdir}/bin/${script_name}" + + $script_command = $::kernel ? { + 'windows' => "ruby.exe ${script_path}", + default => $script_path + } + File { backup => false, } - file { "${concatdir}/bin/concatfragments.sh": + file { $script_path: mode => '0755', - source => 'puppet:///modules/concat/concatfragments.sh', + source => "puppet:///modules/concat/${script_name}", } file { [ $concatdir, "${concatdir}/bin" ]: From 99384037d6d6b1e1ffff5c0058f635fcb458a3c2 Mon Sep 17 00:00:00 2001 From: Luis Fernandez Alvarez Date: Mon, 28 Oct 2013 09:03:30 +0100 Subject: [PATCH 042/202] Removed duplicated opts.separator call in concatfragments.rb --- files/concatfragments.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/files/concatfragments.rb b/files/concatfragments.rb index 5f267a4..73fd7f9 100755 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -49,7 +49,6 @@ settings = { OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" - opts.separator "" opts.separator "Specific options:" opts.on("-o", "--outfile OUTFILE", String, "The file to create from the sources") do |o| From 7c4f929e42996d424aebaceaaabba7a9fb7e36e2 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 29 Oct 2013 15:39:54 -0700 Subject: [PATCH 043/202] add deprecation warnings on removed parameters + warn on inclusion of concat::setup --- manifests/fragment.pp | 9 ++-- manifests/init.pp | 8 +++- manifests/setup.pp | 2 +- spec/system/deprecation_warnings_spec.rb | 51 +++++++++++++++++++++++ spec/unit/classes/concat_setup_spec.rb | 20 --------- spec/unit/defines/concat_fragment_spec.rb | 11 +++++ spec/unit/defines/concat_spec.rb | 8 ++++ 7 files changed, 84 insertions(+), 25 deletions(-) create mode 100644 spec/system/deprecation_warnings_spec.rb diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 0fb6099..3382e16 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -22,8 +22,7 @@ # [*group*] # Owner of the file # [*backup*] -# Controls the filebucketing behavior of the final file and see File type -# reference for its use. Defaults to 'puppet' +# Deprecated # define concat::fragment( $target, @@ -33,7 +32,8 @@ define concat::fragment( $ensure = 'present', $mode = '0644', $owner = undef, - $group = undef + $group = undef, + $backup = undef ) { validate_absolute_path($target) validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') @@ -43,6 +43,9 @@ define concat::fragment( validate_string($mode) validate_string($owner) validate_string($group) + if $backup { + warning('The $backup parameter to concat::fragment is deprecated and has no effect') + } include concat::setup diff --git a/manifests/init.pp b/manifests/init.pp index 4a4a480..774113c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,6 +31,8 @@ # Whether to replace a file that already exists on the local system # [*order*] # [*ensure_newline*] +# [*gnu*] +# Deprecated # # === Actions: # * Creates fragment directories if it didn't exist already @@ -64,7 +66,8 @@ define concat( $backup = 'puppet', $replace = true, $order = 'alpha', - $ensure_newline = false + $ensure_newline = false, + $gnu = undef, ) { validate_re($ensure, '^present$|^absent$') validate_absolute_path($path) @@ -78,6 +81,9 @@ define concat( validate_bool($replace) validate_re($order, '^alpha$|^numeric$') validate_bool($ensure_newline) + if $gnu { + warning('The $gnu parameter to concat is deprecated and has no effect') + } include concat::setup diff --git a/manifests/setup.pp b/manifests/setup.pp index fbb7be6..de67164 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -11,7 +11,7 @@ # class concat::setup { if $caller_module_name != $module_name { - fail("Use of private class ${name} by ${caller_module_name}") + warning("${name} is deprecated as a public API of the ${module_name} module and should no longer be directly included in the manifest.") } if $::concat_basedir { diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb new file mode 100644 index 0000000..f4b3a56 --- /dev/null +++ b/spec/system/deprecation_warnings_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper_system' + +describe 'deprecation warnings' do + + shared_examples 'has_warning'do |pp, w| + context puppet_apply(pp) do + its(:stderr) { should =~ /#{Regexp.escape(w)}/m } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should =~ /#{Regexp.escape(w)}/m } + its(:exit_code) { should be_zero } + end + end + + context 'concat gnu parameter' do + pp=" + concat { '/tmp/file': + gnu => 'foo', + } + concat::fragment { 'foo': + target => '/tmp/file', + } + " + w = 'The $gnu parameter to concat is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment backup parameter' do + pp=" + concat { '/tmp/file': } + concat::fragment { 'foo': + target => '/tmp/file', + backup => 'bar', + } + " + w = 'The $backup parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'include concat::setup' do + pp=" + include concat::setup + " + w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.' + + it_behaves_like 'has_warning', pp, w + end + +end diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index f41fa2a..5ddf9b1 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -27,30 +27,10 @@ describe 'concat::setup', :type => :class do end context 'facts' do - # concat::setup is a private module so we need pretend that we are calling - # it from elsewhere in the same module - let(:pre_condition) do - "$caller_module_name = 'concat'" - end - context 'concat_basedir =>' do context '/foo' do it_behaves_like 'setup', '/foo' end - - context 'undef' do - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')}/) - end - end end - end # facts - - context 'called from another module namespace' do - let(:facts) {{ :concat_basedir => '/foo' }} - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /Use of private class concat::setup/) - end - end end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 57d9ecf..ebb0807 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -205,4 +205,15 @@ describe 'concat::fragment', :type => :define do end end # group => + # should raise a warning but rspec-puppet can't presently test for warning() + # we can only test for the existence of the parameter + context 'backup =>' do + context 'foo' do + it_behaves_like 'fragment', 'motd_header', { + :backup => 'foo', + :target => '/etc/motd', + } + end + end # backup => + end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 7e69b4f..33b9beb 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -361,6 +361,14 @@ describe 'concat', :type => :define do end end # ensure_newline => + # should raise a warning but rspec-puppet can't presently test for warning() + # we can only test for the existence of the parameter + context 'gnu =>' do + context 'foo' do + it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'} + end + end + end # vim:sw=2:ts=2:expandtab:textwidth=79 From 200e4ee2051d91bc623396defb3dbdfb7fa5c0f9 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 29 Oct 2013 21:44:14 -0700 Subject: [PATCH 044/202] always exec the concatfragments script as root when running as root This is to allow the concatfragments script to be installed into a path that may not be accessible by a non-root user. --- manifests/init.pp | 7 +-- spec/system/concat_spec.rb | 73 +++++++++++++++++++++++--------- spec/unit/defines/concat_spec.rb | 11 +++-- 3 files changed, 64 insertions(+), 27 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 774113c..87f2768 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -162,14 +162,15 @@ define concat( backup => $backup, } - # remove extra whitespace from string interopolation to make testing easier + # remove extra whitespace from string interpolation to make testing easier $command = strip(regsubst("${script_command} -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + # if puppet is running as root, this exec should also run as root to allow + # the concatfragments.sh script to potentially be installed in path that + # may not be accessible by a target non-root owner. exec { "concat_${name}": alias => "concat_${fragdir}", command => $command, - user => $owner, - group => $group, notify => File[$name], subscribe => File[$fragdir], unless => "${command} -t", diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb index af360d6..b3b7350 100644 --- a/spec/system/concat_spec.rb +++ b/spec/system/concat_spec.rb @@ -1,27 +1,8 @@ require 'spec_helper_system' describe 'basic concat test' do - context 'should run successfully' do - pp=" - concat { '/tmp/file': - owner => root, - group => root, - mode => '0644', - } - - concat::fragment { '1': - target => '/tmp/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '/tmp/file', - content => '2', - order => '02', - } - " + shared_examples 'concat' do |pp| context puppet_apply(pp) do its(:stderr) { should be_empty } its(:exit_code) { should_not == 1 } @@ -50,6 +31,58 @@ describe 'basic concat test' do describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do it { should be_file } end + end + context 'owner/group root' do + pp=" + concat { '/tmp/file': + owner => 'root', + group => 'root', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + it_behaves_like 'concat', pp + end + + context 'owner/group non-root' do + before(:all) do + shell "groupadd -g 42 bob" + shell "useradd -u 42 -g 42 bob" + end + + pp=" + concat { '/tmp/file': + owner => 'bob', + group => 'bob', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + it_behaves_like 'concat', pp end end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 33b9beb..ddbd21a 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' describe 'concat', :type => :define do - shared_examples 'concat' do |title, params| + shared_examples 'concat' do |title, params, id| params = {} if params.nil? + id = 'root' if id.nil? # default param values p = { @@ -37,7 +38,7 @@ describe 'concat', :type => :define do let(:title) { title } let(:params) { params } - let(:facts) {{ :concat_basedir => concatdir }} + let(:facts) {{ :concat_basedir => concatdir, :id => id }} if p[:ensure] == 'present' it do @@ -95,8 +96,6 @@ describe 'concat', :type => :define do should contain_exec("concat_#{title}").with({ :alias => "concat_#{fragdir}", :command => cmd, - :user => p[:owner], - :group => p[:group], :unless => "#{cmd} -t", }) end @@ -162,6 +161,10 @@ describe 'concat', :type => :define do end end # title => + context 'as non-root user' do + it_behaves_like 'concat', '/etc/foo.bar', {}, 'bob' + end + context 'ensure =>' do ['present', 'absent'].each do |ens| context ens do From 256e0bdf9fd5f3e546e2e80b8578af66c5d91e1f Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 1 Nov 2013 18:20:41 -0700 Subject: [PATCH 045/202] remove usage of resource defaults for file owner/permissions In addition, the permissions of the fragment directory and files is now fixed and not world readable. --- manifests/fragment.pp | 2 +- manifests/init.pp | 22 +++--- manifests/setup.pp | 2 + spec/system/concat_spec.rb | 88 ++++++++++++++++++++--- spec/unit/defines/concat_fragment_spec.rb | 2 +- spec/unit/defines/concat_spec.rb | 21 +++--- 6 files changed, 106 insertions(+), 31 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 3382e16..644ef68 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -30,7 +30,7 @@ define concat::fragment( $source = undef, $order = 10, $ensure = 'present', - $mode = '0644', + $mode = '0640', $owner = undef, $group = undef, $backup = undef diff --git a/manifests/init.pp b/manifests/init.pp index 87f2768..fde0e8e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -125,20 +125,18 @@ define concat( } File { - owner => $owner, - group => $group, - mode => $mode, - replace => $replace, backup => false, } if $ensure == 'present' { file { $fragdir: ensure => directory, + mode => '0750', } file { "${fragdir}/fragments": ensure => directory, + mode => '0750', force => true, ignore => ['.svn', '.git', '.gitignore'], notify => Exec["concat_${name}"], @@ -148,18 +146,24 @@ define concat( file { "${fragdir}/fragments.concat": ensure => present, + mode => '0640', } file { "${fragdir}/${concat_name}": ensure => present, + mode => '0640', } file { $name: - ensure => present, - path => $path, - alias => "concat_${name}", - source => "${fragdir}/${concat_name}", - backup => $backup, + ensure => present, + owner => $owner, + group => $group, + mode => $mode, + replace => $replace, + path => $path, + alias => "concat_${name}", + source => "${fragdir}/${concat_name}", + backup => $backup, } # remove extra whitespace from string interpolation to make testing easier diff --git a/manifests/setup.pp b/manifests/setup.pp index de67164..83d8a8c 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -37,6 +37,8 @@ class concat::setup { } file { $script_path: + ensure => file, + owner => $::id, mode => '0755', source => "puppet:///modules/concat/${script_name}", } diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb index b3b7350..55c8e3b 100644 --- a/spec/system/concat_spec.rb +++ b/spec/system/concat_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_system' describe 'basic concat test' do - shared_examples 'concat' do |pp| + shared_examples 'successfully_applied' do |pp| context puppet_apply(pp) do its(:stderr) { should be_empty } its(:exit_code) { should_not == 1 } @@ -11,25 +11,47 @@ describe 'basic concat test' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do - it { should be_file } - it { should contain '1' } - it { should contain '2' } - end - - # Test that all the relevant bits exist on disk after it - # concats. describe file('/var/lib/puppet/concat') do it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + describe file('/var/lib/puppet/concat/bin') do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + describe file('/var/lib/puppet/concat/bin/concatfragments.sh') do + it { should be_file } + it { should be_owned_by 'root' } + #it { should be_grouped_into 'root' } + it { should be_mode 755 } end describe file('/var/lib/puppet/concat/_tmp_file') do it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 750 } end describe file('/var/lib/puppet/concat/_tmp_file/fragments') do it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 750 } end describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat.out') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } end end @@ -54,7 +76,28 @@ describe 'basic concat test' do } " - it_behaves_like 'concat', pp + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/file') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end end context 'owner/group non-root' do @@ -83,6 +126,29 @@ describe 'basic concat test' do } " - it_behaves_like 'concat', pp + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/file') do + it { should be_file } + it { should be_owned_by 'bob' } + it { should be_grouped_into 'bob' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + it { should contain '1' } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + it { should contain '2' } + end end end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index ebb0807..7e4fe0a 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -10,7 +10,7 @@ describe 'concat::fragment', :type => :define do :source => nil, :order => 10, :ensure => 'present', - :mode => '0644', + :mode => '0640', :owner => nil, :group => nil, :backup => 'puppet', diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index ddbd21a..8d74510 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -29,11 +29,7 @@ describe 'concat', :type => :define do default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' file_defaults = { - :owner => p[:owner], - :group => p[:group], - :mode => p[:mode], :backup => false, - :replace => p[:replace], } let(:title) { title } @@ -44,12 +40,14 @@ describe 'concat', :type => :define do it do should contain_file(fragdir).with(file_defaults.merge({ :ensure => 'directory', + :mode => '0750', })) end it do should contain_file("#{fragdir}/fragments").with(file_defaults.merge({ :ensure => 'directory', + :mode => '0750', :force => true, :ignore => ['.svn', '.git', '.gitignore'], :purge => true, @@ -64,17 +62,22 @@ describe 'concat', :type => :define do it do should contain_file(file).with(file_defaults.merge({ :ensure => 'present', + :mode => '0640', })) end end it do should contain_file(title).with(file_defaults.merge({ - :ensure => 'present', - :path => p[:path], - :alias => "concat_#{title}", - :source => "#{fragdir}/#{concat_name}", - :backup => p[:backup], + :ensure => 'present', + :owner => p[:owner], + :group => p[:group], + :mode => p[:mode], + :replace => p[:replace], + :path => p[:path], + :alias => "concat_#{title}", + :source => "#{fragdir}/#{concat_name}", + :backup => p[:backup], })) end From c73b01922686eb7f7100b89bec0253cead5c14d3 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 1 Nov 2013 18:32:02 -0700 Subject: [PATCH 046/202] remove dead files --- .gemfile | 7 ------- files/null/.gitignore | 0 2 files changed, 7 deletions(-) delete mode 100644 .gemfile delete mode 100644 files/null/.gitignore diff --git a/.gemfile b/.gemfile deleted file mode 100644 index d4241e8..0000000 --- a/.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -source :rubygems - -puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] -gem 'puppet', puppetversion -gem 'puppet-lint' -gem 'rspec-puppet' -gem 'puppetlabs_spec_helper', '>= 0.1.0' diff --git a/files/null/.gitignore b/files/null/.gitignore deleted file mode 100644 index e69de29..0000000 From e3b845205572d15e5fa89eeacc73415d2d29c5cb Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 1 Nov 2013 18:32:26 -0700 Subject: [PATCH 047/202] rename README.markdown -> README.md For better consistency with other PuppetLabs' modules --- README | 91 ------------------------------------ README.markdown => README.md | 0 2 files changed, 91 deletions(-) delete mode 100644 README rename README.markdown => README.md (100%) diff --git a/README b/README deleted file mode 100644 index 650141c..0000000 --- a/README +++ /dev/null @@ -1,91 +0,0 @@ -== Module: concat - -A system to construct files using fragments from other files or templates. - -This requires at least puppet 0.25 to work correctly as we use some -enhancements in recursive directory management and regular expressions -to do the work here. - -=== Usage: - -The basic use case is as below: - - concat{"/etc/named.conf": - notify => Service["named"] - } - - concat::fragment{"foo.com_config": - target => "/etc/named.conf", - order => 10, - content => template("named_conf_zone.erb") - } - - # add a fragment not managed by puppet so local users - # can add content to managed file - concat::fragment{"foo.com_user_config": - target => "/etc/named.conf", - order => 12, - ensure => "/etc/named.conf.local" - } - -This will use the template named_conf_zone.erb to build a single -bit of config up and put it into the fragments dir. The file -will have an number prefix of 10, you can use the order option -to control that and thus control the order the final file gets built in. - -You can also specify a path and use a different name for your resources: - - # You can make this something dynamic, based on whatever parameters your - # module/class for example. - $vhost_file = '/etc/httpd/vhosts/01-my-vhost.conf' - - concat{'apache-vhost-myvhost': - path => $vhost_file, - } - - # We don't care where the file is located, just what to put in it. - concat::fragment {'apache-vhost-myvhost-main': - target => 'apache-vhost-myvhost', - content => '', - order => 01, - } - - concat::fragment {'apache-vhost-myvhost-close': - target => 'apache-vhost-myvhost', - content => '', - order => 99, - } - -=== Setup: - -The class concat::setup uses the fact concat_basedir to define the variable -$concatdir, where all the temporary files and fragments will be -durably stored. The fact concat_basedir will be set up on the client to -/concat, so you will be able to run different setup/flavours -of puppet clients. -However, since this requires the file lib/facter/concat_basedir.rb to be -deployed on the clients, so you will have to set "pluginsync = true" on -both the master and client, at least for the first run. - -There's some regular expression magic to figure out the puppet version but -if you're on an older 0.24 version just set $puppetversion = 24 - -=== Detail: - -We use a helper shell script called concatfragments.sh that gets placed -in /concat/bin to do the concatenation. While this might -seem more complex than some of the one-liner alternatives you might find on -the net we do a lot of error checking and safety checks in the script to avoid -problems that might be caused by complex escaping errors etc. - -=== License: - -Apache Version 2 - -=== Latest: - -http://github.com/puppetlabs/puppetlabs-concat/ - -=== Contact: - -Puppetlabs, via our puppet-users@ mailing list. diff --git a/README.markdown b/README.md similarity index 100% rename from README.markdown rename to README.md From b6e9b1c693d1590b566563e2491748b60cab9a94 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 1 Nov 2013 18:52:59 -0700 Subject: [PATCH 048/202] fix or suppress all lint warnings --- Rakefile | 4 ++++ manifests/init.pp | 2 +- manifests/setup.pp | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index bb60173..edd0a23 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,6 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'rspec-system/rake_task' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_quoted_booleans') diff --git a/manifests/init.pp b/manifests/init.pp index 774113c..8987600 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -103,7 +103,7 @@ define concat( $use_warn_message = undef } - $warnmsg_escaped = regsubst($use_warn_message, "'", "'\\\\''", 'G') + $warnmsg_escaped = regsubst($use_warn_message, '\'', '\'\\\'\'', 'G') $warnflag = $warnmsg_escaped ? { '' => '', default => "-w '${warnmsg_escaped}'" diff --git a/manifests/setup.pp b/manifests/setup.pp index de67164..9f8c403 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -21,8 +21,8 @@ class concat::setup { } $script_name = $::kernel ? { - 'windows' => "concatfragments.rb", - default => "concatfragments.sh" + 'windows' => 'concatfragments.rb', + default => 'concatfragments.sh' } $script_path = "${concatdir}/bin/${script_name}" From 79352f4da6899adfc3be88cdaa7b46281d80e539 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sat, 2 Nov 2013 09:33:41 -0700 Subject: [PATCH 049/202] allow concat::fragment target param to be an arbitrary string Revert validation of the target param as an absolute path and allow it to be an arbitrary string. This is so the concat { : path => ... } concat::fragment { ...: target => } association may be symbolic as long as concat path param is specified. This should resolve the symbolic name regression introduced in: https://github.com/puppetlabs/puppetlabs-concat/commit/eaf84079 --- manifests/fragment.pp | 2 +- spec/system/symbolic_name_spec.rb | 35 +++++++++++++++++++++++ spec/unit/defines/concat_fragment_spec.rb | 28 +++++++++++------- 3 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 spec/system/symbolic_name_spec.rb diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 3382e16..c4a4cdf 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -35,7 +35,7 @@ define concat::fragment( $group = undef, $backup = undef ) { - validate_absolute_path($target) + validate_string($target) validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') validate_string($content) validate_string($source) diff --git a/spec/system/symbolic_name_spec.rb b/spec/system/symbolic_name_spec.rb new file mode 100644 index 0000000..2b687c0 --- /dev/null +++ b/spec/system/symbolic_name_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper_system' + +describe 'symbolic name' do + pp=" + concat { 'not_abs_path': + path => '/tmp/file', + } + + concat::fragment { '1': + target => 'not_abs_path', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => 'not_abs_path', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end +end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index ebb0807..8206920 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -44,22 +44,30 @@ describe 'concat::fragment', :type => :define do end end - context 'target =>' do - context '/etc/motd' do - it_behaves_like 'fragment', 'motd_header', { + context 'title' do + ['0', '1', 'a', 'z'].each do |title| + it_behaves_like 'fragment', title, { :target => '/etc/motd', } end + end # title - ['./etc/motd', 'etc/motd', false].each do |target| + context 'target =>' do + ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| context target do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} - let(:params) {{ :target => target }} + it_behaves_like 'fragment', target, { + :target => '/etc/motd', + } + end + end - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) - end + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :target => false }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) end end end # target => From 1a926b933c8424d05f55ec33e15a2a4c8915f9bd Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sat, 2 Nov 2013 10:45:02 -0700 Subject: [PATCH 050/202] deprecate concat::fragment mode, owner, & group params There's no need to allow the ownership/permissions of a fragment to be set as the concat define sets ownership/permissions on the final aggregated file. --- manifests/fragment.pp | 27 +++-- spec/system/deprecation_warnings_spec.rb | 39 ++++++++ spec/unit/defines/concat_fragment_spec.rb | 114 +++++++++------------- spec/unit/defines/concat_spec.rb | 14 ++- 4 files changed, 113 insertions(+), 81 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 7164d00..4f3a4b6 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -16,11 +16,11 @@ # [*ensure*] # Present/Absent or destination to a file to include another file # [*mode*] -# Mode for the file +# Deprecated # [*owner*] -# Owner of the file +# Deprecated # [*group*] -# Owner of the file +# Deprecated # [*backup*] # Deprecated # @@ -30,7 +30,7 @@ define concat::fragment( $source = undef, $order = 10, $ensure = 'present', - $mode = '0640', + $mode = undef, $owner = undef, $group = undef, $backup = undef @@ -40,9 +40,15 @@ define concat::fragment( validate_string($content) validate_string($source) validate_string($order) - validate_string($mode) - validate_string($owner) - validate_string($group) + if $mode { + warning('The $mode parameter to concat::fragment is deprecated and has no effect') + } + if $owner { + warning('The $owner parameter to concat::fragment is deprecated and has no effect') + } + if $group { + warning('The $group parameter to concat::fragment is deprecated and has no effect') + } if $backup { warning('The $backup parameter to concat::fragment is deprecated and has no effect') } @@ -67,11 +73,12 @@ define concat::fragment( } } + # punt on group ownership until some point in the distant future when $::gid + # can be relied on to be present file { "${fragdir}/fragments/${order}_${safe_name}": ensure => $ensure, - mode => $mode, - owner => $owner, - group => $group, + owner => $::id, + mode => '0640', source => $source, content => $content, backup => false, diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index f4b3a56..29fcfb2 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -26,6 +26,45 @@ describe 'deprecation warnings' do it_behaves_like 'has_warning', pp, w end + context 'concat::fragment mode parameter' do + pp=" + concat { '/tmp/file': } + concat::fragment { 'foo': + target => '/tmp/file', + mode => 'bar', + } + " + w = 'The $mode parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment owner parameter' do + pp=" + concat { '/tmp/file': } + concat::fragment { 'foo': + target => '/tmp/file', + owner => 'bar', + } + " + w = 'The $owner parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment group parameter' do + pp=" + concat { '/tmp/file': } + concat::fragment { 'foo': + target => '/tmp/file', + group => 'bar', + } + " + w = 'The $group parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + context 'concat::fragment backup parameter' do pp=" concat { '/tmp/file': } diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 65b8f79..d7d8ea5 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -10,19 +10,16 @@ describe 'concat::fragment', :type => :define do :source => nil, :order => 10, :ensure => 'present', - :mode => '0640', - :owner => nil, - :group => nil, - :backup => 'puppet', }.merge(params) safe_name = title.gsub(/[\/\n]/, '_') safe_target_name = p[:target].gsub(/[\/\n]/, '_') concatdir = '/var/lib/puppet/concat' fragdir = "#{concatdir}/#{safe_target_name}" + id = 'root' let(:title) { title } - let(:facts) {{ :concat_basedir => concatdir }} + let(:facts) {{ :concat_basedir => concatdir, :id => id }} let(:params) { params } let(:pre_condition) do "concat{ '#{p[:target]}': }" @@ -33,9 +30,8 @@ describe 'concat::fragment', :type => :define do should contain_concat(p[:target]) should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ :ensure => p[:ensure], - :mode => p[:mode], - :owner => p[:owner], - :group => p[:group], + :owner => id, + :mode => '0640', :source => p[:source], :content => p[:content], :alias => "concat_fragment_#{title}", @@ -156,72 +152,58 @@ describe 'concat::fragment', :type => :define do end end # order => - context 'mode =>' do - context '1755' do - it_behaves_like 'fragment', 'motd_header', { - :mode => '1755', - :target => '/etc/motd', - } - end + describe 'deprecated parameter' do + context 'mode =>' do + context '1755' do + it_behaves_like 'fragment', 'motd_header', { + :mode => '1755', + :target => '/etc/motd', + } - context 'false' do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} - let(:params) {{ :mode => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end end - end - end # mode => + end # mode => - context 'owner =>' do - context 'apenny' do - it_behaves_like 'fragment', 'motd_header', { - :owner => 'apenny', - :target => '/etc/motd', - } - end + context 'owner =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :owner => 'apenny', + :target => '/etc/motd', + } - context 'false' do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} - let(:params) {{ :owner => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end end - end - end # owner => + end # owner => - context 'group =>' do - context 'apenny' do - it_behaves_like 'fragment', 'motd_header', { - :group => 'apenny', - :target => '/etc/motd', - } - end + context 'group =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :group => 'apenny', + :target => '/etc/motd', + } - context 'false' do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} - let(:params) {{ :group => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end end - end - end # group => + end # group => - # should raise a warning but rspec-puppet can't presently test for warning() - # we can only test for the existence of the parameter - context 'backup =>' do - context 'foo' do - it_behaves_like 'fragment', 'motd_header', { - :backup => 'foo', - :target => '/etc/motd', - } - end - end # backup => + context 'backup =>' do + context 'foo' do + it_behaves_like 'fragment', 'motd_header', { + :backup => 'foo', + :target => '/etc/motd', + } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # backup => + end # deprecated params end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 8d74510..d284f3a 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -367,11 +367,15 @@ describe 'concat', :type => :define do end end # ensure_newline => - # should raise a warning but rspec-puppet can't presently test for warning() - # we can only test for the existence of the parameter - context 'gnu =>' do - context 'foo' do - it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'} + describe 'deprecated parameter' do + context 'gnu =>' do + context 'foo' do + it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'} + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end end end From a08709caf7ed461e2e644faf129a626d2b20ea44 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sun, 3 Nov 2013 10:20:32 -0700 Subject: [PATCH 051/202] add tests for concat_basedir fact --- spec/unit/facts/concat_basedir_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spec/unit/facts/concat_basedir_spec.rb diff --git a/spec/unit/facts/concat_basedir_spec.rb b/spec/unit/facts/concat_basedir_spec.rb new file mode 100644 index 0000000..41bc90f --- /dev/null +++ b/spec/unit/facts/concat_basedir_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'concat_basedir', :type => :fact do + before(:each) { Facter.clear } + + context 'Puppet[:vardir] ==' do + it '/var/lib/puppet' do + Puppet.stubs(:[]).with(:vardir).returns('/var/lib/puppet') + Facter.fact(:concat_basedir).value.should == '/var/lib/puppet/concat' + end + + it '/home/apenny/.puppet/var' do + Puppet.stubs(:[]).with(:vardir).returns('/home/apenny/.puppet/var') + Facter.fact(:concat_basedir).value.should == '/home/apenny/.puppet/var/concat' + end + end + +end From 41695bd62723edc86f48f3d163eafccc4c6797e6 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sun, 3 Nov 2013 11:02:00 -0700 Subject: [PATCH 052/202] convert from 4 space to 2 space indent --- lib/facter/concat_basedir.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/facter/concat_basedir.rb b/lib/facter/concat_basedir.rb index ef5a689..bfac071 100644 --- a/lib/facter/concat_basedir.rb +++ b/lib/facter/concat_basedir.rb @@ -5,7 +5,7 @@ # "${::vardir}/concat/" # Facter.add("concat_basedir") do - setcode do - File.join(Puppet[:vardir],"concat") - end + setcode do + File.join(Puppet[:vardir],"concat") + end end From 8f53c479cb15338b4ffccc33075aeb251fc90f91 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sun, 3 Nov 2013 11:26:09 -0700 Subject: [PATCH 053/202] add rspec-puppet pending test for warning on inclusion of concat::setup --- spec/unit/classes/concat_setup_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 5ddf9b1..bba455a 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -33,4 +33,10 @@ describe 'concat::setup', :type => :class do end end end # facts + + context 'deprecated as a public class' do + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end end From 2ef05a73fed074dcdcb94e531623596086c9ff2f Mon Sep 17 00:00:00 2001 From: Michiel Brandenburg Date: Tue, 12 Nov 2013 11:36:34 +0100 Subject: [PATCH 054/202] Puppet 2.6.x compatibility --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index ab63971..ecb0d2b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -67,7 +67,7 @@ define concat( $replace = true, $order = 'alpha', $ensure_newline = false, - $gnu = undef, + $gnu = undef ) { validate_re($ensure, '^present$|^absent$') validate_absolute_path($path) From 9025ab41fd32d432d5457672c30982b423b7033c Mon Sep 17 00:00:00 2001 From: jhoblitt Date: Tue, 12 Nov 2013 05:19:08 -0700 Subject: [PATCH 055/202] update travis matrix - peg the oldest tested version at puppet 2.7.3 + facter 1.6.0, primarily to try to catch the class param dangling comma issue that effects older versions of puppet - let the newest version of puppet 3.x free float --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad51c64..3fed52d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,16 +14,21 @@ rvm: - 2.0.0 env: matrix: + - PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - PUPPET_GEM_VERSION="~> 3.2.0" + - PUPPET_GEM_VERSION="~> 3.0" global: matrix: exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - rvm: 2.0.0 From ba9501c1a0787121de15c6d048067c5afc5ef58e Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 12 Nov 2013 23:16:47 -0700 Subject: [PATCH 056/202] allow source param to concat::fragment to be a string or an Array This is resolve a regression preventing an array of string(s) being passed to the fragment file resource's source parameter. --- manifests/fragment.pp | 4 +++- spec/unit/defines/concat_fragment_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 4f3a4b6..c5cf62d 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -38,7 +38,9 @@ define concat::fragment( validate_string($target) validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') validate_string($content) - validate_string($source) + if !(is_string($source) or is_array($source)) { + fail('$source is not a string or an Array.') + } validate_string($order) if $mode { warning('The $mode parameter to concat::fragment is deprecated and has no effect') diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index d7d8ea5..d26fd67 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -111,7 +111,7 @@ describe 'concat::fragment', :type => :define do end # content => context 'source =>' do - ['', '/foo/bar'].each do |source| + ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source| context source do it_behaves_like 'fragment', 'motd_header', { :source => source, @@ -126,7 +126,7 @@ describe 'concat::fragment', :type => :define do let(:params) {{ :source => false, :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { should }.to raise_error(Puppet::Error, /is not a string or an Array/) end end end # source => From 6c687551d8902778759bc985539d1c3792cd84db Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Wed, 13 Nov 2013 10:15:10 -0800 Subject: [PATCH 057/202] Initial pass at test to ensure fragments accept and properly handle the underlying file source attribute. --- spec/system/fragment_list_source_spec.rb | 90 ++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 spec/system/fragment_list_source_spec.rb diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_list_source_spec.rb new file mode 100644 index 0000000..1217e53 --- /dev/null +++ b/spec/system/fragment_list_source_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper_system' + +describe 'concat::fragment source lists ' do + context 'should create files containing first match only.' do + file1_contents="file1 contents" + file2_contents="file2 contents" + shell("echo '#{file1_contents}' > /tmp/file1") + shell("echo '#{file2_contents}' > /tmp/file2") + pp=" + + concat { '/tmp/result_file1': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/result_file2': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/result_file3': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/result_file1', + source => [ '/tmp/file1', '/tmp/file2' ], + order => '01', + } + concat::fragment { '2': + target => '/tmp/result_file2', + source => [ '/tmp/file2', '/tmp/file1' ], + order => '01', + } + concat::fragment { '3': + target => '/tmp/result_file3', + source => [ '/tmp/file1', '/tmp/file2' ], + order => '01', + } + " + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + describe file('/tmp/result_file1') do + it { should be_file } + it { should contain file1_contents } + it { should_not contain file2_contents } + end + describe file('/tmp/result_file2') do + it { should be_file } + it { should contain file2_contents } + it { should_not contain file1_contents } + end + describe file('/tmp/result_file3') do + it { should be_file } + it { should contain file1_contents } + it { should_not contain file2_contents } + end + end + + context 'should fail if no match on source.' do + pp=" + concat { '/tmp/fail_no_source': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/fail_no_source', + source => [ '/tmp/nofilehere', '/tmp/nothereeither' ], + order => '01', + } + " + context puppet_apply(pp) do + its(:exit_code) { should_not be_zero } + its(:refresh) { should be_nil } + end + describe file('/tmp/fail_no_source') do + it { should_not exist } + end + end +end + From 499f338ce542991d0e264a396ce5f995d44671c3 Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Wed, 13 Nov 2013 14:23:30 -0800 Subject: [PATCH 058/202] put the shell() calls into before{} blocks so that they're executed meaningfully. Testing to make sure a file doesn't exist shouldn't be as much of a hack as that is. I'm obviously missing something in the framework, but this works. --- spec/system/fragment_list_source_spec.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_list_source_spec.rb index 1217e53..ebfe633 100644 --- a/spec/system/fragment_list_source_spec.rb +++ b/spec/system/fragment_list_source_spec.rb @@ -4,8 +4,10 @@ describe 'concat::fragment source lists ' do context 'should create files containing first match only.' do file1_contents="file1 contents" file2_contents="file2 contents" - shell("echo '#{file1_contents}' > /tmp/file1") - shell("echo '#{file2_contents}' > /tmp/file2") + before(:all) do + shell("/bin/echo '#{file1_contents}' > /tmp/file1") + shell("/bin/echo '#{file2_contents}' > /tmp/file2") + end pp=" concat { '/tmp/result_file1': @@ -65,6 +67,9 @@ describe 'concat::fragment source lists ' do end context 'should fail if no match on source.' do + before(:all) do + shell("/bin/rm /tmp/fail_no_source /tmp/nofilehere /tmp/nothereeither") + end pp=" concat { '/tmp/fail_no_source': owner => root, @@ -80,10 +85,13 @@ describe 'concat::fragment source lists ' do " context puppet_apply(pp) do its(:exit_code) { should_not be_zero } + its(:exit_code) { should_not == 1 } its(:refresh) { should be_nil } end describe file('/tmp/fail_no_source') do - it { should_not exist } + #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. + it { should_not be_file } + it { should_not be_directory } end end end From c852dc22d77803d629813917054dd83946d7e0eb Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 5 Nov 2013 20:40:03 -0700 Subject: [PATCH 059/202] clean up between system spec files --- spec/spec_helper_system.rb | 7 +++++ spec/system/concat_spec.rb | 32 ++++++++++---------- spec/system/deprecation_warnings_spec.rb | 20 ++++++------- spec/system/empty_spec.rb | 4 +-- spec/system/fragment_list_source_spec.rb | 38 ++++++++++++------------ spec/system/replace_spec.rb | 8 ++--- spec/system/symbolic_name_spec.rb | 4 +-- spec/system/warn_spec.rb | 8 ++--- 8 files changed, 64 insertions(+), 57 deletions(-) diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 0924e47..311fe0a 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -23,4 +23,11 @@ RSpec.configure do |c| puppet_module_install(:source => proj_root, :module_name => 'concat') shell('puppet module install puppetlabs-stdlib') end + + c.before(:all) do + shell('mkdir -p /tmp/concat') + end + c.after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end end diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb index 55c8e3b..943de7e 100644 --- a/spec/system/concat_spec.rb +++ b/spec/system/concat_spec.rb @@ -29,25 +29,25 @@ describe 'basic concat test' do #it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file('/var/lib/puppet/concat/_tmp_file') do + describe file('/var/lib/puppet/concat/_tmp_concat_file') do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments') do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat.out') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat.out') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -57,20 +57,20 @@ describe 'basic concat test' do context 'owner/group root' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => 'root', group => 'root', mode => '0644', } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -78,7 +78,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -86,13 +86,13 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -107,20 +107,20 @@ describe 'basic concat test' do end pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => 'bob', group => 'bob', mode => '0644', } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -128,7 +128,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should be_owned_by 'bob' } it { should be_grouped_into 'bob' } @@ -136,14 +136,14 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/01_1') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } it { should contain '1' } end - describe file('/var/lib/puppet/concat/_tmp_file/fragments/02_2') do + describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index 29fcfb2..58e1e76 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -14,11 +14,11 @@ describe 'deprecation warnings' do context 'concat gnu parameter' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': gnu => 'foo', } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', } " w = 'The $gnu parameter to concat is deprecated and has no effect' @@ -28,9 +28,9 @@ describe 'deprecation warnings' do context 'concat::fragment mode parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', mode => 'bar', } " @@ -41,9 +41,9 @@ describe 'deprecation warnings' do context 'concat::fragment owner parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', owner => 'bar', } " @@ -54,9 +54,9 @@ describe 'deprecation warnings' do context 'concat::fragment group parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', group => 'bar', } " @@ -67,9 +67,9 @@ describe 'deprecation warnings' do context 'concat::fragment backup parameter' do pp=" - concat { '/tmp/file': } + concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/file', + target => '/tmp/concat/file', backup => 'bar', } " diff --git a/spec/system/empty_spec.rb b/spec/system/empty_spec.rb index 83dae01..67d968e 100644 --- a/spec/system/empty_spec.rb +++ b/spec/system/empty_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -19,7 +19,7 @@ describe 'basic concat test' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should_not contain '1\n2' } end diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_list_source_spec.rb index ebfe633..5716ef7 100644 --- a/spec/system/fragment_list_source_spec.rb +++ b/spec/system/fragment_list_source_spec.rb @@ -5,40 +5,40 @@ describe 'concat::fragment source lists ' do file1_contents="file1 contents" file2_contents="file2 contents" before(:all) do - shell("/bin/echo '#{file1_contents}' > /tmp/file1") - shell("/bin/echo '#{file2_contents}' > /tmp/file2") + shell("/bin/echo '#{file1_contents}' > /tmp/concat/file1") + shell("/bin/echo '#{file2_contents}' > /tmp/concat/file2") end pp=" - concat { '/tmp/result_file1': + concat { '/tmp/concat/result_file1': owner => root, group => root, mode => '0644', } - concat { '/tmp/result_file2': + concat { '/tmp/concat/result_file2': owner => root, group => root, mode => '0644', } - concat { '/tmp/result_file3': + concat { '/tmp/concat/result_file3': owner => root, group => root, mode => '0644', } concat::fragment { '1': - target => '/tmp/result_file1', - source => [ '/tmp/file1', '/tmp/file2' ], + target => '/tmp/concat/result_file1', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], order => '01', } concat::fragment { '2': - target => '/tmp/result_file2', - source => [ '/tmp/file2', '/tmp/file1' ], + target => '/tmp/concat/result_file2', + source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], order => '01', } concat::fragment { '3': - target => '/tmp/result_file3', - source => [ '/tmp/file1', '/tmp/file2' ], + target => '/tmp/concat/result_file3', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], order => '01', } " @@ -49,17 +49,17 @@ describe 'concat::fragment source lists ' do its(:stderr) { should be_empty } its(:exit_code) { should be_zero } end - describe file('/tmp/result_file1') do + describe file('/tmp/concat/result_file1') do it { should be_file } it { should contain file1_contents } it { should_not contain file2_contents } end - describe file('/tmp/result_file2') do + describe file('/tmp/concat/result_file2') do it { should be_file } it { should contain file2_contents } it { should_not contain file1_contents } end - describe file('/tmp/result_file3') do + describe file('/tmp/concat/result_file3') do it { should be_file } it { should contain file1_contents } it { should_not contain file2_contents } @@ -68,18 +68,18 @@ describe 'concat::fragment source lists ' do context 'should fail if no match on source.' do before(:all) do - shell("/bin/rm /tmp/fail_no_source /tmp/nofilehere /tmp/nothereeither") + shell("/bin/rm /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither") end pp=" - concat { '/tmp/fail_no_source': + concat { '/tmp/concat/fail_no_source': owner => root, group => root, mode => '0644', } concat::fragment { '1': - target => '/tmp/fail_no_source', - source => [ '/tmp/nofilehere', '/tmp/nothereeither' ], + target => '/tmp/concat/fail_no_source', + source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], order => '01', } " @@ -88,7 +88,7 @@ describe 'concat::fragment source lists ' do its(:exit_code) { should_not == 1 } its(:refresh) { should be_nil } end - describe file('/tmp/fail_no_source') do + describe file('/tmp/concat/fail_no_source') do #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. it { should_not be_file } it { should_not be_directory } diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb index 7f11e5f..4844087 100644 --- a/spec/system/replace_spec.rb +++ b/spec/system/replace_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper_system' describe 'file should not replace' do - shell('echo "file exists" >> /tmp/file') + shell('echo "file exists" >> /tmp/concat/file') context 'should fail' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -13,13 +13,13 @@ describe 'file should not replace' do } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } diff --git a/spec/system/symbolic_name_spec.rb b/spec/system/symbolic_name_spec.rb index 2b687c0..239aa80 100644 --- a/spec/system/symbolic_name_spec.rb +++ b/spec/system/symbolic_name_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'symbolic name' do pp=" concat { 'not_abs_path': - path => '/tmp/file', + path => '/tmp/concat/file', } concat::fragment { '1': @@ -27,7 +27,7 @@ describe 'symbolic name' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should contain '1' } it { should contain '2' } diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb index 872058b..d5052ba 100644 --- a/spec/system/warn_spec.rb +++ b/spec/system/warn_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do pp=" - concat { '/tmp/file': + concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', @@ -11,13 +11,13 @@ describe 'basic concat test' do } concat::fragment { '1': - target => '/tmp/file', + target => '/tmp/concat/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/file', + target => '/tmp/concat/file', content => '2', order => '02', } @@ -31,7 +31,7 @@ describe 'basic concat test' do its(:exit_code) { should be_zero } end - describe file('/tmp/file') do + describe file('/tmp/concat/file') do it { should be_file } it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain '1' } From 4ee4be00acc74edc467d6f52a3bc12712909eb0a Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 13 Nov 2013 20:28:27 -0700 Subject: [PATCH 060/202] minor system test cleanups --- spec/system/concat_spec.rb | 4 ++-- spec/system/deprecation_warnings_spec.rb | 24 ++++++++++++------------ spec/system/empty_spec.rb | 4 ++-- spec/system/fragment_list_source_spec.rb | 18 +++++++++++------- spec/system/replace_spec.rb | 9 ++++++--- spec/system/symbolic_name_spec.rb | 4 ++-- spec/system/warn_spec.rb | 4 ++-- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb index 943de7e..ee754f6 100644 --- a/spec/system/concat_spec.rb +++ b/spec/system/concat_spec.rb @@ -56,7 +56,7 @@ describe 'basic concat test' do end context 'owner/group root' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': owner => 'root', group => 'root', @@ -74,7 +74,7 @@ describe 'basic concat test' do content => '2', order => '02', } - " + EOS it_behaves_like 'successfully_applied', pp diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index 58e1e76..0cb5a01 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -13,75 +13,75 @@ describe 'deprecation warnings' do end context 'concat gnu parameter' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': gnu => 'foo', } concat::fragment { 'foo': target => '/tmp/concat/file', } - " + EOS w = 'The $gnu parameter to concat is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment mode parameter' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': target => '/tmp/concat/file', mode => 'bar', } - " + EOS w = 'The $mode parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment owner parameter' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': target => '/tmp/concat/file', owner => 'bar', } - " + EOS w = 'The $owner parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment group parameter' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': target => '/tmp/concat/file', group => 'bar', } - " + EOS w = 'The $group parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment backup parameter' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': target => '/tmp/concat/file', backup => 'bar', } - " + EOS w = 'The $backup parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'include concat::setup' do - pp=" + pp = <<-EOS include concat::setup - " + EOS w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.' it_behaves_like 'has_warning', pp, w diff --git a/spec/system/empty_spec.rb b/spec/system/empty_spec.rb index 67d968e..383f478 100644 --- a/spec/system/empty_spec.rb +++ b/spec/system/empty_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': owner => root, group => root, mode => '0644', force => true, } - " + EOS context puppet_apply(pp) do its(:stderr) { should be_empty } diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_list_source_spec.rb index 5716ef7..ab15948 100644 --- a/spec/system/fragment_list_source_spec.rb +++ b/spec/system/fragment_list_source_spec.rb @@ -2,14 +2,15 @@ require 'spec_helper_system' describe 'concat::fragment source lists ' do context 'should create files containing first match only.' do - file1_contents="file1 contents" - file2_contents="file2 contents" + let(:file1_contents) { 'file1 contents' } + let(:file2_contents) { 'file2 contents' } before(:all) do + shell("/bin/echo '#{file1_contents}' > /tmp/concat/file1") shell("/bin/echo '#{file2_contents}' > /tmp/concat/file2") end - pp=" - + + pp = <<-EOS concat { '/tmp/concat/result_file1': owner => root, group => root, @@ -41,7 +42,8 @@ describe 'concat::fragment source lists ' do source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], order => '01', } - " + EOS + context puppet_apply(pp) do its(:stderr) { should be_empty } its(:exit_code) { should_not == 1 } @@ -70,7 +72,8 @@ describe 'concat::fragment source lists ' do before(:all) do shell("/bin/rm /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither") end - pp=" + + pp = <<-EOS concat { '/tmp/concat/fail_no_source': owner => root, group => root, @@ -82,7 +85,8 @@ describe 'concat::fragment source lists ' do source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], order => '01', } - " + EOS + context puppet_apply(pp) do its(:exit_code) { should_not be_zero } its(:exit_code) { should_not == 1 } diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb index 4844087..3cd18ba 100644 --- a/spec/system/replace_spec.rb +++ b/spec/system/replace_spec.rb @@ -2,9 +2,12 @@ require 'spec_helper_system' describe 'file should not replace' do - shell('echo "file exists" >> /tmp/concat/file') + before(:all) do + shell('echo "file exists" > /tmp/concat/file') + end + context 'should fail' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': owner => root, group => root, @@ -23,7 +26,7 @@ describe 'file should not replace' do content => '2', order => '02', } - " + EOS context puppet_apply(pp) do its(:stderr) { should be_empty } diff --git a/spec/system/symbolic_name_spec.rb b/spec/system/symbolic_name_spec.rb index 239aa80..caae647 100644 --- a/spec/system/symbolic_name_spec.rb +++ b/spec/system/symbolic_name_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper_system' describe 'symbolic name' do - pp=" + pp = <<-EOS concat { 'not_abs_path': path => '/tmp/concat/file', } @@ -17,7 +17,7 @@ describe 'symbolic name' do content => '2', order => '02', } - " + EOS context puppet_apply(pp) do its(:stderr) { should be_empty } diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb index d5052ba..405dfd6 100644 --- a/spec/system/warn_spec.rb +++ b/spec/system/warn_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_system' describe 'basic concat test' do context 'should run successfully' do - pp=" + pp = <<-EOS concat { '/tmp/concat/file': owner => root, group => root, @@ -21,7 +21,7 @@ describe 'basic concat test' do content => '2', order => '02', } - " + EOS context puppet_apply(pp) do its(:stderr) { should be_empty } From 7c702a5713bee9f57d49d8491d0fbb9d9c16df3c Mon Sep 17 00:00:00 2001 From: Terri Haber Date: Fri, 15 Nov 2013 15:51:37 -0800 Subject: [PATCH 061/202] adding basic manifest tests --- tests/fragment.pp | 19 +++++++++++++++++++ tests/init.pp | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/fragment.pp create mode 100644 tests/init.pp diff --git a/tests/fragment.pp b/tests/fragment.pp new file mode 100644 index 0000000..bf3f99a --- /dev/null +++ b/tests/fragment.pp @@ -0,0 +1,19 @@ +concat { 'testconcat': + path => '/tmp/concat', + ensure => present, + owner => 'root', + group => 'root', + mode => '0664', +} + +concat::fragment { '1': + target => 'testconcat', + content => '1', + order => '01', +} + +concat::fragment { '2': + target => 'testconcat', + content => '2', + order => '02', +} diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000..fd21427 --- /dev/null +++ b/tests/init.pp @@ -0,0 +1,7 @@ +concat { '/tmp/concat': + ensure => present, + force => true, + owner => 'root', + group => 'root', + mode => '0644', +} From ae1e74cf362c75db9ee81d6d1061aabd9e357720 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Mon, 4 Nov 2013 19:49:15 -0700 Subject: [PATCH 062/202] add system tests for replacing symlinks and directories --- spec/spec_helper_system.rb | 2 + spec/system/replace_spec.rb | 277 ++++++++++++++++++++++++++++++++---- 2 files changed, 249 insertions(+), 30 deletions(-) diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 311fe0a..9ed91c1 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -30,4 +30,6 @@ RSpec.configure do |c| c.after(:all) do shell('rm -rf /tmp/concat /var/lib/puppet/concat') end + + c.treat_symbols_as_metadata_keys_with_true_values = true end diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb index 3cd18ba..a0f976a 100644 --- a/spec/system/replace_spec.rb +++ b/spec/system/replace_spec.rb @@ -1,40 +1,257 @@ require 'spec_helper_system' +describe 'replacement of' do + context 'file' do + context 'should not succeed' do + before(:all) do + shell('mkdir /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end -describe 'file should not replace' do - before(:all) do - shell('echo "file exists" > /tmp/concat/file') - end + pp = <<-EOS + concat { '/tmp/concat/file': + replace => false, + } - context 'should fail' do - pp = <<-EOS - concat { '/tmp/concat/file': - owner => root, - group => root, - mode => '0644', - replace => false, - } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } - concat::fragment { '1': - target => '/tmp/concat/file', - content => '1', - order => '01', - } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS - concat::fragment { '2': - target => '/tmp/concat/file', - content => '2', - order => '02', - } - EOS + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'file exists' } + it { should_not contain '1' } + it { should_not contain '2' } + end end - end + context 'should succeed' do + before(:all) do + shell('mkdir /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain 'file exists' } + it { should contain '1' } + it { should contain '2' } + end + end + end # file + + context 'symlink' do + context 'should not succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_linked_to '/tmp/concat/dangling' } + end + + describe file('/tmp/concat/dangling') do + # XXX serverspec does not have a matcher for 'exists' + it { should_not be_file } + it { should_not be_directory } + end + end + + context 'should succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end + end + end # symlink + + context 'directory' do + context 'should not succeed' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should =~ /change from directory to file failed/ } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should =~ /change from directory to file failed/ } + its(:exit_code) { should_not == 1 } + end + + describe file('/tmp/concat/file') do + it { should be_directory } + end + end + + # XXX concat's force param currently enables the creation of empty files when + # there are no fragments. The semantics either need to be changed, extended, + # or a new param introduced to control directory replacement. + context 'should succeed', :pending => 'not yet implemented' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + force => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + end + end + end # directory end From 24e0cda13ec46c9247691ebdcdb4ec3674136d72 Mon Sep 17 00:00:00 2001 From: Henrik Feldt Date: Tue, 26 Nov 2013 12:14:03 +0100 Subject: [PATCH 063/202] See #67 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cecdcc8..d533155 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ class motd { # /etc/motd.local concat::fragment{"motd_local": target => $motd, - ensure => "/etc/motd.local", - order => 15 + source => "/etc/motd.local", + order => 15 } } From 952b88b45bc1d0a88df4edc2c4ae78ed6e80ebd1 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 21 Nov 2013 10:14:45 -0500 Subject: [PATCH 064/202] Improve formatting of code example * Puppet syntax highlighting * Double-spaced indentation * Aligned instances of => * Quoted strings * Single-quoted some unnecessarily double-quoted strings * Removed comma from the last variable --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d533155..9fc4ca6 100644 --- a/README.md +++ b/README.md @@ -28,53 +28,53 @@ Puppet modules on this server: Local sysadmins can also append to the file by just editing /etc/motd.local their changes will be incorporated into the puppet managed motd. -
+```puppet
 # class to setup basic motd, include on all nodes
 class motd {
-   $motd = "/etc/motd"
+  $motd = '/etc/motd'
 
-   concat{$motd:
-      owner => root,
-      group => root,
-      mode  => '0644',
-   }
+  concat { $motd:
+    owner => 'root',
+    group => 'root',
+    mode  => '0644'
+  }
 
-   concat::fragment{"motd_header":
-      target => $motd,
-      content => "\nPuppet modules on this server:\n\n",
-      order   => 01,
-   }
+  concat::fragment{ 'motd_header':
+    target  => $motd,
+    content => "\nPuppet modules on this server:\n\n",
+    order   => '01'
+  }
 
-   # local users on the machine can append to motd by just creating
-   # /etc/motd.local
-   concat::fragment{"motd_local":
-      target => $motd,
-      source => "/etc/motd.local",
-      order  => 15
-   }
+  # local users on the machine can append to motd by just creating
+  # /etc/motd.local
+  concat::fragment{ 'motd_local':
+    target => $motd,
+    source => '/etc/motd.local',
+    order  => '15'
+  }
 }
 
 # used by other modules to register themselves in the motd
 define motd::register($content="", $order=10) {
-   if $content == "" {
-      $body = $name
-   } else {
-      $body = $content
-   }
+  if $content == "" {
+    $body = $name
+  } else {
+    $body = $content
+  }
 
-   concat::fragment{"motd_fragment_$name":
-      target  => "/etc/motd",
-      content => "    -- $body\n"
-   }
+  concat::fragment{ "motd_fragment_$name":
+    target  => '/etc/motd',
+    content => "    -- $body\n"
+  }
 }
 
 # a sample apache module
 class apache {
-   include apache::install, apache::config, apache::service
+  include apache::install, apache::config, apache::service
 
-   motd::register{"Apache": }
+  motd::register{ 'Apache': }
 }
-
+``` Detailed documentation of the class options can be found in the manifest files. From 07a4f61af5efcb82daf7a560fedad5f0db89df55 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 3 Dec 2013 12:37:48 -0500 Subject: [PATCH 065/202] Rewrite the docs to fit the current best practices for Puppetlabs modules. --- README.md | 268 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 205 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 9fc4ca6..aa8b0a0 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,59 @@ -What is it? -=========== +#Concat + [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-concat.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-concat) +####Table of Contents -A Puppet module that can construct files from fragments. +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with concat](#setup) + * [What concat affects](#what-concat-affects) + * [Setup requirements](#setup-requirements) + * [Beginning with concat](#beginning-with-concat) +4. [Usage - Configuration options and additional functionality](#usage) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) -Please see the comments in the various .pp files for details -as well as posts on my blog at http://www.devco.net/ +##Overview -Released under the Apache 2.0 licence +This module constructs files from multiple fragments in an ordered way. -Usage: ------- +##Module Description + +This module lets you use many concat::fragment{} resources throughout +your modules to construct a single file at the end. It does this through +a shell (or ruby) script and a temporary holding space for the fragments. + +##Setup + +###What concat affects + +* Installs concatfragments.[sh|rb] based on platform. +* Adds a concat/ directory into Puppets `vardir`. + +###Beginning with concat + +To start using concat you need to create: + +* A concat{} resource for the final file. +* One or more concat::fragment{}'s. + +A minimal example might be: + +```puppet +concat { '/tmp/file': + ensure => present, +} + +concat::fragment { 'tmpfile': + target => '/tmp/file' + content => 'test contents', + order => '01' +} +``` + +##Usage If you wanted a /etc/motd file that listed all the major modules on the machine. And that would be maintained automatically even @@ -29,7 +71,6 @@ Local sysadmins can also append to the file by just editing /etc/motd.local their changes will be incorporated into the puppet managed motd. ```puppet -# class to setup basic motd, include on all nodes class motd { $motd = '/etc/motd' @@ -67,8 +108,11 @@ define motd::register($content="", $order=10) { content => " -- $body\n" } } +``` -# a sample apache module +To use this you'd then do something like: + +```puppet class apache { include apache::install, apache::config, apache::service @@ -76,88 +120,186 @@ class apache { } ``` -Detailed documentation of the class options can be found in the -manifest files. +##Reference -Known Issues: -------------- -* Since puppet-concat now relies on a fact for the concat directory, - you will need to set up pluginsync = true on both the master and client - node's '/etc/puppet/puppet.conf' for at least the first run. - You have this issue if puppet fails to run on the client and you have - a message similar to - "err: Failed to apply catalog: Parameter path failed: File - paths must be fully qualified, not 'undef' at [...]/concat/manifests/setup.pp:44". +###Classes -Contributors: -------------- -**Paul Elliot** +####Public classes - * Provided 0.24.8 support, shell warnings and empty file creation support. +####Private classes +* `concat::setup`: Sets up the concat script/directories. -**Chad Netzer** +###Parameters - * Various patches to improve safety of file operations - * Symlink support +###Defines -**David Schmitt** +####concat - * Patch to remove hard coded paths relying on OS path - * Patch to use file{} to copy the resulting file to the final destination. This means Puppet client will show diffs and that hopefully we can change file ownerships now +#####`ensure` +Controls if the combined file is present or absent. -**Peter Meier** +######Example +- ensure => present +- ensure => absent - * Basedir as a fact - * Unprivileged user support +#####`path` +Controls the destination of the file to create. -**Sharif Nassar** +######Example +- path => '/tmp/filename' - * Solaris/Nexenta support - * Better error reporting +#####`owner` +Set the owner of the combined file. -**Christian G. Warden** +######Example +- owner => 'root' - * Style improvements +#####`group` +Set the group of the combined file. -**Reid Vandewiele** +######Example +- group => 'root' - * Support non GNU systems by default +#####`mode` +Set the mode of the combined file. -**Erik Dalén** +######Example +- mode => '0644' - * Style improvements +#####`warn` +Determine if a warning message should be added at the top of the file to let +users know it was autogenerated by Puppet. -**Gildas Le Nadan** +######Example +- warn => true +- warn => false - * Documentation improvements +#####`warn_message` +Set the contents of the warning message. -**Paul Belanger** +######Example +- warn_message => 'This file is autogenerated!' - * Testing improvements and Travis support +#####`force` +Determine if empty files are allowed when no fragments were added. -**Branan Purvine-Riley** +######Example +- force => true +- force => false - * Support Puppet Module Tool better +#####`backup` +Controls the filebucket behavior used for the file. -**Dustin J. Mitchell** +######Example +- backup => 'puppet' - * Always include setup when using the concat define +#####`replace` +Controls if Puppet should replace the destination file if it already exists. -**Andreas Jaggi** +######Example +- replace => true +- replace => false - * Puppet Lint support +#####`order` +Controls the way in which the shell script chooses to sort the files. It's +rare you'll need to adjust this. -**Jan Vansteenkiste** +######Allowed Values +- order => 'alpha' +- order => 'numeric' - * Configurable paths +#####`ensure_newline` +Ensure there's a newline at the end of the fragments. -**Joshua Hoblitt** +######Example +- ensure_newline => true +- ensure_newline => false - * Remove requirement to manually include `concat::setup` in the manifest - * Style improvements - * Parameter validation / refactor parameter handling - * Test coverage +####concat::fragment -Contact: --------- -puppet-users@ mailing list. +#####`target` +Choose the destination file of the fragment. + +######Example +- target => '/tmp/testfile' + +#####`content` +Create the content of the fragment. + +######Example +- content => 'test file contents' + +#####`source` +Find the sources within Puppet of the fragment. + +######Example +- source => 'puppet:///modules/test/testfile' +- source => ['puppet:///modules/test/1', 'puppet:///modules/test/2'] + +#####`order` +Order the fragments. + +######Example +- order => '01' + +#####`ensure` +Control the file of fragment created. + +######Example +- ensure => 'present' +- ensure => 'absent' +- ensure => 'file' +- ensure => 'directory' + +#####`mode` +Set the mode of the fragment. + +######Example +- mode => '0644' + +#####`owner` +Set the owner of the fragment. + +######Example +- owner => 'root' + +#####`group` +Set the group of the fragment. + +######Example +- group => 'root' + +#####`backup` +Control the filebucket behavior for the fragment. + +######Example +- backup => 'puppet' + +##Limitations + +This module has been tested on: + +* RedHat Enterprise Linux (and Centos) 5/6 +* Debian 6/7 +* Ubuntu 12.04 + +Testing on other platforms has been light and cannot be guaranteed. + +#Development + +Puppet Labs modules on the Puppet Forge are open projects, and community +contributions are essential for keeping them great. We can’t access the +huge number of platforms and myriad of hardware, software, and deployment +configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our +modules work in your environment. There are a few guidelines that we need +contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +###Contributors + +The list of contributors can be found at: + +https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors From 9bf4b7f350bcbe4f44be8fe19aec82de7ef09ff5 Mon Sep 17 00:00:00 2001 From: Matthew Schmitt Date: Wed, 4 Dec 2013 20:40:05 -0800 Subject: [PATCH 066/202] Cleaning up linting error with ensure param --- tests/fragment.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fragment.pp b/tests/fragment.pp index bf3f99a..a2dfaca 100644 --- a/tests/fragment.pp +++ b/tests/fragment.pp @@ -1,6 +1,6 @@ concat { 'testconcat': - path => '/tmp/concat', ensure => present, + path => '/tmp/concat', owner => 'root', group => 'root', mode => '0664', From f1a57a6c7e34d0ed36468da1068f05e0adcf16be Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 5 Dec 2013 08:00:04 -0700 Subject: [PATCH 067/202] add system tests for file fragments sourced from a single file In addition to checking for fragment sourcing from a 'list' of files. --- ...source_spec.rb => fragment_source_spec.rb} | 74 ++++++++++++++----- 1 file changed, 57 insertions(+), 17 deletions(-) rename spec/system/{fragment_list_source_spec.rb => fragment_source_spec.rb} (52%) diff --git a/spec/system/fragment_list_source_spec.rb b/spec/system/fragment_source_spec.rb similarity index 52% rename from spec/system/fragment_list_source_spec.rb rename to spec/system/fragment_source_spec.rb index ab15948..6ff088f 100644 --- a/spec/system/fragment_list_source_spec.rb +++ b/spec/system/fragment_source_spec.rb @@ -1,13 +1,51 @@ require 'spec_helper_system' -describe 'concat::fragment source lists ' do - context 'should create files containing first match only.' do - let(:file1_contents) { 'file1 contents' } - let(:file2_contents) { 'file2 contents' } +describe 'concat::fragment source' do + context 'should read file fragments from local system' do before(:all) do + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + end - shell("/bin/echo '#{file1_contents}' > /tmp/concat/file1") - shell("/bin/echo '#{file2_contents}' > /tmp/concat/file2") + pp = <<-EOS + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + source => '/tmp/concat/file1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string1 contents', + } + concat::fragment { '3': + target => '/tmp/concat/foo', + source => '/tmp/concat/file2', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain 'file1 contents' } + it { should contain 'string1 contents' } + it { should contain 'file2 contents' } + end + end # should read file fragments from local system + + context 'should create files containing first match only.' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") end pp = <<-EOS @@ -51,26 +89,28 @@ describe 'concat::fragment source lists ' do its(:stderr) { should be_empty } its(:exit_code) { should be_zero } end - describe file('/tmp/concat/result_file1') do + describe file('/tmp/concat/result_file1') do it { should be_file } - it { should contain file1_contents } - it { should_not contain file2_contents } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } end - describe file('/tmp/concat/result_file2') do + describe file('/tmp/concat/result_file2') do it { should be_file } - it { should contain file2_contents } - it { should_not contain file1_contents } + it { should contain 'file2 contents' } + it { should_not contain 'file1 contents' } end - describe file('/tmp/concat/result_file3') do + describe file('/tmp/concat/result_file3') do it { should be_file } - it { should contain file1_contents } - it { should_not contain file2_contents } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } end end - + context 'should fail if no match on source.' do before(:all) do - shell("/bin/rm /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither") + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither') end pp = <<-EOS From 41d5d4ccd16856ef768f8e51ac986e4adf839d40 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 5 Dec 2013 16:01:17 -0700 Subject: [PATCH 068/202] fix regression preventing usage of fragment ensure => /target syntax Also fix a historical bug that prevents a fragment from being converted from a symlink to using a source or content parameter. --- manifests/fragment.pp | 48 +++++--- spec/system/deprecation_warnings_spec.rb | 127 ++++++++++++++++++++-- spec/unit/defines/concat_fragment_spec.rb | 68 +++++++++++- 3 files changed, 216 insertions(+), 27 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index c5cf62d..9477653 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -36,7 +36,9 @@ define concat::fragment( $backup = undef ) { validate_string($target) - validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') + if ! ($ensure in [ 'present', 'absent' ]) { + warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') + } validate_string($content) if !(is_string($source) or is_array($source)) { fail('$source is not a string or an Array.') @@ -62,23 +64,43 @@ define concat::fragment( $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_target_name}" - # if content is passed, use that, else if source is passed use that - # if neither passed, but $ensure is in symlink form, make a symlink - case $ensure { - '', 'absent', 'present', 'file', 'directory': { - if ! ($content or $source) { - crit('No content, source or symlink specified') - } - } - default: { - # do nothing, make puppet-lint happy - } + # The file type's semantics are problematic in that ensure => present will + # not over write a pre-existing symlink. We are attempting to provide + # backwards compatiblity with previous concat::fragment versions that + # supported the file type's ensure => /target syntax + + # be paranoid and only allow the fragment's file resource's ensure param to + # be file, absent, or a file target + $safe_ensure = $ensure ? { + '' => 'file', + undef => 'file', + 'file' => 'file', + 'present' => 'file', + 'absent' => 'absent', + default => $ensure, + } + + # if it looks line ensure => /target syntax was used, fish that out + if ! ($ensure in ['', 'present', 'absent', 'file' ]) { + $ensure_target = $ensure + } + + # the file type's semantics only allows one of: ensure => /target, content, + # or source + if ($ensure_target and $source) or + ($ensure_target and $content) or + ($source and $content) { + fail('You cannot specify more than one of $content, $source, $ensure => /target') + } + + if ! ($content or $source or $ensure_target) { + crit('No content, source or symlink specified') } # punt on group ownership until some point in the distant future when $::gid # can be relied on to be present file { "${fragdir}/fragments/${order}_${safe_name}": - ensure => $ensure, + ensure => $safe_ensure, owner => $::id, mode => '0640', source => $source, diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index 0cb5a01..3c28d04 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -18,7 +18,8 @@ describe 'deprecation warnings' do gnu => 'foo', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '/tmp/concat/file', + content => 'bar', } EOS w = 'The $gnu parameter to concat is deprecated and has no effect' @@ -26,12 +27,117 @@ describe 'deprecation warnings' do it_behaves_like 'has_warning', pp, w end + context 'concat::fragment ensure parameter' do + context 'target file exists' do + before(:all) do + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + end + after(:all) do + # XXX this test may leave behind a symlink in the fragment directory + # which could cause warnings and/or breakage from the subsequent tests + # unless we clean it up. + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + ensure => '/tmp/concat/file1', + } + EOS + w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'file1 contents' } + end + + # check that the fragment can be changed from a symlink to a plain file + + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + it { should_not contain 'file1 contents' } + end + end # target file exists + + context 'target does not exist' do + after(:all) do + # XXX this test may leave behind a symlink in the fragment directory + # which could cause warnings and/or breakage from the subsequent tests + # unless we clean it up. + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + ensure => '/tmp/concat/file1', + } + EOS + w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + end + + # check that the fragment can be changed from a symlink to a plain file + + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + end + end # target file exists + + end # concat::fragment ensure parameter + context 'concat::fragment mode parameter' do pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - mode => 'bar', + target => '/tmp/concat/file', + content => 'bar', + mode => 'bar', } EOS w = 'The $mode parameter to concat::fragment is deprecated and has no effect' @@ -43,8 +149,9 @@ describe 'deprecation warnings' do pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - owner => 'bar', + target => '/tmp/concat/file', + content => 'bar', + owner => 'bar', } EOS w = 'The $owner parameter to concat::fragment is deprecated and has no effect' @@ -56,8 +163,9 @@ describe 'deprecation warnings' do pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - group => 'bar', + target => '/tmp/concat/file', + content => 'bar', + group => 'bar', } EOS w = 'The $group parameter to concat::fragment is deprecated and has no effect' @@ -69,8 +177,9 @@ describe 'deprecation warnings' do pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - backup => 'bar', + target => '/tmp/concat/file', + content => 'bar', + backup => 'bar', } EOS w = 'The $backup parameter to concat::fragment is deprecated and has no effect' diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index d26fd67..3b5269e 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -17,6 +17,11 @@ describe 'concat::fragment', :type => :define do concatdir = '/var/lib/puppet/concat' fragdir = "#{concatdir}/#{safe_target_name}" id = 'root' + if p[:ensure] == 'absent' + safe_ensure = p[:ensure] + else + safe_ensure = 'file' + end let(:title) { title } let(:facts) {{ :concat_basedir => concatdir, :id => id }} @@ -29,7 +34,7 @@ describe 'concat::fragment', :type => :define do should contain_class('concat::setup') should contain_concat(p[:target]) should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ - :ensure => p[:ensure], + :ensure => safe_ensure, :owner => id, :mode => '0640', :source => p[:source], @@ -69,7 +74,7 @@ describe 'concat::fragment', :type => :define do end # target => context 'ensure =>' do - ['', 'present', 'absent', 'file', 'directory'].each do |ens| + ['present', 'absent'].each do |ens| context ens do it_behaves_like 'fragment', 'motd_header', { :ensure => ens, @@ -78,13 +83,13 @@ describe 'concat::fragment', :type => :define do end end - context 'invalid' do + context 'any value other than \'present\' or \'absent\'' do let(:title) { 'motd_header' } let(:facts) {{ :concat_basedir => '/tmp' }} let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^$|^present$|^absent$|^file$|^directory$"')}/) + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') end end end # ensure => @@ -152,6 +157,59 @@ describe 'concat::fragment', :type => :define do end end # order => + context 'more than one content source' do + error_msg = 'You cannot specify more than one of $content, $source, $ensure => /target' + + context 'ensure => target and source' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :ensure => '/foo', + :source => '/bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + context 'ensure => target and content' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :ensure => '/foo', + :content => 'bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + context 'source and content' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :source => '/foo', + :content => 'bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + end # more than one content source + describe 'deprecated parameter' do context 'mode =>' do context '1755' do From 00a8f4e73695eb93529942b31d0580df17ee9393 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Tue, 17 Dec 2013 11:03:38 -0500 Subject: [PATCH 069/202] [Most of] variables quoted to allow multi-word warning messages, spaces in file/directory names, etc. --- files/concatfragments.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 88fe0e7..6c02682 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -67,26 +67,26 @@ while getopts "o:s:d:tnw:fl" options; do done # do we have -o? -if [ x${OUTFILE} = "x" ]; then +if [ "x${OUTFILE}" = "x" ]; then echo "Please specify an output file with -o" exit 1 fi # do we have -d? -if [ x${WORKDIR} = "x" ]; then +if [ "x${WORKDIR}" = "x" ]; then echo "Please fragments directory with -d" exit 1 fi # can we write to -o? -if [ -f ${OUTFILE} ]; then - if [ ! -w ${OUTFILE} ]; then +if [ -f "${OUTFILE}" ]; then + if [ ! -w "${OUTFILE}" ]; then echo "Cannot write to ${OUTFILE}" exit 1 fi else - if [ ! -w `dirname ${OUTFILE}` ]; then - echo "Cannot write to `dirname ${OUTFILE}` to create ${OUTFILE}" + if [ ! -w `dirname "${OUTFILE}"` ]; then + echo "Cannot write to `dirname \"${OUTFILE}\"` to create ${OUTFILE}" exit 1 fi fi @@ -98,14 +98,14 @@ if [ ! -d "${WORKDIR}/fragments" ] && [ ! -x "${WORKDIR}/fragments" ]; then fi # are there actually any fragments? -if [ ! "$(ls -A ${WORKDIR}/fragments)" ]; then - if [ x${FORCE} = "x" ]; then +if [ ! "$(ls -A \"${WORKDIR}/fragments\")" ]; then + if [ "x${FORCE}" = "x" ]; then echo "The fragments directory is empty, cowardly refusing to make empty config files" exit 1 fi fi -cd ${WORKDIR} +cd "${WORKDIR}" if [ "x${WARNMSG}" = "x" ]; then : > "fragments.concat" @@ -113,7 +113,7 @@ else printf '%s\n' "$WARNMSG" > "fragments.concat" fi -if [ x${ENSURE_NEWLINE} != x ]; then +if [ "x${ENSURE_NEWLINE}" != "x" ]; then find fragments/ -type f -follow -print0 | xargs -0 -I '{}' sh -c 'if [ -n "$(tail -c 1 < {} )" ]; then echo >> {} ; fi' fi @@ -127,13 +127,13 @@ do done IFS=$IFS_BACKUP -if [ x${TEST} = "x" ]; then +if [ "x${TEST}" = "x" ]; then # This is a real run, copy the file to outfile - cp fragments.concat ${OUTFILE} + cp fragments.concat "${OUTFILE}" RETVAL=$? else # Just compare the result to outfile to help the exec decide - cmp ${OUTFILE} fragments.concat + cmp "${OUTFILE}" fragments.concat RETVAL=$? fi From 8a500af5ee2f62149ef2a246dd66fd905296c331 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Mon, 23 Dec 2013 13:23:49 -0800 Subject: [PATCH 070/202] revert concat $warn/$warn_message param split + add deprecation warnings Partially reverting the $warn/$warn_message param split from eaf8407 as this change was unnecessarily API breaking. Instead, we are adding string/bool type validating to the $warn parameter and deprecation warnings for the usage of stringified boolean values (eg, 'true', 'on', etc.). In a future major release, the logic can be simplified to treating all string values as a warning message. --- manifests/init.pp | 36 ++++++++---- spec/system/deprecation_warnings_spec.rb | 48 +++++++++++++++ spec/system/warn_spec.rb | 75 ++++++++++++++++++++++-- spec/unit/defines/concat_spec.rb | 70 +++++++++++----------- 4 files changed, 174 insertions(+), 55 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index ecb0d2b..fc78157 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -21,8 +21,6 @@ # [*warn*] # Adds a normal shell style comment top of the file indicating that it is # built by puppet -# [*warn_message*] -# A custom message string that overides the default. # [*force*] # [*backup*] # Controls the filebucketing behavior of the final file and see File type @@ -51,7 +49,7 @@ # # * The exec can notified using Exec["concat_/path/to/file"] or # Exec["concat_/path/to/directory"] -# * The final file can be referened as File["/path/to/file"] or +# * The final file can be referenced as File["/path/to/file"] or # File["concat_/path/to/file"] # define concat( @@ -61,7 +59,6 @@ define concat( $group = undef, $mode = '0644', $warn = false, - $warn_message = undef, $force = false, $backup = 'puppet', $replace = true, @@ -74,8 +71,9 @@ define concat( validate_string($owner) validate_string($group) validate_string($mode) - validate_bool($warn) - validate_string($warn_message) + if ! (is_string($warn) or $warn == true or $warn == false) { + fail('$warn is not a string or boolean') + } validate_bool($force) validate_string($backup) validate_bool($replace) @@ -93,17 +91,29 @@ define concat( $concat_name = 'fragments.concat.out' $script_command = $concat::setup::script_command $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' + $bool_warn_message = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' - if $warn == true { - $use_warn_message = $warn_message ? { - undef => $default_warn_message, - default => $warn_message, + case $warn { + true: { + $warn_message = $default_warn_message + } + 'true', 'yes', 'on': { + warning($bool_warn_message) + $warn_message = $default_warn_message + } + false: { + $warn_message = '' + } + 'false', 'no', 'off': { + warning($bool_warn_message) + $warn_message = '' + } + default: { + $warn_message = $warn } - } else { - $use_warn_message = undef } - $warnmsg_escaped = regsubst($use_warn_message, '\'', '\'\\\'\'', 'G') + $warnmsg_escaped = regsubst($warn_message, '\'', '\'\\\'\'', 'G') $warnflag = $warnmsg_escaped ? { '' => '', default => "-w '${warnmsg_escaped}'" diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/system/deprecation_warnings_spec.rb index 3c28d04..75e4ccf 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/system/deprecation_warnings_spec.rb @@ -27,6 +27,54 @@ describe 'deprecation warnings' do it_behaves_like 'has_warning', pp, w end + context 'concat warn parameter =>' do + ['true', 'yes', 'on'].each do |warn| + context warn do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain 'bar' } + end + end + end + + ['false', 'no', 'off'].each do |warn| + context warn do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain 'bar' } + end + end + end + end + context 'concat::fragment ensure parameter' do context 'target file exists' do before(:all) do diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb index 405dfd6..053d6d6 100644 --- a/spec/system/warn_spec.rb +++ b/spec/system/warn_spec.rb @@ -1,12 +1,9 @@ require 'spec_helper_system' -describe 'basic concat test' do - context 'should run successfully' do +describe 'concat warn =>' do + context 'true should enable default warning message' do pp = <<-EOS concat { '/tmp/concat/file': - owner => root, - group => root, - mode => '0644', warn => true, } @@ -38,4 +35,72 @@ describe 'basic concat test' do it { should contain '2' } end end + context 'false should not enable default warning message' do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end + context '# foo should overide default warning message' do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '# foo', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# foo' } + it { should contain '1' } + it { should contain '2' } + end + end end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index d284f3a..08cf2ec 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -14,7 +14,6 @@ describe 'concat', :type => :define do :group => nil, :mode => '0644', :warn => false, - :warn_message => nil, :force => false, :backup => 'puppet', :replace => true, @@ -86,9 +85,25 @@ describe 'concat', :type => :define do "-d #{concatdir}/#{safe_name}" # flag order: fragdir, warnflag, forceflag, orderflag, newlineflag - if p[:warn] - message = p[:warn_message] || default_warn_message - cmd += " -w \'#{message}\'" + if p.has_key?(:warn) + case p[:warn] + when TrueClass + message = default_warn_message + when 'true', 'yes', 'on' + # should generate a stringified boolean warning + message = default_warn_message + when FalseClass + message = nil + when 'false', 'no', 'off' + # should generate a stringified boolean warning + message = nil + else + message = p[:warn] + end + + unless message.nil? + cmd += " -w \'#{message}\'" + end end cmd += " -f" if p[:force] @@ -243,52 +258,33 @@ describe 'concat', :type => :define do end # mode => context 'warn =>' do - [true, false].each do |warn| + [true, false, '# foo'].each do |warn| context warn do it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } end end + context '(stringified boolean)' do + ['true', 'yes', 'on', 'false', 'no', 'off'].each do |warn| + context warn do + it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end + end + context '123' do let(:title) { '/etc/foo.bar' } let(:params) {{ :warn => 123 }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + expect { should }.to raise_error(Puppet::Error, /is not a string or boolean/) end end end # warn => - context 'warn_message =>' do - context '# ashp replaced your file' do - # should do nothing unless warn == true; - # but we can't presently test that because concatfragments.sh isn't run - # from rspec-puppet tests - context 'warn =>' do - context 'true' do - it_behaves_like 'concat', '/etc/foo.bar', { - :warn => true, - :warn_message => '# ashp replaced your file' - } - end - - context 'false' do - it_behaves_like 'concat', '/etc/foo.bar', { - :warn => false, - :warn_message => '# ashp replaced your file' - } - end - end - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :warn_message => false }} - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) - end - end - end # warn_message => - context 'force =>' do [true, false].each do |force| context force do From 2583d85a42d6fc37c0d9b4fb241318bbf850ca92 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sun, 29 Dec 2013 11:19:09 -0700 Subject: [PATCH 071/202] add README section on API deprecations since version 1.0.0 --- README.md | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/README.md b/README.md index aa8b0a0..04bf9e0 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ * [Setup requirements](#setup-requirements) * [Beginning with concat](#beginning-with-concat) 4. [Usage - Configuration options and additional functionality](#usage) + * [API _deprecations_](#api-deprecations) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 5. [Limitations - OS compatibility, etc.](#limitations) 6. [Development - Guide for contributing to the module](#development) @@ -55,6 +56,9 @@ concat::fragment { 'tmpfile': ##Usage +Please be aware that there have been a number of [API +_deprecations_](#api-deprecations). + If you wanted a /etc/motd file that listed all the major modules on the machine. And that would be maintained automatically even if you just remove the include lines for other modules you could @@ -275,6 +279,137 @@ Control the filebucket behavior for the fragment. ######Example - backup => 'puppet' +### API _deprecations_ + +#### Since version `1.0.0` + +##### `concat{}` `warn` parameter + +```puppet +concat { '/tmp/file': + ensure => present, + warn => 'true', # generates stringified boolean value warning +} +``` + +Using stringified Boolean values as the `warn` parameter to `concat` is +deprecated, generates a catalog compile time warning, and will be silently +treated as the concatenated file header/warning message in a future release. + +The following strings are considered a stringified Boolean value: + + * `'true'` + * `'yes'` + * `'on'` + * `'false'` + * `'no'` + * `'off'` + +Please migrate to using the Puppet DSL's native [Boolean data +type](http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#booleans). + +##### `concat{}` `gnu` parameter + +```puppet +concat { '/tmp/file': + ensure => present, + gnu => $foo, # generates deprecation warning +} +``` + +The `gnu` parameter to `concat` is deprecated, generates a catalog compile time +warning, and has no effect. This parameter will be removed in a future +release. + +Note that this parameter was silently ignored in the `1.0.0` release. + +##### `concat::fragment{}` `ensure` parameter + +```puppet +concat::fragment { 'cpuinfo': + ensure => '/proc/cpuinfo', # generates deprecation warning + target => '/tmp/file', +} +``` + +Passing a value other than `'present'` or `'absent'` as the `ensure` parameter +to `concat::fragment` is deprecated and generates a catalog compile time +warning. The warning will become a catalog compilation failure in a future +release. + +This type emulates the Puppet core `file` type's disfavored [`ensure` +semantics](http://docs.puppetlabs.com/references/latest/type.html#file-attribute-ensure) +of treating a file path as a directive to create a symlink. This feature is +problematic in several ways. It copies an API semantic of another type that is +both frowned upon and not generally well known. It's behavior may be +surprising in that the target concatenated file will not be a symlink nor is +there any common file system that has a concept of a section of a plain file +being symbolically linked to another file. Additionally, the behavior is +generally inconsistent with most Puppet types in that a missing source file +will be silently ignored. + +If you want to use the content of a file as a fragment please use the `source` +parameter. + +##### `concat::fragment{}` `mode/owner/group` parameters + +```puppet +concat::fragment { 'foo': + target => '/tmp/file', + content => 'foo', + mode => $mode, # generates deprecation warning + owner => $owner, # generates deprecation warning + group => $group, # generates deprecation warning +} +``` + +The `mode` parameter to `concat::fragment` is deprecated, generates a catalog compile time warning, and has no effect. + +The `owner` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. + +The `group` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. + +These parameters had no user visible effect in version `1.0.0` and will be +removed in a future release. + +##### `concat::fragment{}` `backup` parameter + +```puppet +concat::fragment { 'foo': + target => '/tmp/file', + content => 'foo', + backup => 'bar', # generates deprecation warning +} +``` + +The `backup` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. It will be removed in a future +release. + +In the `1.0.0` release this parameter controlled file bucketing of the file +fragment. Bucketting the fragment(s) is redundant with bucketting the final +concatenated file and this feature has been removed. + +##### `class { 'concat::setup': }` + +```puppet +include concat::setup # generates deprecation warning + +class { 'concat::setup: } # generates deprecation warning +``` + +The `concat::setup` class is deprecated as a public API of this module and +should no longer be directly included in the manifest. This class may be +removed in a future release. + +##### Parameter validation + +While not an API depreciation, users should be aware that all public parameters +in this module are now validated for at least variable type. This may cause +validation errors in a manifest that was previously silently misbehaving. + ##Limitations This module has been tested on: From acd15c913dad2ddbab367e1800a38c0ac7e7c5f7 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 3 Jan 2014 16:34:28 -0700 Subject: [PATCH 072/202] work around RubyGems 2.2.0 breaking ruby 1.8.7 --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3fed52d..368af1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,12 @@ branches: only: - master language: ruby +# work around RubyGems 2.2.0 breaking ruby 1.8.7 +# https://github.com/rubygems/rubygems/pull/763 +# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 +before_install: + - gem update --system 2.1.11 + - gem --version bundler_args: --without development script: bundle exec rake spec SPEC_OPTS='--format documentation' after_success: From a225075f9cd3a8033a56c3a226ce2285ab30fbc3 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 3 Jan 2014 18:17:48 -0500 Subject: [PATCH 073/202] 1.1.0 release. --- CHANGELOG | 43 +++++++++++++++++++++++++++++++++++++++++++ Modulefile | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f8141d7..61eda77 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,46 @@ +2014-01-03 1.1.0 + +Summary: + +This release of concat was 90% written by Joshua Hoblitt, and the module team +would like to thank him for the huge amount of work he put into this release. + +This module deprecates a bunch of old parameters and usage patterns, modernizes +much of the manifest code, simplifies a whole bunch of logic and makes +improvements to almost all parts of the module. + +The other major feature is windows support, courtesy of luisfdez, with an +alternative version of the concat bash script in ruby. We've attempted to +ensure that there are no backwards incompatible changes, all users of 1.0.0 +should be able to use 1.1.0 without any failures, but you may find deprecation +warnings and we'll be aggressively moving for a 2.0 to remove those too. + +Removed: +- Puppet 0.24 support. +- Filebucket backup of all file resources except the target concatenated file. +- Default owner/user/group values. +- Purging of long unused /usr/local/bin/concatfragments.sh + +Features: +- Windows support via a ruby version of the concat bash script. +- Huge amount of acceptance testing work added. +- Documentation (README) completely rewritten. +- New parameters in concat: + - `ensure`: Controls if the file should be present/absent at all. +- Remove requirement to include concat::setup in manifests. +- Made `gnu` parameter deprecated. +- Added parameter validation. + +Bugfixes: +- Ensure concat::setup runs before concat::fragment in all cases. +- Pluginsync references updated for modern Puppet. +- Fix incorrect group parameter. +- Use $owner instead of $id to avoid confusion with $::id +- Compatibility fixes for Puppet 2.7/ruby 1.8.7 +- Use LC_ALL=C instead of LANG=C +- Always exec the concatfragments script as root when running as root. +- Syntax and other cleanup changes. + 2013-08-09 1.0.0 Summary: diff --git a/Modulefile b/Modulefile index 249438e..f69b2e7 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.0' +version '2.0.0-rc1' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From fad58dc50a7363251be9d93ed0a2bff29a18f1de Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 3 Jan 2014 18:22:57 -0500 Subject: [PATCH 074/202] Add information on deprecations. --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 61eda77..829b111 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,9 @@ ensure that there are no backwards incompatible changes, all users of 1.0.0 should be able to use 1.1.0 without any failures, but you may find deprecation warnings and we'll be aggressively moving for a 2.0 to remove those too. +For further information on deprecations, please read: +https://github.com/puppetlabs/puppetlabs-concat/blob/master/README.md#api-deprecations + Removed: - Puppet 0.24 support. - Filebucket backup of all file resources except the target concatenated file. From df36f0056b1146896c1c56e49e267365fc6f512a Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Tue, 7 Jan 2014 10:28:57 -0500 Subject: [PATCH 075/202] remove workaround for Rubygems 2.2.0 bug https://github.com/rubygems/rubygems/pull/763 is merged and released in Rubygems 2.2.1. A forced downgrade is no longer required. --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 368af1e..3fed52d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,6 @@ branches: only: - master language: ruby -# work around RubyGems 2.2.0 breaking ruby 1.8.7 -# https://github.com/rubygems/rubygems/pull/763 -# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 -before_install: - - gem update --system 2.1.11 - - gem --version bundler_args: --without development script: bundle exec rake spec SPEC_OPTS='--format documentation' after_success: From 8e268be6f0ad728aff7dedef868f0c8a7f368066 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 7 Jan 2014 11:38:28 -0500 Subject: [PATCH 076/202] Correct the version we're releasing. --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index f69b2e7..2e9b6b9 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '2.0.0-rc1' +version '1.1.0-rc1' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From 162048133d1579a4c6d0268d8e0d29fecdbb73d9 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 7 Jan 2014 11:56:08 -0500 Subject: [PATCH 077/202] Add workaround back in, problems still happening. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3fed52d..90e7d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,12 @@ script: bundle exec rake spec SPEC_OPTS='--format documentation' after_success: - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng - .forge-releng/publish +# work around RubyGems 2.2.0 breaking ruby 1.8.7 +# https://github.com/rubygems/rubygems/pull/763 +# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 +before_install: + - gem update --system 2.1.11 + - gem --version rvm: - 1.8.7 - 1.9.3 From 20e8d6e4f65259be59bb0212b4d68dfa6e457e6f Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 15 Jan 2014 11:16:49 -0800 Subject: [PATCH 078/202] Convert specs to beaker and increase coverage --- .nodeset.yml | 35 ----- Gemfile | 4 +- Rakefile | 1 - spec/acceptance/backup_spec.rb | 107 ++++++++++++++ spec/acceptance/basic_spec.rb | 12 ++ spec/{system => acceptance}/concat_spec.rb | 36 ++--- .../deprecation_warnings_spec.rb | 91 +++++------- spec/{system => acceptance}/empty_spec.rb | 13 +- .../fragment_source_spec.rb | 34 ++--- spec/acceptance/newline_spec.rb | 57 ++++++++ spec/acceptance/nodesets/centos-59-x64.yml | 10 ++ spec/acceptance/nodesets/centos-64-x64-pe.yml | 12 ++ spec/acceptance/nodesets/centos-64-x64.yml | 10 ++ spec/acceptance/nodesets/debian-607-x64.yml | 10 ++ spec/acceptance/nodesets/debian-70rc1-x64.yml | 10 ++ spec/acceptance/nodesets/default.yml | 10 ++ spec/acceptance/nodesets/fedora-18-x64.yml | 10 ++ spec/acceptance/nodesets/sles-11sp1-x64.yml | 10 ++ .../nodesets/ubuntu-server-10044-x64.yml | 10 ++ .../nodesets/ubuntu-server-12042-x64.yml | 10 ++ spec/acceptance/order_spec.rb | 137 ++++++++++++++++++ spec/{system => acceptance}/replace_spec.rb | 72 ++++----- .../symbolic_name_spec.rb | 11 +- spec/{system => acceptance}/warn_spec.rb | 29 ++-- spec/spec_helper_acceptance.rb | 42 ++++++ spec/spec_helper_system.rb | 35 ----- spec/system/basic_spec.rb | 13 -- 27 files changed, 574 insertions(+), 257 deletions(-) delete mode 100644 .nodeset.yml create mode 100644 spec/acceptance/backup_spec.rb create mode 100644 spec/acceptance/basic_spec.rb rename spec/{system => acceptance}/concat_spec.rb (73%) rename spec/{system => acceptance}/deprecation_warnings_spec.rb (74%) rename spec/{system => acceptance}/empty_spec.rb (53%) rename spec/{system => acceptance}/fragment_source_spec.rb (80%) create mode 100644 spec/acceptance/newline_spec.rb create mode 100644 spec/acceptance/nodesets/centos-59-x64.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64-pe.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64.yml create mode 100644 spec/acceptance/nodesets/debian-607-x64.yml create mode 100644 spec/acceptance/nodesets/debian-70rc1-x64.yml create mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/fedora-18-x64.yml create mode 100644 spec/acceptance/nodesets/sles-11sp1-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-10044-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 spec/acceptance/order_spec.rb rename spec/{system => acceptance}/replace_spec.rb (73%) rename spec/{system => acceptance}/symbolic_name_spec.rb (66%) rename spec/{system => acceptance}/warn_spec.rb (72%) create mode 100644 spec/spec_helper_acceptance.rb delete mode 100644 spec/spec_helper_system.rb delete mode 100644 spec/system/basic_spec.rb diff --git a/.nodeset.yml b/.nodeset.yml deleted file mode 100644 index cbd0d57..0000000 --- a/.nodeset.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -default_set: 'centos-64-x64' -sets: - 'centos-59-x64': - nodes: - "main.foo.vm": - prefab: 'centos-59-x64' - 'centos-64-x64': - nodes: - "main.foo.vm": - prefab: 'centos-64-x64' - 'fedora-18-x64': - nodes: - "main.foo.vm": - prefab: 'fedora-18-x64' - 'debian-607-x64': - nodes: - "main.foo.vm": - prefab: 'debian-607-x64' - 'debian-70rc1-x64': - nodes: - "main.foo.vm": - prefab: 'debian-70rc1-x64' - 'ubuntu-server-10044-x64': - nodes: - "main.foo.vm": - prefab: 'ubuntu-server-10044-x64' - 'ubuntu-server-12042-x64': - nodes: - "main.foo.vm": - prefab: 'ubuntu-server-12042-x64' - 'sles-11sp1-x64': - nodes: - "main.foo.vm": - prefab: 'sles-11sp1-x64' diff --git a/Gemfile b/Gemfile index d5738af..e381bc0 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,10 @@ group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system-puppet', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false gem 'puppet-lint', :require => false gem 'serverspec', :require => false - gem 'rspec-system-serverspec', :require => false gem 'pry', :require => false end diff --git a/Rakefile b/Rakefile index edd0a23..23aea87 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,4 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'rspec-system/rake_task' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.send('disable_80chars') diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb new file mode 100644 index 0000000..5a740b0 --- /dev/null +++ b/spec/acceptance/backup_spec.rb @@ -0,0 +1,107 @@ +require 'spec_helper_acceptance' + +describe 'concat backup parameter' do + context '=> puppet' do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => 'puppet', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end + + context '=> .backup' do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + # XXX Puppet doesn't mention anything about filebucketing with a given + # extension like .backup + it 'applies the manifest twice no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + describe file('/tmp/concat/file.backup') do + it { should be_file } + it { should contain 'old contents' } + end + end + + # XXX The backup parameter uses validate_string() and thus can't be the + # boolean false value, but the string 'false' has the same effect in Puppet 3 + context "=> 'false'" do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to_not match(/Filebucketed/) + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end +end diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100644 index 0000000..5d78d7b --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper_acceptance' + +# Here we put the more basic fundamental tests, ultra obvious stuff. +describe "basic tests:" do + it 'copies the module across' do + # No point diagnosing any more if the module wasn't copied properly + shell "ls #{default['distmoduledir']}/concat" do |r| + expect(r.stdout).to match(/Modulefile/) + expect(r.stderr).to be_empty + end + end +end diff --git a/spec/system/concat_spec.rb b/spec/acceptance/concat_spec.rb similarity index 73% rename from spec/system/concat_spec.rb rename to spec/acceptance/concat_spec.rb index ee754f6..8fc0959 100644 --- a/spec/system/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,53 +1,50 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'basic concat test' do shared_examples 'successfully_applied' do |pp| - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/var/lib/puppet/concat') do + describe file("#{default['puppetvardir']}/concat") do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file('/var/lib/puppet/concat/bin') do + describe file("#{default['puppetvardir']}/concat/bin") do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file('/var/lib/puppet/concat/bin/concatfragments.sh') do + describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do it { should be_file } it { should be_owned_by 'root' } #it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file('/var/lib/puppet/concat/_tmp_concat_file') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do it { should be_directory } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 750 } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat.out') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -86,13 +83,13 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } @@ -105,6 +102,9 @@ describe 'basic concat test' do shell "groupadd -g 42 bob" shell "useradd -u 42 -g 42 bob" end + after(:all) do + shell "userdel bob" + end pp=" concat { '/tmp/concat/file': @@ -136,14 +136,14 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } it { should be_mode 640 } it { should contain '1' } end - describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do it { should be_file } it { should be_owned_by 'root' } it { should be_grouped_into 'root' } diff --git a/spec/system/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb similarity index 74% rename from spec/system/deprecation_warnings_spec.rb rename to spec/acceptance/deprecation_warnings_spec.rb index 75e4ccf..f139d81 100644 --- a/spec/system/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -1,14 +1,11 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'deprecation warnings' do shared_examples 'has_warning'do |pp, w| - context puppet_apply(pp) do - its(:stderr) { should =~ /#{Regexp.escape(w)}/m } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should =~ /#{Regexp.escape(w)}/m } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with a stderr regex' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) + expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) end end @@ -104,40 +101,29 @@ describe 'deprecation warnings' do it { should contain 'file1 contents' } end - # check that the fragment can be changed from a symlink to a plain file + describe 'the fragment can be changed from a symlink to a plain file' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS - pp = <<-EOS - concat { '/tmp/concat/file': } - concat::fragment { 'foo': - target => '/tmp/concat/file', - content => 'new content', - } - EOS + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - describe file('/tmp/concat/file') do - it { should be_file } - it { should contain 'new content' } - it { should_not contain 'file1 contents' } + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + it { should_not contain 'file1 contents' } + end end end # target file exists context 'target does not exist' do - after(:all) do - # XXX this test may leave behind a symlink in the fragment directory - # which could cause warnings and/or breakage from the subsequent tests - # unless we clean it up. - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') - end - pp = <<-EOS concat { '/tmp/concat/file': } concat::fragment { 'foo': @@ -153,27 +139,24 @@ describe 'deprecation warnings' do it { should be_file } end - # check that the fragment can be changed from a symlink to a plain file + describe 'the fragment can be changed from a symlink to a plain file' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS - pp = <<-EOS - concat { '/tmp/concat/file': } - concat::fragment { 'foo': - target => '/tmp/concat/file', - content => 'new content', - } - EOS + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - - describe file('/tmp/concat/file') do - it { should be_file } - it { should contain 'new content' } + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + end end end # target file exists diff --git a/spec/system/empty_spec.rb b/spec/acceptance/empty_spec.rb similarity index 53% rename from spec/system/empty_spec.rb rename to spec/acceptance/empty_spec.rb index 383f478..0999528 100644 --- a/spec/system/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' -describe 'basic concat test' do +describe 'concat force empty parameter' do context 'should run successfully' do pp = <<-EOS concat { '/tmp/concat/file': @@ -11,12 +11,9 @@ describe 'basic concat test' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do diff --git a/spec/system/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb similarity index 80% rename from spec/system/fragment_source_spec.rb rename to spec/acceptance/fragment_source_spec.rb index 6ff088f..3afd534 100644 --- a/spec/system/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'concat::fragment source' do context 'should read file fragments from local system' do @@ -24,12 +24,9 @@ describe 'concat::fragment source' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/foo') do @@ -82,12 +79,9 @@ describe 'concat::fragment source' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/result_file1') do it { should be_file } @@ -127,16 +121,14 @@ describe 'concat::fragment source' do } EOS - context puppet_apply(pp) do - its(:exit_code) { should_not be_zero } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } + it 'applies the manifest with resource failures' do + apply_manifest(pp, :expect_failures => true) end describe file('/tmp/concat/fail_no_source') do - #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. - it { should_not be_file } - it { should_not be_directory } + #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. + it { should_not be_file } + it { should_not be_directory } end - end + end end diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb new file mode 100644 index 0000000..1e989df --- /dev/null +++ b/spec/acceptance/newline_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper_acceptance' + +describe 'concat ensure_newline parameter' do + context '=> false' do + pp = <<-EOS + concat { '/tmp/concat/file': + ensure_newline => false, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '12' } + end + end + + context '=> true' do + pp = <<-EOS + concat { '/tmp/concat/file': + ensure_newline => true, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + #XXX ensure_newline => true causes changes on every run because the files + #are modified in place. + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain "1\n2\n" } + end + end +end diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000..2ad90b8 --- /dev/null +++ b/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - 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 + 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 new file mode 100644 index 0000000..7d9242f --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - 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 + hypervisor : vagrant +CONFIG: + type: pe diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000..0639835 --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/debian-607-x64.yml b/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000..4c8be42 --- /dev/null +++ b/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-607-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000..19181c1 --- /dev/null +++ b/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-70rc1-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000..0639835 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/fedora-18-x64.yml b/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000..624b537 --- /dev/null +++ b/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + fedora-18-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/sles-11sp1-x64.yml b/spec/acceptance/nodesets/sles-11sp1-x64.yml new file mode 100644 index 0000000..554c37a --- /dev/null +++ b/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11sp1-x64: + roles: + - 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 + 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 new file mode 100644 index 0000000..5047017 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000..1c7a34c --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb new file mode 100644 index 0000000..8bcb713 --- /dev/null +++ b/spec/acceptance/order_spec.rb @@ -0,0 +1,137 @@ +require 'spec_helper_acceptance' + +describe 'concat order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> alpha' do + pp = <<-EOS + concat { '/tmp/concat/foo': + order => 'alpha' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string10\nstring1\nsring2" } + end + end + + context '=> numeric' do + pp = <<-EOS + concat { '/tmp/concat/foo': + order => 'numeric' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring10" } + end + end +end # concat order + +describe 'concat::fragment order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> reverse order' do + pp = <<-EOS + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '15', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + # default order 10 + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '1', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string3\nstring2\nsring1" } + end + end + + context '=> normal order' do + pp = <<-EOS + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '01', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + order => '02' + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '03', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring3" } + end + end +end # concat::fragment order diff --git a/spec/system/replace_spec.rb b/spec/acceptance/replace_spec.rb similarity index 73% rename from spec/system/replace_spec.rb rename to spec/acceptance/replace_spec.rb index a0f976a..7b31e09 100644 --- a/spec/system/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -1,10 +1,10 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'replacement of' do context 'file' do context 'should not succeed' do before(:all) do - shell('mkdir /tmp/concat') + shell('mkdir -p /tmp/concat') shell('echo "file exists" > /tmp/concat/file') end after(:all) do @@ -27,12 +27,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -45,7 +42,7 @@ describe 'replacement of' do context 'should succeed' do before(:all) do - shell('mkdir /tmp/concat') + shell('mkdir -p /tmp/concat') shell('echo "file exists" > /tmp/concat/file') end after(:all) do @@ -68,12 +65,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -91,7 +85,7 @@ describe 'replacement of' do # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do - shell('mkdir /tmp/concat') + shell('mkdir -p /tmp/concat') shell('ln -s /tmp/concat/dangling /tmp/concat/file') end after(:all) do @@ -114,12 +108,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -138,7 +129,7 @@ describe 'replacement of' do # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do - shell('mkdir /tmp/concat') + shell('mkdir -p /tmp/concat') shell('ln -s /tmp/concat/dangling /tmp/concat/file') end after(:all) do @@ -161,12 +152,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -200,12 +188,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should =~ /change from directory to file failed/ } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should =~ /change from directory to file failed/ } - its(:exit_code) { should_not == 1 } + it 'applies the manifest twice with stderr for changing to file' do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) end describe file('/tmp/concat/file') do @@ -213,9 +198,11 @@ describe 'replacement of' do end end - # XXX concat's force param currently enables the creation of empty files when - # there are no fragments. The semantics either need to be changed, extended, - # or a new param introduced to control directory replacement. + # XXX concat's force param currently enables the creation of empty files + # when there are no fragments, and the replace param will only replace + # files and symlinks, not directories. The semantics either need to be + # changed, extended, or a new param introduced to control directory + # replacement. context 'should succeed', :pending => 'not yet implemented' do before(:all) do shell('mkdir -p /tmp/concat/file') @@ -240,12 +227,9 @@ describe 'replacement of' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do diff --git a/spec/system/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb similarity index 66% rename from spec/system/symbolic_name_spec.rb rename to spec/acceptance/symbolic_name_spec.rb index caae647..7267f5e 100644 --- a/spec/system/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'symbolic name' do pp = <<-EOS @@ -19,12 +19,9 @@ describe 'symbolic name' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do diff --git a/spec/system/warn_spec.rb b/spec/acceptance/warn_spec.rb similarity index 72% rename from spec/system/warn_spec.rb rename to spec/acceptance/warn_spec.rb index 053d6d6..cb0b743 100644 --- a/spec/system/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'concat warn =>' do context 'true should enable default warning message' do @@ -20,12 +20,9 @@ describe 'concat warn =>' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -54,12 +51,9 @@ describe 'concat warn =>' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do @@ -88,12 +82,9 @@ describe 'concat warn =>' do } EOS - context puppet_apply(pp) do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - its(:refresh) { should be_nil } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end describe file('/tmp/concat/file') do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..b064d68 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,42 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' + +hosts.each do |host| + if host['platform'] =~ /debian/ + on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' + end + if host.is_pe? + install_pe + else + # Install Puppet + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" + end +end + +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 => 'concat') + hosts.each do |host| + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end + + c.before(:all) do + shell('mkdir -p /tmp/concat') + end + c.after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + c.treat_symbols_as_metadata_keys_with_true_values = true +end diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb deleted file mode 100644 index 9ed91c1..0000000 --- a/spec/spec_helper_system.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'rspec-system/spec_helper' -require 'rspec-system-puppet/helpers' -require 'rspec-system-serverspec/helpers' -include Serverspec::Helper::RSpecSystem -include Serverspec::Helper::DetectOS -include RSpecSystemPuppet::Helpers - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Enable colour - c.tty = true - - c.include RSpecSystemPuppet::Helpers - - # This is where we 'setup' the nodes before running our tests - c.before :suite do - # Install puppet - puppet_install - - # Install modules and dependencies - puppet_module_install(:source => proj_root, :module_name => 'concat') - shell('puppet module install puppetlabs-stdlib') - end - - c.before(:all) do - shell('mkdir -p /tmp/concat') - end - c.after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - end - - c.treat_symbols_as_metadata_keys_with_true_values = true -end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb deleted file mode 100644 index 39ac746..0000000 --- a/spec/system/basic_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper_system' - -# Here we put the more basic fundamental tests, ultra obvious stuff. -describe "basic tests:" do - context 'make sure we have copied the module across' do - # No point diagnosing any more if the module wasn't copied properly - context shell 'ls /etc/puppet/modules/concat' do - its(:stdout) { should =~ /Modulefile/ } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end - end -end From b07f338f29c04dbcc8ba1be5a1c9c645916f5f11 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 21 Jan 2014 16:28:42 -0500 Subject: [PATCH 079/202] Fix ensure => absent with path => set. The current code doesn't correctly account for an absent with a path set, incorrectly trying to remove $name instead. Fixing this raised the issue that fragments left with no ensure will fail when absent is set as the fragdir is deleted. As a workaround for this we check the `ensure` parameter from the concat{} resource with getparam() and then pass that to the fragment if no specific ensure was passed in. This effectively ensures fragments inherit their parents ensure status. --- manifests/fragment.pp | 21 ++++++++------ manifests/init.pp | 2 +- spec/acceptance/concat_spec.rb | 50 ++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 9477653..69c1fba 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -29,16 +29,13 @@ define concat::fragment( $content = undef, $source = undef, $order = 10, - $ensure = 'present', + $ensure = undef, $mode = undef, $owner = undef, $group = undef, $backup = undef ) { validate_string($target) - if ! ($ensure in [ 'present', 'absent' ]) { - warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') - } validate_string($content) if !(is_string($source) or is_array($source)) { fail('$source is not a string or an Array.') @@ -56,6 +53,14 @@ define concat::fragment( if $backup { warning('The $backup parameter to concat::fragment is deprecated and has no effect') } + if $ensure == undef { + $_ensure = getparam(Concat[$target], 'ensure') + } else { + if ! ($ensure in [ 'present', 'absent' ]) { + warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') + } + $_ensure = $ensure + } include concat::setup @@ -71,18 +76,18 @@ define concat::fragment( # be paranoid and only allow the fragment's file resource's ensure param to # be file, absent, or a file target - $safe_ensure = $ensure ? { + $safe_ensure = $_ensure ? { '' => 'file', undef => 'file', 'file' => 'file', 'present' => 'file', 'absent' => 'absent', - default => $ensure, + default => $_ensure, } # if it looks line ensure => /target syntax was used, fish that out - if ! ($ensure in ['', 'present', 'absent', 'file' ]) { - $ensure_target = $ensure + if ! ($_ensure in ['', 'present', 'absent', 'file' ]) { + $ensure_target = $_ensure } # the file type's semantics only allows one of: ensure => /target, content, diff --git a/manifests/init.pp b/manifests/init.pp index fc78157..566e3bf 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -206,7 +206,7 @@ define concat( force => true, } - file { $name: + file { $path: ensure => absent, backup => $backup, } diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 8fc0959..e31e489 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -151,4 +151,54 @@ describe 'basic concat test' do it { should contain '2' } end end + + context 'ensure' do + context 'works when set to present with path set' do + pp=" + concat { 'file': + ensure => present, + path => '/tmp/concat/file', + mode => '0644', + } + concat::fragment { '1': + target => 'file', + content => '1', + order => '01', + } + " + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_mode 644 } + it { should contain '1' } + end + end + context 'works when set to absent with path set' do + pp=" + concat { 'file': + ensure => absent, + path => '/tmp/concat/file', + mode => '0644', + } + concat::fragment { '1': + target => 'file', + content => '1', + order => '01', + } + " + + # Can't used shared examples as this will always trigger the exec when + # absent is set. + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should_not be_file } + end + end + end end From 78e9d34670512db8648f1132c605f16d18778475 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 21 Jan 2014 17:51:26 -0500 Subject: [PATCH 080/202] Fix the tests by switching to stdlib 4.x instead of 3.x. getparam() unfortunately only arrived in 4.x, so switch. --- .fixtures.yml | 2 +- Modulefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index f7f1eba..dc6b41f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,6 +2,6 @@ fixtures: repositories: 'stdlib': repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' - ref: '3.0.0' + ref: '4.0.0' symlinks: 'concat': '#{source_dir}' diff --git a/Modulefile b/Modulefile index 2e9b6b9..c90d6f4 100644 --- a/Modulefile +++ b/Modulefile @@ -6,4 +6,4 @@ license 'Apache 2.0' summary 'Concat module' description 'Concat module' project_page 'http://github.com/puppetlabs/puppetlabs-concat' -dependency 'puppetlabs/stdlib', '>= 3.0.0' +dependency 'puppetlabs/stdlib', '>= 4.0.0' From 7c473b8de0afd102f7ed441216f8b2d571b3122a Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 23 Jan 2014 13:01:05 -0500 Subject: [PATCH 081/202] Enable fast finish in Travis http://blog.travis-ci.com/2013-11-27-fast-finishing-builds/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 90e7d0f..21ef81b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ env: - PUPPET_GEM_VERSION="~> 3.0" global: matrix: + fast_finish: true exclude: - rvm: 1.9.3 env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" From f07674346467ca2e1379f867680428579b5ae185 Mon Sep 17 00:00:00 2001 From: Max Griffiths Date: Wed, 5 Feb 2014 14:53:02 +0000 Subject: [PATCH 082/202] Update README.md pass order to concat::fragment --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 04bf9e0..60eca38 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ define motd::register($content="", $order=10) { concat::fragment{ "motd_fragment_$name": target => '/etc/motd', + order => $order, content => " -- $body\n" } } From a9eba26ab7b7b9c952e130a8afb29e6e63263386 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 11 Feb 2014 16:33:52 -0800 Subject: [PATCH 083/202] Allow custom gemsource --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e381bc0..56b9775 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :test do gem 'rake', :require => false From 5c378174e37bdb1fae0cbfe8b202efba2383fd84 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 24 Sep 2013 17:12:27 -0400 Subject: [PATCH 084/202] Ensure that ::setup runs before ::fragment in all cases. --- Gemfile | 1 - manifests/setup.pp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 783e522..d5738af 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ group :development, :test do gem 'serverspec', :require => false gem 'rspec-system-serverspec', :require => false gem 'pry', :require => false - gem 'vagrant-wrapper', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/manifests/setup.pp b/manifests/setup.pp index 2d29bf8..15be696 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -52,4 +52,8 @@ class concat::setup { '/usr/local/bin/concatfragments.sh': ensure => absent; } + + # Ensure we run setup first. + Class['concat::setup'] -> Concat::Fragment<| |> + } From 17431c02e735fa158b8518c4e98c177930662754 Mon Sep 17 00:00:00 2001 From: Aaron Blew Date: Fri, 27 Sep 2013 00:24:58 -0700 Subject: [PATCH 085/202] Help message for pluginsync now references the correct section of the config --- README.markdown | 2 +- manifests/setup.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index c9a52b3..9580c9d 100644 --- a/README.markdown +++ b/README.markdown @@ -80,7 +80,7 @@ manifest files. Known Issues: ------------- * Since puppet-concat now relies on a fact for the concat directory, - you will need to set up pluginsync = true on the [master] section of your + you will need to set up pluginsync = true on both the master and client node's '/etc/puppet/puppet.conf' for at least the first run. You have this issue if puppet fails to run on the client and you have a message similar to diff --git a/manifests/setup.pp b/manifests/setup.pp index 15be696..55d7197 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -27,7 +27,7 @@ class concat::setup { if $::concat_basedir { $concatdir = $::concat_basedir } else { - fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] section of your node's '/etc/puppet/puppet.conf'.") + fail ("\$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node's '/etc/puppet/puppet.conf'.") } $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1') From 9e187ccf36cec6700fcdb700a3a43791707d06a0 Mon Sep 17 00:00:00 2001 From: Paul Chechetin Date: Wed, 16 Oct 2013 13:07:31 +0400 Subject: [PATCH 086/202] Replace LANG => LC_ALL --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 570d553..88fe0e7 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -121,7 +121,7 @@ fi IFS_BACKUP=$IFS IFS=' ' -for fragfile in `find fragments/ -type f -follow | LANG=C sort ${SORTARG}` +for fragfile in `find fragments/ -type f -follow | LC_ALL=C sort ${SORTARG}` do cat $fragfile >> "fragments.concat" done From 596cec14be85b8a20fc710980816f696553b2078 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 12 Feb 2014 16:41:41 -0500 Subject: [PATCH 087/202] Port over acceptance tests from master. --- Gemfile | 6 +- Rakefile | 5 +- spec/acceptance/backup_spec.rb | 110 ++++++++ spec/acceptance/basic_spec.rb | 12 + spec/acceptance/concat_spec.rb | 112 ++++++++ spec/acceptance/empty_spec.rb | 24 ++ spec/acceptance/fragment_source_spec.rb | 137 ++++++++++ spec/acceptance/newline_spec.rb | 59 +++++ spec/acceptance/nodesets/centos-59-x64.yml | 10 + spec/acceptance/nodesets/centos-64-x64-pe.yml | 12 + spec/acceptance/nodesets/centos-64-x64.yml | 10 + spec/acceptance/nodesets/debian-607-x64.yml | 10 + spec/acceptance/nodesets/debian-70rc1-x64.yml | 10 + spec/acceptance/nodesets/default.yml | 10 + spec/acceptance/nodesets/fedora-18-x64.yml | 10 + spec/acceptance/nodesets/sles-11sp1-x64.yml | 10 + .../nodesets/ubuntu-server-10044-x64.yml | 10 + .../nodesets/ubuntu-server-12042-x64.yml | 10 + spec/acceptance/order_spec.rb | 141 ++++++++++ spec/acceptance/replace_spec.rb | 247 ++++++++++++++++++ spec/acceptance/symbolic_name_spec.rb | 33 +++ spec/acceptance/warn_spec.rb | 100 +++++++ spec/spec_helper_acceptance.rb | 42 +++ 23 files changed, 1126 insertions(+), 4 deletions(-) create mode 100644 spec/acceptance/backup_spec.rb create mode 100644 spec/acceptance/basic_spec.rb create mode 100644 spec/acceptance/concat_spec.rb create mode 100644 spec/acceptance/empty_spec.rb create mode 100644 spec/acceptance/fragment_source_spec.rb create mode 100644 spec/acceptance/newline_spec.rb create mode 100644 spec/acceptance/nodesets/centos-59-x64.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64-pe.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64.yml create mode 100644 spec/acceptance/nodesets/debian-607-x64.yml create mode 100644 spec/acceptance/nodesets/debian-70rc1-x64.yml create mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/fedora-18-x64.yml create mode 100644 spec/acceptance/nodesets/sles-11sp1-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-10044-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 spec/acceptance/order_spec.rb create mode 100644 spec/acceptance/replace_spec.rb create mode 100644 spec/acceptance/symbolic_name_spec.rb create mode 100644 spec/acceptance/warn_spec.rb create mode 100644 spec/spec_helper_acceptance.rb diff --git a/Gemfile b/Gemfile index d5738af..56b9775 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,13 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system-puppet', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false gem 'puppet-lint', :require => false gem 'serverspec', :require => false - gem 'rspec-system-serverspec', :require => false gem 'pry', :require => false end diff --git a/Rakefile b/Rakefile index bb60173..23aea87 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,5 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'rspec-system/rake_task' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_quoted_booleans') diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb new file mode 100644 index 0000000..98694d1 --- /dev/null +++ b/spec/acceptance/backup_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper_acceptance' + +describe 'concat backup parameter' do + context '=> puppet' do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + backup => 'puppet', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end + + context '=> .backup' do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + # XXX Puppet doesn't mention anything about filebucketing with a given + # extension like .backup + it 'applies the manifest twice no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + describe file('/tmp/concat/file.backup') do + it { should be_file } + it { should contain 'old contents' } + end + end + + # XXX The backup parameter uses validate_string() and thus can't be the + # boolean false value, but the string 'false' has the same effect in Puppet 3 + context "=> 'false'" do + before :all do + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + after :all do + shell('rm -rf /tmp/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to_not match(/Filebucketed/) + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end +end diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100644 index 0000000..5d78d7b --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper_acceptance' + +# Here we put the more basic fundamental tests, ultra obvious stuff. +describe "basic tests:" do + it 'copies the module across' do + # No point diagnosing any more if the module wasn't copied properly + shell "ls #{default['distmoduledir']}/concat" do |r| + expect(r.stdout).to match(/Modulefile/) + expect(r.stderr).to be_empty + end + end +end diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb new file mode 100644 index 0000000..a4982c1 --- /dev/null +++ b/spec/acceptance/concat_spec.rb @@ -0,0 +1,112 @@ +require 'spec_helper_acceptance' + +describe 'basic concat test' do + + shared_examples 'successfully_applied' do |pp| + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + end + + context 'owner/group root' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + owner => 'root', + group => 'root', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + end + end + + context 'owner/group non-root' do + before(:all) do + shell "groupadd -g 42 bob" + shell "useradd -u 42 -g 42 bob" + end + after(:all) do + shell "userdel bob" + end + + pp=" + concat { '/tmp/concat/file': + owner => 'bob', + group => 'bob', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + " + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_owned_by 'bob' } + it { should be_grouped_into 'bob' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + it { should contain '1' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + it { should contain '2' } + end + end +end diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb new file mode 100644 index 0000000..0999528 --- /dev/null +++ b/spec/acceptance/empty_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper_acceptance' + +describe 'concat force empty parameter' do + context 'should run successfully' do + pp = <<-EOS + concat { '/tmp/concat/file': + owner => root, + group => root, + mode => '0644', + force => true, + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '1\n2' } + end + end +end diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb new file mode 100644 index 0000000..6c93f0a --- /dev/null +++ b/spec/acceptance/fragment_source_spec.rb @@ -0,0 +1,137 @@ +require 'spec_helper_acceptance' + +describe 'concat::fragment source' do + context 'should read file fragments from local system' do + before(:all) do + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + source => '/tmp/concat/file1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string1 contents', + } + concat::fragment { '3': + target => '/tmp/concat/foo', + source => '/tmp/concat/file2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain 'file1 contents' } + it { should contain 'string1 contents' } + it { should contain 'file2 contents' } + end + end # should read file fragments from local system + + context 'should create files containing first match only.' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/result_file1': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/concat/result_file2': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/concat/result_file3': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/result_file1', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + order => '01', + } + concat::fragment { '2': + target => '/tmp/concat/result_file2', + source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], + order => '01', + } + concat::fragment { '3': + target => '/tmp/concat/result_file3', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + order => '01', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + describe file('/tmp/concat/result_file1') do + it { should be_file } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } + end + describe file('/tmp/concat/result_file2') do + it { should be_file } + it { should contain 'file2 contents' } + it { should_not contain 'file1 contents' } + end + describe file('/tmp/concat/result_file3') do + it { should be_file } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } + end + end + + context 'should fail if no match on source.' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/fail_no_source': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/fail_no_source', + source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], + order => '01', + } + EOS + + it 'applies the manifest with resource failures' do + apply_manifest(pp, :expect_failures => true) + end + describe file('/tmp/concat/fail_no_source') do + #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. + it { should_not be_file } + it { should_not be_directory } + end + end +end + diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb new file mode 100644 index 0000000..996f99e --- /dev/null +++ b/spec/acceptance/newline_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper_acceptance' + +describe 'concat ensure_newline parameter' do + context '=> false' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + ensure_newline => false, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '12' } + end + end + + context '=> true' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + ensure_newline => true, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :expect_changes => true).stderr).to eq("") + #XXX ensure_newline => true causes changes on every run because the files + #are modified in place. + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain "1\n2\n" } + end + end +end diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000..2ad90b8 --- /dev/null +++ b/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - 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 + 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 new file mode 100644 index 0000000..7d9242f --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - 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 + hypervisor : vagrant +CONFIG: + type: pe diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000..0639835 --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/debian-607-x64.yml b/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000..4c8be42 --- /dev/null +++ b/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-607-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000..19181c1 --- /dev/null +++ b/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-70rc1-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000..0639835 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/fedora-18-x64.yml b/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000..624b537 --- /dev/null +++ b/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + fedora-18-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/sles-11sp1-x64.yml b/spec/acceptance/nodesets/sles-11sp1-x64.yml new file mode 100644 index 0000000..554c37a --- /dev/null +++ b/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11sp1-x64: + roles: + - 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 + 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 new file mode 100644 index 0000000..5047017 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000..1c7a34c --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb new file mode 100644 index 0000000..8a1af6f --- /dev/null +++ b/spec/acceptance/order_spec.rb @@ -0,0 +1,141 @@ +require 'spec_helper_acceptance' + +describe 'concat order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> alpha' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/foo': + order => 'alpha' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string10\nstring1\nsring2" } + end + end + + context '=> numeric' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/foo': + order => 'numeric' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring10" } + end + end +end # concat order + +describe 'concat::fragment order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> reverse order' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '15', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + # default order 10 + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '1', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string3\nstring2\nsring1" } + end + end + + context '=> normal order' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '01', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + order => '02' + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '03', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring3" } + end + end +end # concat::fragment order diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb new file mode 100644 index 0000000..4a305e1 --- /dev/null +++ b/spec/acceptance/replace_spec.rb @@ -0,0 +1,247 @@ +require 'spec_helper_acceptance' + +describe 'replacement of' do + context 'file' do + context 'should not succeed' do + before(:all) do + shell('mkdir -p /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + replace => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'file exists' } + it { should_not contain '1' } + it { should_not contain '2' } + end + end + + context 'should succeed' do + before(:all) do + shell('mkdir -p /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain 'file exists' } + it { should contain '1' } + it { should contain '2' } + end + end + end # file + + context 'symlink' do + context 'should not succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir -p /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + replace => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_linked_to '/tmp/concat/dangling' } + end + + describe file('/tmp/concat/dangling') do + # XXX serverspec does not have a matcher for 'exists' + it { should_not be_file } + it { should_not be_directory } + end + end + + context 'should succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir -p /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end + end + end # symlink + + context 'directory' do + context 'should not succeed' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with stderr for changing to file' do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) + end + + describe file('/tmp/concat/file') do + it { should be_directory } + end + end + + # XXX concat's force param currently enables the creation of empty files + # when there are no fragments, and the replace param will only replace + # files and symlinks, not directories. The semantics either need to be + # changed, extended, or a new param introduced to control directory + # replacement. + context 'should succeed', :pending => 'not yet implemented' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + force => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + end + end + end # directory +end diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb new file mode 100644 index 0000000..b1b512f --- /dev/null +++ b/spec/acceptance/symbolic_name_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper_acceptance' + +describe 'symbolic name' do + pp = <<-EOS + include concat::setup + concat { 'not_abs_path': + path => '/tmp/concat/file', + } + + concat::fragment { '1': + target => 'not_abs_path', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => 'not_abs_path', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end +end diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb new file mode 100644 index 0000000..e19c6b5 --- /dev/null +++ b/spec/acceptance/warn_spec.rb @@ -0,0 +1,100 @@ +require 'spec_helper_acceptance' + +describe 'concat warn =>' do + context 'true should enable default warning message' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + warn => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end + context 'false should not enable default warning message' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + warn => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end + context '# foo should overide default warning message' do + pp = <<-EOS + include concat::setup + concat { '/tmp/concat/file': + warn => '# foo', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# foo' } + it { should contain '1' } + it { should contain '2' } + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..b064d68 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,42 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' + +hosts.each do |host| + if host['platform'] =~ /debian/ + on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' + end + if host.is_pe? + install_pe + else + # Install Puppet + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" + end +end + +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 => 'concat') + hosts.each do |host| + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end + + c.before(:all) do + shell('mkdir -p /tmp/concat') + end + c.after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + c.treat_symbols_as_metadata_keys_with_true_values = true +end From a2bf6e26a1758391215032478eae7b9ad7edf1b6 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 12 Feb 2014 20:01:00 -0500 Subject: [PATCH 088/202] Prepare 1.0.1 release. --- CHANGELOG | 12 ++++++++++++ Modulefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f8141d7..a36cbac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +2014-02-12 1.0.1 + +Summary: + +Minor bugfixes for sorting of fragments and ordering of resources. + +Bugfixes: +- LANG => C replaced with LC_ALL => C to reduce spurious recreation of +fragments. +- Corrected pluginsync documentation. +- Ensure concat::setup always runs before fragments. + 2013-08-09 1.0.0 Summary: diff --git a/Modulefile b/Modulefile index 8515b17..7f223b8 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.0' +version '1.0.1' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From 1edafdcf42c08e1c434d51c1cdc523fca612e4d3 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 11:15:53 -0800 Subject: [PATCH 089/202] Don't remove /tmp/concat in after :each If the spec files are run in a random order, removing /tmp/concat after certain tests could cause the next tests to fail if they do not recreate this directory. --- spec/acceptance/backup_spec.rb | 12 +++--------- spec/acceptance/basic_spec.rb | 12 ------------ 2 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 spec/acceptance/basic_spec.rb diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 98694d1..e6bbd17 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -3,12 +3,10 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do context '=> puppet' do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS include concat::setup @@ -37,12 +35,10 @@ describe 'concat backup parameter' do context '=> .backup' do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS include concat::setup @@ -76,12 +72,10 @@ describe 'concat backup parameter' do # boolean false value, but the string 'false' has the same effect in Puppet 3 context "=> 'false'" do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS include concat::setup diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb deleted file mode 100644 index 5d78d7b..0000000 --- a/spec/acceptance/basic_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper_acceptance' - -# Here we put the more basic fundamental tests, ultra obvious stuff. -describe "basic tests:" do - it 'copies the module across' do - # No point diagnosing any more if the module wasn't copied properly - shell "ls #{default['distmoduledir']}/concat" do |r| - expect(r.stdout).to match(/Modulefile/) - expect(r.stderr).to be_empty - end - end -end From 35c0d2354fa371c0560449da4fc8b4163b383639 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 11:15:53 -0800 Subject: [PATCH 090/202] Don't remove /tmp/concat in after :each If the spec files are run in a random order, removing /tmp/concat after certain tests could cause the next tests to fail if they do not recreate this directory. (cherry picked from commit 1edafdcf42c08e1c434d51c1cdc523fca612e4d3) --- spec/acceptance/backup_spec.rb | 12 +++--------- spec/acceptance/basic_spec.rb | 12 ------------ 2 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 spec/acceptance/basic_spec.rb diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 5a740b0..7b2858d 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -3,12 +3,10 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do context '=> puppet' do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS concat { '/tmp/concat/file': @@ -36,12 +34,10 @@ describe 'concat backup parameter' do context '=> .backup' do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS concat { '/tmp/concat/file': @@ -74,12 +70,10 @@ describe 'concat backup parameter' do # boolean false value, but the string 'false' has the same effect in Puppet 3 context "=> 'false'" do before :all do + shell('rm -rf /tmp/concat') shell('mkdir -p /tmp/concat') shell("/bin/echo 'old contents' > /tmp/concat/file") end - after :all do - shell('rm -rf /tmp/concat') - end pp = <<-EOS concat { '/tmp/concat/file': diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb deleted file mode 100644 index 5d78d7b..0000000 --- a/spec/acceptance/basic_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper_acceptance' - -# Here we put the more basic fundamental tests, ultra obvious stuff. -describe "basic tests:" do - it 'copies the module across' do - # No point diagnosing any more if the module wasn't copied properly - shell "ls #{default['distmoduledir']}/concat" do |r| - expect(r.stdout).to match(/Modulefile/) - expect(r.stderr).to be_empty - end - end -end From ccf5284b56283148e8b0efbba9fb85c2fcd6ba48 Mon Sep 17 00:00:00 2001 From: Alex Dreyer Date: Fri, 14 Feb 2014 12:54:48 -0800 Subject: [PATCH 091/202] Switch test to use a much higher gid/uid --- spec/acceptance/concat_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index a4982c1..a3c0507 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -57,8 +57,8 @@ describe 'basic concat test' do context 'owner/group non-root' do before(:all) do - shell "groupadd -g 42 bob" - shell "useradd -u 42 -g 42 bob" + shell "groupadd -g 64444 bob" + shell "useradd -u 42 -g 64444 bob" end after(:all) do shell "userdel bob" From 62795f81265e72d9b9b82a22f44305364c0e71f9 Mon Sep 17 00:00:00 2001 From: Alex Dreyer Date: Fri, 14 Feb 2014 12:54:48 -0800 Subject: [PATCH 092/202] Switch test to use a much higher gid/uid (cherry picked from commit ccf5284b56283148e8b0efbba9fb85c2fcd6ba48) --- spec/acceptance/concat_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index e31e489..89919cc 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -99,8 +99,8 @@ describe 'basic concat test' do context 'owner/group non-root' do before(:all) do - shell "groupadd -g 42 bob" - shell "useradd -u 42 -g 42 bob" + shell "groupadd -g 64444 bob" + shell "useradd -u 42 -g 64444 bob" end after(:all) do shell "userdel bob" From 854a83ae4f30b78edf31ceac989d5a67914459b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Tue, 18 Feb 2014 16:57:09 +0100 Subject: [PATCH 093/202] be more ignorant ignore vim swp files. May be especially important when those sneak into released packages, such as in the case of 1.0.1: concat/manifests/.setup.pp.swp concat/manifests/.init.pp.swp concat/manifests/.fragment.pp.swp concat/files/.concatfragments.sh.swp concat/spec/acceptance/.warn_spec.rb.swp concat/spec/acceptance/.symbolic_name_spec.rb.swp concat/spec/acceptance/.order_spec.rb.swp concat/spec/acceptance/.fragment_source_spec.rb.swp concat/spec/acceptance/.deprecation_warnings_spec.rb.swp concat/spec/acceptance/.empty_spec.rb.swp concat/spec/acceptance/.concat_spec.rb.swo concat/spec/acceptance/.replace_spec.rb.swp concat/spec/acceptance/.basic_spec.rb.swp concat/spec/acceptance/.deprecation_warnings_spec.rb.swo concat/spec/acceptance/.concat_spec.rb.swp concat/spec/acceptance/.backup_spec.rb.swp --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7f449ba..143345e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ Gemfile.lock vendor spec/fixtures .rspec_system -.bundle \ No newline at end of file +.bundle +*.sw* From e0a7ca97f0e3d8b1196006301d30a19997c8b4c6 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 20 Feb 2014 16:59:08 -0800 Subject: [PATCH 094/202] Fix test port from 596cec1 --- spec/acceptance/newline_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 996f99e..6a761fb 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -46,7 +46,7 @@ describe 'concat ensure_newline parameter' do it 'applies the manifest twice with no stderr' do expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :expect_changes => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") #XXX ensure_newline => true causes changes on every run because the files #are modified in place. end From 600ddf0e43370227a56b39c73492790a6a900342 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 21 Feb 2014 15:35:36 -0800 Subject: [PATCH 095/202] Disable test for unimplemented feature --- spec/acceptance/newline_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 6a761fb..5b7e968 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -46,7 +46,9 @@ describe 'concat ensure_newline parameter' do it 'applies the manifest twice with no stderr' do expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + pending "ensure_newline => true causes changes on every run because the files are modified in place." do + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end #XXX ensure_newline => true causes changes on every run because the files #are modified in place. end From 3d625c9c2819f9b3046607d07e2bc6cae53b091d Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Sat, 22 Feb 2014 17:15:56 -0800 Subject: [PATCH 096/202] This test is implemented incorrectly, and is testing an unimplemented feature. So commenting it out --- spec/acceptance/newline_spec.rb | 54 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 5b7e968..92a78ad 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -28,34 +28,32 @@ describe 'concat ensure_newline parameter' do end end - context '=> true' do - pp = <<-EOS - include concat::setup - concat { '/tmp/concat/file': - ensure_newline => true, - } - concat::fragment { '1': - target => '/tmp/concat/file', - content => '1', - } - concat::fragment { '2': - target => '/tmp/concat/file', - content => '2', - } - EOS + #context '=> true' do + # pp = <<-EOS + # include concat::setup + # concat { '/tmp/concat/file': + # ensure_newline => true, + # } + # concat::fragment { '1': + # target => '/tmp/concat/file', + # content => '1', + # } + # concat::fragment { '2': + # target => '/tmp/concat/file', + # content => '2', + # } + # EOS - it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - pending "ensure_newline => true causes changes on every run because the files are modified in place." do - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") - end - #XXX ensure_newline => true causes changes on every run because the files - #are modified in place. - end + # it 'applies the manifest twice with no stderr' do + # expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + # expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + # #XXX ensure_newline => true causes changes on every run because the files + # #are modified in place. + # end - describe file('/tmp/concat/file') do - it { should be_file } - it { should contain "1\n2\n" } - end - end + # describe file('/tmp/concat/file') do + # it { should be_file } + # it { should contain "1\n2\n" } + # end + #end end From a2f625f3852b93059bdbeec8173dd983ff22443c Mon Sep 17 00:00:00 2001 From: Lucien Weller Date: Fri, 21 Feb 2014 19:17:41 +0100 Subject: [PATCH 097/202] Added double quotes to paths in concat command, so that it does not fail when path of target file contains some blanks. --- manifests/init.pp | 2 +- spec/acceptance/quoted_paths_spec.rb | 33 ++++++++++++++++++++++++++++ spec/unit/defines/concat_spec.rb | 4 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 spec/acceptance/quoted_paths_spec.rb diff --git a/manifests/init.pp b/manifests/init.pp index 566e3bf..91d82eb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -177,7 +177,7 @@ define concat( } # remove extra whitespace from string interpolation to make testing easier - $command = strip(regsubst("${script_command} -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) # if puppet is running as root, this exec should also run as root to allow # the concatfragments.sh script to potentially be installed in path that diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb new file mode 100644 index 0000000..d1a2b5f --- /dev/null +++ b/spec/acceptance/quoted_paths_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper_acceptance' + +describe 'quoted paths' do + before(:all) do + shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat') + shell('mkdir -p "/tmp/concat test"') + end + + context 'path with blanks' do + pp = <<-EOS + concat { '/tmp/concat test/foo': + } + concat::fragment { '1': + target => '/tmp/concat test/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat test/foo', + content => 'string2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat test/foo') do + it { should be_file } + it { should contain "string1\nsring2" } + end + end +end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 08cf2ec..9fdd7b2 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -81,8 +81,8 @@ describe 'concat', :type => :define do end cmd = "#{concatdir}/bin/concatfragments.sh " + - "-o #{concatdir}/#{safe_name}/fragments.concat.out " + - "-d #{concatdir}/#{safe_name}" + "-o \"#{concatdir}/#{safe_name}/fragments.concat.out\" " + + "-d \"#{concatdir}/#{safe_name}\"" # flag order: fragdir, warnflag, forceflag, orderflag, newlineflag if p.has_key?(:warn) From d6b11cd502f19ffd7194fc46bb4e1f58355f8a81 Mon Sep 17 00:00:00 2001 From: Pi3r Date: Tue, 25 Feb 2014 14:54:09 +0100 Subject: [PATCH 098/202] Use explicit undef in else case This is better than leaving it "unset". --- manifests/fragment.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 69c1fba..bea0e24 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -88,6 +88,8 @@ define concat::fragment( # if it looks line ensure => /target syntax was used, fish that out if ! ($_ensure in ['', 'present', 'absent', 'file' ]) { $ensure_target = $_ensure + } else { + $ensure_target = undef } # the file type's semantics only allows one of: ensure => /target, content, From 8b852e2b893691fe91eea02d31331e9abdfdd0bd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 26 Feb 2014 14:17:59 -0800 Subject: [PATCH 099/202] Fix aix/windows ownership issues and vardir path --- spec/acceptance/concat_spec.rb | 102 ++++++++---------------- spec/acceptance/empty_spec.rb | 3 +- spec/acceptance/fragment_source_spec.rb | 28 +++++-- spec/acceptance/replace_spec.rb | 3 +- spec/spec_helper_acceptance.rb | 26 +++--- 5 files changed, 71 insertions(+), 91 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index a3c0507..673d793 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,5 +1,17 @@ require 'spec_helper_acceptance' +case fact('osfamily') +when 'AIX' + username = 'root' + groupname = 'system' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' +end + describe 'basic concat test' do shared_examples 'successfully_applied' do |pp| @@ -9,12 +21,12 @@ describe 'basic concat test' do end end - context 'owner/group root' do + context 'owner/group' do pp = <<-EOS include concat::setup concat { '/tmp/concat/file': - owner => 'root', - group => 'root', + owner => '#{username}', + group => '#{groupname}', mode => '0644', } @@ -35,78 +47,32 @@ describe 'basic concat test' do describe file('/tmp/concat/file') do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } + it { should be_owned_by username } + it { should be_grouped_into groupname } + # XXX file be_mode isn't supported on AIX + it("should be mode 644", :unless => fact('osfamily') == "AIX") { + should be_mode 644 + } it { should contain '1' } it { should contain '2' } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/01_1") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do - it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - end - - context 'owner/group non-root' do - before(:all) do - shell "groupadd -g 64444 bob" - shell "useradd -u 42 -g 64444 bob" - end - after(:all) do - shell "userdel bob" - end - - pp=" - concat { '/tmp/concat/file': - owner => 'bob', - group => 'bob', - mode => '0644', + it { should be_owned_by username } + it { should be_grouped_into groupname } + # XXX file be_mode isn't supported on AIX + it("should be mode 644", :unless => fact('osfamily') == "AIX") { + should be_mode 644 } - - concat::fragment { '1': - target => '/tmp/concat/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '/tmp/concat/file', - content => '2', - order => '02', - } - " - - it_behaves_like 'successfully_applied', pp - - describe file('/tmp/concat/file') do - it { should be_file } - it { should be_owned_by 'bob' } - it { should be_grouped_into 'bob' } - it { should be_mode 644 } - it { should contain '1' } - it { should contain '2' } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/02_2") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - it { should contain '1' } - end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do - it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - it { should contain '2' } + it { should be_owned_by username } + it { should be_grouped_into groupname } + # XXX file be_mode isn't supported on AIX + it("should be mode 644", :unless => fact('osfamily') == "AIX") { + should be_mode 644 + } end end end diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 0999528..f59916d 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -3,9 +3,8 @@ require 'spec_helper_acceptance' describe 'concat force empty parameter' do context 'should run successfully' do pp = <<-EOS + include concat::setup concat { '/tmp/concat/file': - owner => root, - group => root, mode => '0644', force => true, } diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 6c93f0a..6d3493b 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -1,5 +1,17 @@ require 'spec_helper_acceptance' +case fact('osfamily') +when 'AIX' + username = 'root' + groupname = 'system' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' +end + describe 'concat::fragment source' do context 'should read file fragments from local system' do before(:all) do @@ -49,18 +61,18 @@ describe 'concat::fragment source' do pp = <<-EOS include concat::setup concat { '/tmp/concat/result_file1': - owner => root, - group => root, + owner => '#{username}', + group => '#{groupname}', mode => '0644', } concat { '/tmp/concat/result_file2': - owner => root, - group => root, + owner => '#{username}', + group => '#{groupname}', mode => '0644', } concat { '/tmp/concat/result_file3': - owner => root, - group => root, + owner => '#{username}', + group => '#{groupname}', mode => '0644', } @@ -112,8 +124,8 @@ describe 'concat::fragment source' do pp = <<-EOS include concat::setup concat { '/tmp/concat/fail_no_source': - owner => root, - group => root, + owner => '#{username}', + group => '#{groupname}', mode => '0644', } diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 4a305e1..99e9d48 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -116,7 +116,8 @@ describe 'replacement of' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + # XXX specinfra doesn't support be_linked_to on AIX + describe file('/tmp/concat/file'), :unless => fact('osfamily') == "AIX" do it { should be_linked_to '/tmp/concat/dangling' } end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b064d68..35dacd1 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,17 +1,19 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' -hosts.each do |host| - if host['platform'] =~ /debian/ - on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' - end - if host.is_pe? - install_pe - else - # Install Puppet - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' - on host, "mkdir -p #{host['distmoduledir']}" +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + if host['platform'] =~ /debian/ + on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' + end + if host.is_pe? + install_pe + else + # Install Puppet + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" + end end end @@ -35,7 +37,7 @@ RSpec.configure do |c| shell('mkdir -p /tmp/concat') end c.after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf /tmp/concat #{default.puppet['vardir']}/concat") end c.treat_symbols_as_metadata_keys_with_true_values = true From 1f61e9d12248edb72443d210b35e1526110e4e20 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 13:01:13 -0800 Subject: [PATCH 100/202] Avoid multi-line greps on solaris 10 --- spec/acceptance/order_spec.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index 8a1af6f..f7f0e2b 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -33,7 +33,10 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } - it { should contain "string10\nstring1\nsring2" } + #XXX Solaris 10 doesn't support multi-line grep + it("should contain string10\nstring1\nsring2", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + should contain "string10\nstring1\nsring2" + } end end @@ -64,7 +67,10 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } - it { should contain "string1\nstring2\nsring10" } + #XXX Solaris 10 doesn't support multi-line grep + it("should contain string1\nstring2\nsring10", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + should contain "string1\nstring2\nsring10" + } end end end # concat order @@ -103,7 +109,10 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } - it { should contain "string3\nstring2\nsring1" } + #XXX Solaris 10 doesn't support multi-line grep + it("should contain string3\nstring2\nsring1", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + should contain "string3\nstring2\nsring1" + } end end @@ -135,7 +144,10 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } - it { should contain "string1\nstring2\nsring3" } + #XXX Solaris 10 doesn't support multi-line grep + it("should contain string1\nstring2\nsring3", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + should contain "string1\nstring2\nsring3" + } end end end # concat::fragment order From f37805060f2213ad130cca01f394997dc351f578 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 13:18:29 -0800 Subject: [PATCH 101/202] Correct syntax --- spec/acceptance/order_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index f7f0e2b..ee675a7 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -34,7 +34,7 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string10\nstring1\nsring2", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + it("should contain string10\nstring1\nsring2", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { should contain "string10\nstring1\nsring2" } end @@ -68,7 +68,7 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring10", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + it("should contain string1\nstring2\nsring10", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { should contain "string1\nstring2\nsring10" } end @@ -110,7 +110,7 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string3\nstring2\nsring1", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + it("should contain string3\nstring2\nsring1", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { should contain "string3\nstring2\nsring1" } end @@ -145,7 +145,7 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring3", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/) { + it("should contain string1\nstring2\nsring3", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { should contain "string1\nstring2\nsring3" } end From 311adee522b23478b49bb3119867d09ec227c7ea Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 14:20:42 -0800 Subject: [PATCH 102/202] It is actually all Solaris --- spec/acceptance/order_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index ee675a7..e148808 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -34,7 +34,7 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string10\nstring1\nsring2", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { + it("should contain string10\nstring1\nsring2", :unless => fact('osfamily') == 'Solaris') { should contain "string10\nstring1\nsring2" } end @@ -68,7 +68,7 @@ describe 'concat order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring10", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { + it("should contain string1\nstring2\nsring10", :unless => fact('osfamily') == 'Solaris') { should contain "string1\nstring2\nsring10" } end @@ -110,7 +110,7 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string3\nstring2\nsring1", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { + it("should contain string3\nstring2\nsring1", :unless => fact('osfamily') == 'Solaris') { should contain "string3\nstring2\nsring1" } end @@ -145,7 +145,7 @@ describe 'concat::fragment order' do describe file('/tmp/concat/foo') do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring3", :unless => fact('operatingsystemrelease').match(/^10_u\d+$/)) { + it("should contain string1\nstring2\nsring3", :unless => fact('osfamily') == 'Solaris') { should contain "string1\nstring2\nsring3" } end From f0b6187f76d62fbb8aeb3fe9178a9189a97c23aa Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 14:52:53 -0800 Subject: [PATCH 103/202] Use tmpdir instead of /tmp for windows compatability --- spec/acceptance/backup_spec.rb | 43 ++++++------ spec/acceptance/concat_spec.rb | 15 +++-- spec/acceptance/empty_spec.rb | 7 +- spec/acceptance/fragment_source_spec.rb | 67 ++++++++++--------- spec/acceptance/newline_spec.rb | 19 +++--- spec/acceptance/order_spec.rb | 54 ++++++++------- spec/acceptance/replace_spec.rb | 87 +++++++++++++------------ spec/acceptance/symbolic_name_spec.rb | 7 +- spec/acceptance/warn_spec.rb | 27 ++++---- 9 files changed, 178 insertions(+), 148 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index e6bbd17..f021a55 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -1,20 +1,23 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do + let :basedir do + default.tmpdir('concat') + end context '=> puppet' do before :all do - shell('rm -rf /tmp/concat') - shell('mkdir -p /tmp/concat') - shell("/bin/echo 'old contents' > /tmp/concat/file") + shell("rm -rf #{basedir}") + shell("mkdir -p #{basedir}") + shell("echo 'old contents' > #{basedir}/file") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': backup => 'puppet', } concat::fragment { 'new file': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new contents', } EOS @@ -22,12 +25,12 @@ describe 'concat backup parameter' do it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stderr).to eq("") - expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' + expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' end expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new contents' } end @@ -35,18 +38,18 @@ describe 'concat backup parameter' do context '=> .backup' do before :all do - shell('rm -rf /tmp/concat') - shell('mkdir -p /tmp/concat') - shell("/bin/echo 'old contents' > /tmp/concat/file") + shell("rm -rf #{basedir}") + shell("mkdir -p #{basedir}") + shell("echo 'old contents' > #{basedir}/file") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new contents', } EOS @@ -58,11 +61,11 @@ describe 'concat backup parameter' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new contents' } end - describe file('/tmp/concat/file.backup') do + describe file("#{basedir}/file.backup") do it { should be_file } it { should contain 'old contents' } end @@ -72,18 +75,18 @@ describe 'concat backup parameter' do # boolean false value, but the string 'false' has the same effect in Puppet 3 context "=> 'false'" do before :all do - shell('rm -rf /tmp/concat') - shell('mkdir -p /tmp/concat') - shell("/bin/echo 'old contents' > /tmp/concat/file") + shell("rm -rf #{basedir}") + shell("mkdir -p #{basedir}") + shell("echo 'old contents' > #{basedir}/file") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new contents', } EOS @@ -96,7 +99,7 @@ describe 'concat backup parameter' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new contents' } end diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 673d793..4480cb5 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -13,6 +13,9 @@ else end describe 'basic concat test' do + let :basedir do + default.tmpdir('concat') + end shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do @@ -24,20 +27,20 @@ describe 'basic concat test' do context 'owner/group' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': owner => '#{username}', group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', order => '02', } @@ -45,7 +48,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -56,7 +59,7 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/01_1") do + describe file("#{default.puppet['vardir']}/concat/#{basedir.gsub('/','_')}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -65,7 +68,7 @@ describe 'basic concat test' do should be_mode 644 } end - describe file("#{default.puppet['vardir']}/concat/_tmp_concat_file/fragments/02_2") do + describe file("#{default.puppet['vardir']}/concat/#{basedir.gsub('/','_')}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index f59916d..57970dd 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,10 +1,13 @@ require 'spec_helper_acceptance' describe 'concat force empty parameter' do + let :basedir do + default.tmpdir('concat') + end context 'should run successfully' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': mode => '0644', force => true, } @@ -15,7 +18,7 @@ describe 'concat force empty parameter' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should_not contain '1\n2' } end diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 6d3493b..0ec6d49 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -13,27 +13,30 @@ else end describe 'concat::fragment source' do + let :basedir do + default.tmpdir('concat') + end context 'should read file fragments from local system' do before(:all) do - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + shell("/bin/echo 'file1 contents' > #{basedir}/file1") + shell("/bin/echo 'file2 contents' > #{basedir}/file2") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', - source => '/tmp/concat/file1', + target => '#{basedir}/foo', + source => '#{basedir}/file1', } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1 contents', } concat::fragment { '3': - target => '/tmp/concat/foo', - source => '/tmp/concat/file2', + target => '#{basedir}/foo', + source => '#{basedir}/file2', } EOS @@ -42,7 +45,7 @@ describe 'concat::fragment source' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should contain 'file1 contents' } it { should contain 'string1 contents' } @@ -52,43 +55,43 @@ describe 'concat::fragment source' do context 'should create files containing first match only.' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") + shell("mkdir -p #{basedir}") + shell("echo 'file1 contents' > #{basedir}/file1") + shell("echo 'file2 contents' > #{basedir}/file2") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/result_file1': + concat { '#{basedir}/result_file1': owner => '#{username}', group => '#{groupname}', mode => '0644', } - concat { '/tmp/concat/result_file2': + concat { '#{basedir}/result_file2': owner => '#{username}', group => '#{groupname}', mode => '0644', } - concat { '/tmp/concat/result_file3': + concat { '#{basedir}/result_file3': owner => '#{username}', group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/result_file1', - source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + target => '#{basedir}/result_file1', + source => [ '#{basedir}/file1', '#{basedir}/file2' ], order => '01', } concat::fragment { '2': - target => '/tmp/concat/result_file2', - source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], + target => '#{basedir}/result_file2', + source => [ '#{basedir}/file2', '#{basedir}/file1' ], order => '01', } concat::fragment { '3': - target => '/tmp/concat/result_file3', - source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + target => '#{basedir}/result_file3', + source => [ '#{basedir}/file1', '#{basedir}/file2' ], order => '01', } EOS @@ -97,17 +100,17 @@ describe 'concat::fragment source' do expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/result_file1') do + describe file("#{basedir}/result_file1") do it { should be_file } it { should contain 'file1 contents' } it { should_not contain 'file2 contents' } end - describe file('/tmp/concat/result_file2') do + describe file("#{basedir}/result_file2") do it { should be_file } it { should contain 'file2 contents' } it { should_not contain 'file1 contents' } end - describe file('/tmp/concat/result_file3') do + describe file("#{basedir}/result_file3") do it { should be_file } it { should contain 'file1 contents' } it { should_not contain 'file2 contents' } @@ -116,22 +119,22 @@ describe 'concat::fragment source' do context 'should fail if no match on source.' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') - shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") + shell("mkdir -p #{basedir}") + shell("rm -rf #{basedir}/fail_no_source #{basedir}/nofilehere #{basedir}/nothereeither") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/fail_no_source': + concat { '#{basedir}/fail_no_source': owner => '#{username}', group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/fail_no_source', - source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], + target => '#{basedir}/fail_no_source', + source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ], order => '01', } EOS @@ -139,7 +142,7 @@ describe 'concat::fragment source' do it 'applies the manifest with resource failures' do apply_manifest(pp, :expect_failures => true) end - describe file('/tmp/concat/fail_no_source') do + describe file("#{basedir}/fail_no_source") do #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. it { should_not be_file } it { should_not be_directory } diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 92a78ad..9ecf26b 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -1,18 +1,21 @@ require 'spec_helper_acceptance' describe 'concat ensure_newline parameter' do + let :basedir do + default.tmpdir('concat') + end context '=> false' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': ensure_newline => false, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -22,7 +25,7 @@ describe 'concat ensure_newline parameter' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '12' } end @@ -31,15 +34,15 @@ describe 'concat ensure_newline parameter' do #context '=> true' do # pp = <<-EOS # include concat::setup - # concat { '/tmp/concat/file': + # concat { '#{basedir}/file': # ensure_newline => true, # } # concat::fragment { '1': - # target => '/tmp/concat/file', + # target => '#{basedir}/file', # content => '1', # } # concat::fragment { '2': - # target => '/tmp/concat/file', + # target => '#{basedir}/file', # content => '2', # } # EOS @@ -51,7 +54,7 @@ describe 'concat ensure_newline parameter' do # #are modified in place. # end - # describe file('/tmp/concat/file') do + # describe file("#{basedir}/file") do # it { should be_file } # it { should contain "1\n2\n" } # end diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index e148808..d01cae2 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -1,27 +1,30 @@ require 'spec_helper_acceptance' describe 'concat order' do + let :basedir do + default.tmpdir('concat') + end before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") + shell("mkdir -p #{basedir}") end context '=> alpha' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/foo': + concat { '#{basedir}/foo': order => 'alpha' } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1', } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string2', } concat::fragment { '10': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string10', } EOS @@ -31,7 +34,7 @@ describe 'concat order' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep it("should contain string10\nstring1\nsring2", :unless => fact('osfamily') == 'Solaris') { @@ -43,19 +46,19 @@ describe 'concat order' do context '=> numeric' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/foo': + concat { '#{basedir}/foo': order => 'numeric' } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1', } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string2', } concat::fragment { '10': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string10', } EOS @@ -65,7 +68,7 @@ describe 'concat order' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep it("should contain string1\nstring2\nsring10", :unless => fact('osfamily') == 'Solaris') { @@ -76,27 +79,30 @@ describe 'concat order' do end # concat order describe 'concat::fragment order' do + let :basedir do + default.tmpdir('concat') + end before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") + shell("mkdir -p #{basedir}") end context '=> reverse order' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1', order => '15', } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string2', # default order 10 } concat::fragment { '3': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string3', order => '1', } @@ -107,7 +113,7 @@ describe 'concat::fragment order' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep it("should contain string3\nstring2\nsring1", :unless => fact('osfamily') == 'Solaris') { @@ -119,19 +125,19 @@ describe 'concat::fragment order' do context '=> normal order' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string2', order => '02' } concat::fragment { '3': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string3', order => '03', } @@ -142,7 +148,7 @@ describe 'concat::fragment order' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep it("should contain string1\nstring2\nsring3", :unless => fact('osfamily') == 'Solaris') { diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 99e9d48..1a468b7 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -1,29 +1,32 @@ require 'spec_helper_acceptance' describe 'replacement of' do + let :basedir do + default.tmpdir('concat') + end context 'file' do context 'should not succeed' do before(:all) do - shell('mkdir -p /tmp/concat') - shell('echo "file exists" > /tmp/concat/file') + shell("mkdir -p #{basedir}") + shell('echo "file exists" > #{basedir}/file') end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': replace => false, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -33,7 +36,7 @@ describe 'replacement of' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'file exists' } it { should_not contain '1' } @@ -43,26 +46,26 @@ describe 'replacement of' do context 'should succeed' do before(:all) do - shell('mkdir -p /tmp/concat') - shell('echo "file exists" > /tmp/concat/file') + shell("mkdir -p #{basedir}") + shell("echo "file exists" > #{basedir}/file") end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': replace => true, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -72,7 +75,7 @@ describe 'replacement of' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should_not contain 'file exists' } it { should contain '1' } @@ -87,26 +90,26 @@ describe 'replacement of' do # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do - shell('mkdir -p /tmp/concat') - shell('ln -s /tmp/concat/dangling /tmp/concat/file') + shell("mkdir -p #{basedir}") + shell("ln -s #{basedir}/dangling #{basedir}/file") end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': replace => false, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -117,11 +120,11 @@ describe 'replacement of' do end # XXX specinfra doesn't support be_linked_to on AIX - describe file('/tmp/concat/file'), :unless => fact('osfamily') == "AIX" do - it { should be_linked_to '/tmp/concat/dangling' } + describe file("#{basedir}/file"), :unless => fact("osfamily") == "AIX" do + it { should be_linked_to "#{basedir}/dangling" } end - describe file('/tmp/concat/dangling') do + describe file("#{basedir}/dangling") do # XXX serverspec does not have a matcher for 'exists' it { should_not be_file } it { should_not be_directory } @@ -133,26 +136,26 @@ describe 'replacement of' do # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do - shell('mkdir -p /tmp/concat') - shell('ln -s /tmp/concat/dangling /tmp/concat/file') + shell("mkdir -p #{basedir}") + shell("ln -s #{basedir}/dangling #{basedir}/file") end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': replace => true, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -162,7 +165,7 @@ describe 'replacement of' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '1' } it { should contain '2' } @@ -173,23 +176,23 @@ describe 'replacement of' do context 'directory' do context 'should not succeed' do before(:all) do - shell('mkdir -p /tmp/concat/file') + shell("mkdir -p #{basedir}/file") end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -199,7 +202,7 @@ describe 'replacement of' do expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_directory } end end @@ -211,25 +214,25 @@ describe 'replacement of' do # replacement. context 'should succeed', :pending => 'not yet implemented' do before(:all) do - shell('mkdir -p /tmp/concat/file') + shell("mkdir -p #{basedir}/file") end after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") end pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': force => true, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', } EOS @@ -239,7 +242,7 @@ describe 'replacement of' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '1' } end diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index b1b512f..8481768 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -1,10 +1,13 @@ require 'spec_helper_acceptance' describe 'symbolic name' do + let :basedir do + default.tmpdir('concat') + end pp = <<-EOS include concat::setup concat { 'not_abs_path': - path => '/tmp/concat/file', + path => '#{basedir}/file', } concat::fragment { '1': @@ -25,7 +28,7 @@ describe 'symbolic name' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '1' } it { should contain '2' } diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index e19c6b5..16947ee 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -1,21 +1,24 @@ require 'spec_helper_acceptance' describe 'concat warn =>' do + let :basedir do + default.tmpdir('concat') + end context 'true should enable default warning message' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => true, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', order => '02', } @@ -26,7 +29,7 @@ describe 'concat warn =>' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain '1' } @@ -36,18 +39,18 @@ describe 'concat warn =>' do context 'false should not enable default warning message' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => false, } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', order => '02', } @@ -58,7 +61,7 @@ describe 'concat warn =>' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain '1' } @@ -68,18 +71,18 @@ describe 'concat warn =>' do context '# foo should overide default warning message' do pp = <<-EOS include concat::setup - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => '# foo', } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', order => '02', } @@ -90,7 +93,7 @@ describe 'concat warn =>' do expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '# foo' } it { should contain '1' } From d887c3b5f546320569f2a525317d7160db7741da Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 15:50:18 -0800 Subject: [PATCH 104/202] Lets can't be used outside of a test context --- spec/acceptance/backup_spec.rb | 4 +--- spec/acceptance/concat_spec.rb | 4 +--- spec/acceptance/empty_spec.rb | 4 +--- spec/acceptance/fragment_source_spec.rb | 4 +--- spec/acceptance/newline_spec.rb | 4 +--- spec/acceptance/order_spec.rb | 8 ++------ spec/acceptance/replace_spec.rb | 4 +--- spec/acceptance/symbolic_name_spec.rb | 4 +--- spec/acceptance/warn_spec.rb | 4 +--- 9 files changed, 10 insertions(+), 30 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index f021a55..764bdbb 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context '=> puppet' do before :all do shell("rm -rf #{basedir}") diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 4480cb5..ab6788e 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -13,9 +13,7 @@ else end describe 'basic concat test' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 57970dd..ad24415 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'concat force empty parameter' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context 'should run successfully' do pp = <<-EOS include concat::setup diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 0ec6d49..d2f0c7b 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -13,9 +13,7 @@ else end describe 'concat::fragment source' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context 'should read file fragments from local system' do before(:all) do shell("/bin/echo 'file1 contents' > #{basedir}/file1") diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 9ecf26b..a511e3f 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'concat ensure_newline parameter' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context '=> false' do pp = <<-EOS include concat::setup diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index d01cae2..32f85d5 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'concat order' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') before(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") shell("mkdir -p #{basedir}") @@ -79,9 +77,7 @@ describe 'concat order' do end # concat order describe 'concat::fragment order' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') before(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") shell("mkdir -p #{basedir}") diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 1a468b7..4893c30 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'replacement of' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context 'file' do context 'should not succeed' do before(:all) do diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index 8481768..384a821 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'symbolic name' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') pp = <<-EOS include concat::setup concat { 'not_abs_path': diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index 16947ee..68758fe 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -1,9 +1,7 @@ require 'spec_helper_acceptance' describe 'concat warn =>' do - let :basedir do - default.tmpdir('concat') - end + basedir = default.tmpdir('concat') context 'true should enable default warning message' do pp = <<-EOS include concat::setup From 495619794e310543cecf1c7da7aa4117a389a20a Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 16:07:01 -0800 Subject: [PATCH 105/202] Correct the incorrect quotes --- spec/acceptance/replace_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 4893c30..dfc05fe 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -6,7 +6,7 @@ describe 'replacement of' do context 'should not succeed' do before(:all) do shell("mkdir -p #{basedir}") - shell('echo "file exists" > #{basedir}/file') + shell("echo 'file exists' > #{basedir}/file") end after(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") @@ -45,7 +45,7 @@ describe 'replacement of' do context 'should succeed' do before(:all) do shell("mkdir -p #{basedir}") - shell("echo "file exists" > #{basedir}/file") + shell("echo 'file exists' > #{basedir}/file") end after(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") From 1577ec78e1a01202f91fbb86b683c301da0227ef Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 27 Feb 2014 17:13:03 -0800 Subject: [PATCH 106/202] Add windows as unsupported --- manifests/setup.pp | 8 ++++++++ spec/acceptance/backup_spec.rb | 2 +- spec/acceptance/concat_spec.rb | 8 ++++---- spec/acceptance/empty_spec.rb | 2 +- spec/acceptance/fragment_source_spec.rb | 2 +- spec/acceptance/newline_spec.rb | 2 +- spec/acceptance/order_spec.rb | 12 ++++++------ spec/acceptance/replace_spec.rb | 4 ++-- spec/acceptance/symbolic_name_spec.rb | 2 +- spec/acceptance/unsupported_spec.rb | 18 ++++++++++++++++++ spec/acceptance/warn_spec.rb | 2 +- spec/spec_helper_acceptance.rb | 2 ++ 12 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 spec/acceptance/unsupported_spec.rb diff --git a/manifests/setup.pp b/manifests/setup.pp index 55d7197..5a985f6 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -18,6 +18,14 @@ # It also copies out the concatfragments.sh file to ${concatdir}/bin # class concat::setup { + case $::osfamily { + 'windows': { + fail("Unsupported osfamily: ${osfamily}") + } + default: { + # Should work otherwise + } + } $id = $::id $root_group = $id ? { root => 0, diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 764bdbb..c09c178 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat backup parameter' do +describe 'concat backup parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context '=> puppet' do before :all do diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index ab6788e..b4f7352 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -12,7 +12,7 @@ else groupname = 'root' end -describe 'basic concat test' do +describe 'basic concat test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') shared_examples 'successfully_applied' do |pp| @@ -51,7 +51,7 @@ describe 'basic concat test' do it { should be_owned_by username } it { should be_grouped_into groupname } # XXX file be_mode isn't supported on AIX - it("should be mode 644", :unless => fact('osfamily') == "AIX") { + it("should be mode 644", :unless => (fact('osfamily') == "AIX" or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should be_mode 644 } it { should contain '1' } @@ -62,7 +62,7 @@ describe 'basic concat test' do it { should be_owned_by username } it { should be_grouped_into groupname } # XXX file be_mode isn't supported on AIX - it("should be mode 644", :unless => fact('osfamily') == "AIX") { + it("should be mode 644", :unless => (fact('osfamily') == "AIX" or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should be_mode 644 } end @@ -71,7 +71,7 @@ describe 'basic concat test' do it { should be_owned_by username } it { should be_grouped_into groupname } # XXX file be_mode isn't supported on AIX - it("should be mode 644", :unless => fact('osfamily') == "AIX") { + it("should be mode 644", :unless => (fact('osfamily') == "AIX" or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should be_mode 644 } end diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index ad24415..8eb0a96 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat force empty parameter' do +describe 'concat force empty parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context 'should run successfully' do pp = <<-EOS diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index d2f0c7b..3f6eb49 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -12,7 +12,7 @@ else groupname = 'root' end -describe 'concat::fragment source' do +describe 'concat::fragment source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context 'should read file fragments from local system' do before(:all) do diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index a511e3f..fb3f17d 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat ensure_newline parameter' do +describe 'concat ensure_newline parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context '=> false' do pp = <<-EOS diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index 32f85d5..1c79ab4 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat order' do +describe 'concat order', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') before(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") @@ -35,7 +35,7 @@ describe 'concat order' do describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string10\nstring1\nsring2", :unless => fact('osfamily') == 'Solaris') { + it("should contain string10\nstring1\nsring2", :unless => (fact('osfamily') == 'Solaris' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should contain "string10\nstring1\nsring2" } end @@ -69,14 +69,14 @@ describe 'concat order' do describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring10", :unless => fact('osfamily') == 'Solaris') { + it("should contain string1\nstring2\nsring10", :unless => (fact('osfamily') == 'Solaris' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should contain "string1\nstring2\nsring10" } end end end # concat order -describe 'concat::fragment order' do +describe 'concat::fragment order', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') before(:all) do shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat") @@ -112,7 +112,7 @@ describe 'concat::fragment order' do describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string3\nstring2\nsring1", :unless => fact('osfamily') == 'Solaris') { + it("should contain string3\nstring2\nsring1", :unless => (fact('osfamily') == 'Solaris' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should contain "string3\nstring2\nsring1" } end @@ -147,7 +147,7 @@ describe 'concat::fragment order' do describe file("#{basedir}/foo") do it { should be_file } #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring3", :unless => fact('osfamily') == 'Solaris') { + it("should contain string1\nstring2\nsring3", :unless => (fact('osfamily') == 'Solaris' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily')))) { should contain "string1\nstring2\nsring3" } end diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index dfc05fe..e84140f 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'replacement of' do +describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context 'file' do context 'should not succeed' do @@ -118,7 +118,7 @@ describe 'replacement of' do end # XXX specinfra doesn't support be_linked_to on AIX - describe file("#{basedir}/file"), :unless => fact("osfamily") == "AIX" do + describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))) do it { should be_linked_to "#{basedir}/dangling" } end diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index 384a821..57a9e95 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'symbolic name' do +describe 'symbolic name', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') pp = <<-EOS include concat::setup diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb new file mode 100644 index 0000000..9df7d88 --- /dev/null +++ b/spec/acceptance/unsupported_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper_acceptance' + +describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + basedir = default.tmpdir('concat') + it 'should fail' do + pp = <<-EOS + include concat::setup + concat { '#{basedir}/file': + backup => 'puppet', + } + concat::fragment { 'new file': + target => '#{basedir}/file', + content => 'new contents', + } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i) + end +end diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index 68758fe..b036884 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat warn =>' do +describe 'concat warn =>', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do basedir = default.tmpdir('concat') context 'true should enable default warning message' do pp = <<-EOS diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 35dacd1..c75a7fb 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -17,6 +17,8 @@ unless ENV['RS_PROVISION'] == 'no' end end +UNSUPPORTED_PLATFORMS = ['windows'] + RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) From 68a54e45ab4840518a6b48042615860fd48fd45a Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Sat, 1 Mar 2014 08:25:23 -0800 Subject: [PATCH 107/202] Adds "Release Notes/Known Bugs" to Changelog,updates file format to markdown, standardizes the format of previous entries Per a request to have initial release notes that specifically listed known issues for this PE 3.2 release, and barred by time constraints from automating a pull from open issues in JIRA, this commit adds a Release Note and Known Bug section to the Changelog for the imminent 3.2 release.As it will display on the Forge, updates file type to markdown and standardizes previous entries. Adds template for release notes to be filled in later. --- CHANGELOG => CHANGELOG.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) rename CHANGELOG => CHANGELOG.md (93%) diff --git a/CHANGELOG b/CHANGELOG.md similarity index 93% rename from CHANGELOG rename to CHANGELOG.md index a36cbac..32784b1 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,32 +1,45 @@ -2014-02-12 1.0.1 +##2014-03-04 - Supported Release 1.0.x +###Summary -Summary: +####Features + +####Bugfixes + +####Known Bugs + +* Not supported on Windows. + + +##2014-02-12 - 1.0.1 + +###Summary Minor bugfixes for sorting of fragments and ordering of resources. -Bugfixes: +####Bugfixes - LANG => C replaced with LC_ALL => C to reduce spurious recreation of fragments. - Corrected pluginsync documentation. - Ensure concat::setup always runs before fragments. -2013-08-09 1.0.0 -Summary: +##2013-08-09 - 1.0.0 + +###Summary Many new features and bugfixes in this release, and if you're a heavy concat user you should test carefully before upgrading. The features should all be backwards compatible but only light testing has been done from our side before this release. -Features: +####Features - New parameters in concat: - `replace`: specify if concat should replace existing files. - `ensure_newline`: controls if fragments should contain a newline at the end. - Improved README documentation. - Add rspec:system tests (rake spec:system to test concat) -Bugfixes +####Bugfixes - Gracefully handle \n in a fragment resource name. - Adding more helpful message for 'pluginsync = true' - Allow passing `source` and `content` directly to file resource, rather than @@ -36,7 +49,7 @@ defining resource defaults. - Allow WARNMSG to contain/start with '#'. - Replace while-read pattern with for-do in order to support Solaris. -CHANGELOG: +####CHANGELOG: - 2010/02/19 - initial release - 2010/03/12 - add support for 0.24.8 and newer - make the location of sort configurable From 9afd286219d096ef20454e69c1d6176e96f35f11 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 28 Feb 2014 15:47:12 +0000 Subject: [PATCH 108/202] Prepare for supported modules. --- metadata.json | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 metadata.json diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..611c618 --- /dev/null +++ b/metadata.json @@ -0,0 +1,71 @@ +{ + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10", + "11" + ] + }, + { + "operatingsystem": "AIX", + "operatingsystemrelease": [ + "5.3", + "6.1", + "7.1" + ] + } + ], + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": "3.x" } + ] +} From 62913f72f590d38db1f50e4471ff54672241a51b Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 3 Mar 2014 19:19:20 +0000 Subject: [PATCH 109/202] Prepare supported module 1.0.2. --- CHANGELOG.md | 6 +++++- Modulefile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32784b1..ec0a281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ -##2014-03-04 - Supported Release 1.0.x +##2014-03-04 - Supported Release 1.0.2 ###Summary +This is a supported release. No functional changes were made from 1.0.1. + ####Features +- Huge amount of tests backported from 1.1. +- Documentation rewrite. ####Bugfixes diff --git a/Modulefile b/Modulefile index 7f223b8..a1c880e 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.1' +version '1.0.2' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From b4ba7dde50129eeb547ed6b6ade1d895ead3ec80 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 3 Mar 2014 21:45:21 +0000 Subject: [PATCH 110/202] Add in missing files to work around Puppet bug. --- metadata.json | 10 +++++++++- spec/fixtures/manifests/site.pp | 0 2 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 spec/fixtures/manifests/site.pp diff --git a/metadata.json b/metadata.json index 611c618..09d5524 100644 --- a/metadata.json +++ b/metadata.json @@ -1,4 +1,11 @@ { + "name": "puppetlabs-concat", + "version": "1.0.2", + "source": "https://github.com/puppetlabs/puppetlabs-concat", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-concat", + "summary": "Concat module", "operatingsystem_support": [ { "operatingsystem": "RedHat", @@ -67,5 +74,6 @@ "requirements": [ { "name": "pe", "version_requirement": "3.2.x" }, { "name": "puppet", "version_requirement": "3.x" } - ] + ], + "dependencies": [] } diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29..0000000 From fee285a2386510ce2dbbbf4172be31aab139ed4c Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 5 Mar 2014 09:15:45 -0800 Subject: [PATCH 111/202] Remove autorelease --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21ef81b..4e72cd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ branches: language: ruby bundler_args: --without development script: bundle exec rake spec SPEC_OPTS='--format documentation' -after_success: - - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng - - .forge-releng/publish # work around RubyGems 2.2.0 breaking ruby 1.8.7 # https://github.com/rubygems/rubygems/pull/763 # https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 @@ -24,7 +21,6 @@ env: - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - PUPPET_GEM_VERSION="~> 3.0" - global: matrix: fast_finish: true exclude: From e154e8d8f3c6e213e16e317ee5eb1e7c6e01bda6 Mon Sep 17 00:00:00 2001 From: Lucien Weller Date: Fri, 21 Feb 2014 19:36:52 +0100 Subject: [PATCH 112/202] ignore mode an owner on windows --- manifests/fragment.pp | 6 ++++-- manifests/setup.pp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index bea0e24..40baadd 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -68,6 +68,8 @@ define concat::fragment( $safe_target_name = regsubst($target, '[/:\n]', '_', 'GM') $concatdir = $concat::setup::concatdir $fragdir = "${concatdir}/${safe_target_name}" + $fragowner = $concat::setup::fragment_owner + $fragmode = $concat::setup::fragment_mode # The file type's semantics are problematic in that ensure => present will # not over write a pre-existing symlink. We are attempting to provide @@ -108,8 +110,8 @@ define concat::fragment( # can be relied on to be present file { "${fragdir}/fragments/${order}_${safe_name}": ensure => $safe_ensure, - owner => $::id, - mode => '0640', + owner => $fragowner, + mode => $fragmode, source => $source, content => $content, backup => false, diff --git a/manifests/setup.pp b/manifests/setup.pp index 8d36478..1767400 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -19,6 +19,10 @@ class concat::setup { } else { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } + + # owner and mode of fragment files (on windows owner and access rights should be inherited from concatdir and not explicitly set to avoid problems) + $fragment_owner = $osfamily ? { 'windows' => undef, default => $::id } + $fragment_mode = $osfamily ? { 'windows' => undef, default => '0640' } $script_name = $::kernel ? { 'windows' => 'concatfragments.rb', @@ -27,6 +31,10 @@ class concat::setup { $script_path = "${concatdir}/bin/${script_name}" + $script_owner = $osfamily ? { 'windows' => undef, default => $::id } + + $script_mode = $osfamily ? { 'windows' => undef, default => '0755' } + $script_command = $::kernel ? { 'windows' => "ruby.exe ${script_path}", default => $script_path @@ -38,8 +46,8 @@ class concat::setup { file { $script_path: ensure => file, - owner => $::id, - mode => '0755', + owner => $script_owner, + mode => $script_mode, source => "puppet:///modules/concat/${script_name}", } From c51b6598e3e11254be9d5874edfa2caf9db91f1f Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Fri, 4 Apr 2014 09:35:06 -0400 Subject: [PATCH 113/202] Proper quoting of quotes. --- files/concatfragments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index 6c02682..f237bed 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -98,7 +98,7 @@ if [ ! -d "${WORKDIR}/fragments" ] && [ ! -x "${WORKDIR}/fragments" ]; then fi # are there actually any fragments? -if [ ! "$(ls -A \"${WORKDIR}/fragments\")" ]; then +if [ ! "$(ls -A """${WORKDIR}/fragments""")" ]; then if [ "x${FORCE}" = "x" ]; then echo "The fragments directory is empty, cowardly refusing to make empty config files" exit 1 From a2df44a967d23e5aa114d19e7adae9f3703d7385 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 21 Apr 2014 18:36:59 -0400 Subject: [PATCH 114/202] Fix newlines. Previously the newline handling modified the actual fragments, causing multiple runs to always update the newlines. Handle this appropriately. --- files/concatfragments.sh | 8 ++++---- spec/acceptance/nodesets/aix-71-vcloud.yml | 19 +++++++++++++++++++ spec/acceptance/nodesets/centos-64-x64.yml | 2 +- spec/acceptance/nodesets/debian-73-x64.yml | 11 +++++++++++ spec/acceptance/nodesets/default.yml | 8 ++++---- spec/acceptance/nodesets/fedora-18-x64.yml | 2 +- spec/acceptance/nodesets/sles-11-x64.yml | 10 ++++++++++ .../nodesets/ubuntu-server-10044-x64.yml | 2 +- .../nodesets/ubuntu-server-12042-x64.yml | 2 +- 9 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 spec/acceptance/nodesets/aix-71-vcloud.yml create mode 100644 spec/acceptance/nodesets/debian-73-x64.yml create mode 100644 spec/acceptance/nodesets/sles-11-x64.yml diff --git a/files/concatfragments.sh b/files/concatfragments.sh index f237bed..f64113a 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -113,10 +113,6 @@ else printf '%s\n' "$WARNMSG" > "fragments.concat" fi -if [ "x${ENSURE_NEWLINE}" != "x" ]; then - find fragments/ -type f -follow -print0 | xargs -0 -I '{}' sh -c 'if [ -n "$(tail -c 1 < {} )" ]; then echo >> {} ; fi' -fi - # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir IFS_BACKUP=$IFS IFS=' @@ -124,6 +120,10 @@ IFS=' for fragfile in `find fragments/ -type f -follow | LC_ALL=C sort ${SORTARG}` do cat $fragfile >> "fragments.concat" + # Handle newlines. + if [ "x${ENSURE_NEWLINE}" != "x" ]; then + echo >> "fragments.concat" + fi done IFS=$IFS_BACKUP diff --git a/spec/acceptance/nodesets/aix-71-vcloud.yml b/spec/acceptance/nodesets/aix-71-vcloud.yml new file mode 100644 index 0000000..f0ae87a --- /dev/null +++ b/spec/acceptance/nodesets/aix-71-vcloud.yml @@ -0,0 +1,19 @@ +HOSTS: + pe-aix-71-acceptance: + roles: + - master + - dashboard + - database + - agent + - default + platform: aix-7.1-power + hypervisor: aix + ip: pe-aix-71-acceptance.delivery.puppetlabs.net +CONFIG: + type: pe + nfs_server: NONE + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/Enterprise/Dynamic + resourcepool: delivery/Quality Assurance/Enterprise/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml index 0639835..05540ed 100644 --- a/spec/acceptance/nodesets/centos-64-x64.yml +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml new file mode 100644 index 0000000..3e6a3a9 --- /dev/null +++ b/spec/acceptance/nodesets/debian-73-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-73-x64.localhost: + roles: + - 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 + hypervisor : vagrant +CONFIG: + log_level: debug + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 0639835..ae812b0 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,10 +1,10 @@ HOSTS: - centos-64-x64: + centos-64-x64.localdomain: roles: - 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 : centos-65-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss diff --git a/spec/acceptance/nodesets/fedora-18-x64.yml b/spec/acceptance/nodesets/fedora-18-x64.yml index 624b537..1361649 100644 --- a/spec/acceptance/nodesets/fedora-18-x64.yml +++ b/spec/acceptance/nodesets/fedora-18-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss diff --git a/spec/acceptance/nodesets/sles-11-x64.yml b/spec/acceptance/nodesets/sles-11-x64.yml new file mode 100644 index 0000000..41abe21 --- /dev/null +++ b/spec/acceptance/nodesets/sles-11-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11-x64.local: + roles: + - 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 + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml index 5047017..5ca1514 100644 --- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml index 1c7a34c..d065b30 100644 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss From 9590b7cb8a7229e8b0344e3d4da6d8daa2d86b60 Mon Sep 17 00:00:00 2001 From: Balint Deak Date: Fri, 25 Apr 2014 10:47:57 +0200 Subject: [PATCH 115/202] fix numeric sorting --- files/concatfragments.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/concatfragments.sh b/files/concatfragments.sh index f64113a..7e6b0f5 100755 --- a/files/concatfragments.sh +++ b/files/concatfragments.sh @@ -117,9 +117,9 @@ fi IFS_BACKUP=$IFS IFS=' ' -for fragfile in `find fragments/ -type f -follow | LC_ALL=C sort ${SORTARG}` +for fragfile in `find fragments/ -type f -follow -print0 | xargs -0 -n1 basename | LC_ALL=C sort ${SORTARG}` do - cat $fragfile >> "fragments.concat" + cat "fragments/$fragfile" >> "fragments.concat" # Handle newlines. if [ "x${ENSURE_NEWLINE}" != "x" ]; then echo >> "fragments.concat" From 8a1965ade9e48b7c3aebb30e27697960a14f9f29 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 2 May 2014 19:50:51 +0200 Subject: [PATCH 116/202] Improve this so it works on Ubuntu 14.04. --- spec/spec_helper_acceptance.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b064d68..22bd72f 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,17 +1,14 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' -hosts.each do |host| - if host['platform'] =~ /debian/ - on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' - end - if host.is_pe? +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + if hosts.first.is_pe? install_pe else - # Install Puppet - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' - on host, "mkdir -p #{host['distmoduledir']}" + install_puppet + end + hosts.each do |host| + on hosts, "mkdir -p #{host['distmoduledir']}" end end From 33b90b4fbc165061722477bce956cf0eeb1f9761 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 14 May 2014 16:10:03 -0400 Subject: [PATCH 117/202] Fixes to get tests running on trusty. --- .../nodesets/ubuntu-server-1404-x64.yml | 11 +++++++++++ spec/spec_helper_acceptance.rb | 16 +++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000..cba1cd0 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index c75a7fb..e6860c9 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,19 +1,17 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' -unless ENV['RS_PROVISION'] == 'no' +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + if hosts.first.is_pe? + install_pe + else + install_puppet + end hosts.each do |host| if host['platform'] =~ /debian/ on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' end - if host.is_pe? - install_pe - else - # Install Puppet - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' - on host, "mkdir -p #{host['distmoduledir']}" - end + on hosts, "mkdir -p #{host['distmoduledir']}" end end From 6b9e8ddc37eaadf595f647bc849656824464917a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 14 May 2014 16:14:53 -0400 Subject: [PATCH 118/202] Add nodeset for ubuntu trusty. --- spec/acceptance/nodesets/ubuntu-server-1404-x64.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000..cba1cd0 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git From fc56fe3d7c3dd2bb7ff792fca194b062b1744218 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 14 May 2014 16:30:29 -0400 Subject: [PATCH 119/202] Update changelog, modulefile and metadata.json for supported 1.0.3 release. --- CHANGELOG.md | 14 ++++++++++++++ Modulefile | 2 +- metadata.json | 18 +++++++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec0a281..ec049a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## - Supported Release 1.0.3 +###Summary + +This is a supported release. No functional changes were made from 1.0.2. + +####Features +- Added test support for Ubuntu Trusty. + +####Bugfixes + +####Known bugs + +*Not supported on Windows. + ##2014-03-04 - Supported Release 1.0.2 ###Summary diff --git a/Modulefile b/Modulefile index a1c880e..4f8a0aa 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.2' +version '1.0.3' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' diff --git a/metadata.json b/metadata.json index 09d5524..3f84e9b 100644 --- a/metadata.json +++ b/metadata.json @@ -11,28 +11,35 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", - "6" + "6", + "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", - "6" + "6", + "7" + ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", - "6" + "6", + "7" + ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", - "6" + "6", + "7" + ] }, { @@ -52,7 +59,8 @@ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", - "12.04" + "12.04", + "14.04" ] }, { From a50226b4ec5d6f2ba0df9e4f8a31df3e1160ff89 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 14 May 2014 17:31:04 -0400 Subject: [PATCH 120/202] Update CHANGELOG and Modulefile for 1.1.0 release. --- CHANGELOG | 17 ++++++++++++++++- Modulefile | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 829b111..c66b922 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,19 @@ -2014-01-03 1.1.0 +2014-05-14 1.1.0 + +Summary + +This release is primarily a bugfix release since 1.1.0-rc1. + +Features: +- Improved testing, with tests moved to beaker + +Bugfixes: +- No longer attempts to set fragment owner and mode on Windows +- Fix numeric sorting +- Fix incorrect quoting +- Fix newlines + +2014-01-03 1.1.0-rc1 Summary: diff --git a/Modulefile b/Modulefile index c90d6f4..ea9ef2c 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.1.0-rc1' +version '1.1.0' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' From 8f5c30c6a31807d385780f6ac83307f76ee92fd1 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 15 May 2014 14:58:07 -0400 Subject: [PATCH 121/202] Claim PE3.3 support. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 3f84e9b..773c988 100644 --- a/metadata.json +++ b/metadata.json @@ -80,7 +80,7 @@ } ], "requirements": [ - { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "pe", "version_requirement": "3.3.x" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] From 43a0313ba97aafeaf6f5e5f58a54587d72610d19 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 20 May 2014 14:03:28 -0400 Subject: [PATCH 122/202] Update version in metadata.json. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 773c988..ea6ca74 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-concat", - "version": "1.0.2", + "version": "1.0.3", "source": "https://github.com/puppetlabs/puppetlabs-concat", "author": "Puppet Labs", "license": "Apache-2.0", From cd645a8360069c1be7a484b08e53b8e305e82bf0 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Wed, 21 May 2014 17:06:37 -0600 Subject: [PATCH 123/202] Change default 'order' parameter to be a string Under Puppet 3.5.1 (and possibly earlier versions, too), the validate_string($order) fails when $order is actaully a numeric type. Apparently there is more strict type checking now. Can't just change validate_string to a is_numeric check, because it's fairly common to use strings like '01' for the order parameter, which doesn't pass the is_numeric test. Additionally, there is nothing saying that $order must be a number. Ultimately the ordering gets implemented as filesystem directory list sorting. --- manifests/fragment.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 40baadd..a51b8c2 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -28,7 +28,7 @@ define concat::fragment( $target, $content = undef, $source = undef, - $order = 10, + $order = '10', $ensure = undef, $mode = undef, $owner = undef, From 379e273e2e9b54556a5d6f5331887b76139c8b59 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 21 May 2014 19:28:25 -0400 Subject: [PATCH 124/202] Update PE version requirement. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index ea6ca74..25f9735 100644 --- a/metadata.json +++ b/metadata.json @@ -80,7 +80,7 @@ } ], "requirements": [ - { "name": "pe", "version_requirement": "3.3.x" }, + { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] From a4abf6f142939eaacf27a91eac92de7d208c6e03 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 28 May 2014 09:31:02 -0700 Subject: [PATCH 125/202] enable the ruby concat script on Solaris Per discussion on #174, Solaris 10 does not support the find/xargs switches that were introduced in that PR (but Solaris 11 does). + add a shebang to concatfragments.rb + fix linter warnings/errors --- files/concatfragments.rb | 1 + manifests/setup.pp | 28 ++++++++++------- spec/unit/classes/concat_setup_spec.rb | 42 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/files/concatfragments.rb b/files/concatfragments.rb index 73fd7f9..cb66b03 100755 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby # Script to concat files to a config file. # # Given a directory like this: diff --git a/manifests/setup.pp b/manifests/setup.pp index 1767400..549284e 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -7,7 +7,7 @@ # Since puppet should always manage files in $concatdir and they should # not be deleted ever, /tmp is not an option. # -# It also copies out the concatfragments.sh file to ${concatdir}/bin +# It also copies out the concatfragments.{sh,rb} file to ${concatdir}/bin # class concat::setup { if $caller_module_name != $module_name { @@ -19,23 +19,29 @@ class concat::setup { } else { fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') } - - # owner and mode of fragment files (on windows owner and access rights should be inherited from concatdir and not explicitly set to avoid problems) - $fragment_owner = $osfamily ? { 'windows' => undef, default => $::id } - $fragment_mode = $osfamily ? { 'windows' => undef, default => '0640' } - $script_name = $::kernel ? { - 'windows' => 'concatfragments.rb', - default => 'concatfragments.sh' + # owner and mode of fragment files (on windows owner and access rights should + # be inherited from concatdir and not explicitly set to avoid problems) + $fragment_owner = $::osfamily ? { 'windows' => undef, default => $::id } + $fragment_mode = $::osfamily ? { 'windows' => undef, default => '0640' } + + # PR #174 introduced changes to the concatfragments.sh script that are + # incompatible with Solaris 10 but reportedly OK on Solaris 11. As a work + # around we are enable the .rb concat script on all Solaris versions. If + # this goes smoothly, we should move towards completely eliminating the .sh + # version. + $script_name = $::osfamily? { + /(Windows|Solaris)/ => 'concatfragments.rb', + default => 'concatfragments.sh' } $script_path = "${concatdir}/bin/${script_name}" - $script_owner = $osfamily ? { 'windows' => undef, default => $::id } + $script_owner = $::osfamily ? { 'windows' => undef, default => $::id } - $script_mode = $osfamily ? { 'windows' => undef, default => '0755' } + $script_mode = $::osfamily ? { 'windows' => undef, default => '0755' } - $script_command = $::kernel ? { + $script_command = $::osfamily? { 'windows' => "ruby.exe ${script_path}", default => $script_path } diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index bba455a..4e83cb2 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -39,4 +39,46 @@ describe 'concat::setup', :type => :class do pending('rspec-puppet support for testing warning()') end end + + context "on osfamily Solaris" do + concatdir = '/foo' + let(:facts) do + { + :concat_basedir => concatdir, + :osfamily => 'Solaris', + :id => 'root', + } + end + + it do + should contain_file("#{concatdir}/bin/concatfragments.rb").with({ + :ensure => 'file', + :owner => 'root', + :mode => '0755', + :source => 'puppet:///modules/concat/concatfragments.rb', + :backup => false, + }) + end + end # on osfamily Solaris + + context "on osfamily Windows" do + concatdir = '/foo' + let(:facts) do + { + :concat_basedir => concatdir, + :osfamily => 'Windows', + :id => 'batman', + } + end + + it do + should contain_file("#{concatdir}/bin/concatfragments.rb").with({ + :ensure => 'file', + :owner => nil, + :mode => nil, + :source => 'puppet:///modules/concat/concatfragments.rb', + :backup => false, + }) + end + end # on osfamily Windows end From 8dedb6bffb9efd3510e9e869fcdbf39b8e53e1d2 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 23 May 2014 10:02:00 -0700 Subject: [PATCH 126/202] Validate the concat::fragment order parameter as string||integer This is to work around a validation issue that arises under the 3.x future parser, as proper numeric types have been introduced (ie, not all scalar values are strings). Users have come to expect to to be able to pass in unquoted integer values to the order parameter which will fail to validate as a string when the future parser is enabled. --- .fixtures.yml | 2 +- Modulefile | 2 +- README.md | 4 +++- manifests/fragment.pp | 4 +++- spec/unit/defines/concat_fragment_spec.rb | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index dc6b41f..67added 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,6 +2,6 @@ fixtures: repositories: 'stdlib': repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' - ref: '4.0.0' + ref: '4.2.0' symlinks: 'concat': '#{source_dir}' diff --git a/Modulefile b/Modulefile index ea9ef2c..bc1f199 100644 --- a/Modulefile +++ b/Modulefile @@ -6,4 +6,4 @@ license 'Apache 2.0' summary 'Concat module' description 'Concat module' project_page 'http://github.com/puppetlabs/puppetlabs-concat' -dependency 'puppetlabs/stdlib', '>= 4.0.0' +dependency 'puppetlabs/stdlib', '>= 4.2.0' diff --git a/README.md b/README.md index 60eca38..3f26ee7 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ class motd { } # used by other modules to register themselves in the motd -define motd::register($content="", $order=10) { +define motd::register($content="", $order='10') { if $content == "" { $body = $name } else { @@ -247,6 +247,8 @@ Order the fragments. ######Example - order => '01' +Best practice is to pass a string to this parameter but integer values are accepted. + #####`ensure` Control the file of fragment created. diff --git a/manifests/fragment.pp b/manifests/fragment.pp index a51b8c2..daa6a23 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -40,7 +40,9 @@ define concat::fragment( if !(is_string($source) or is_array($source)) { fail('$source is not a string or an Array.') } - validate_string($order) + if !(is_string($order) or is_integer($order)) { + fail('$order is not a string or integer.') + } if $mode { warning('The $mode parameter to concat::fragment is deprecated and has no effect') } diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 3b5269e..3c61aab 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -152,7 +152,7 @@ describe 'concat::fragment', :type => :define do let(:params) {{ :order => false, :target => '/etc/motd' }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { should }.to raise_error(Puppet::Error, /is not a string or integer/) end end end # order => From 6ca22bd99c41aeca5276b65d238cf17a7139bdf7 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 28 May 2014 08:59:55 -0700 Subject: [PATCH 127/202] raise the "low bar" travis puppet version to 2.7.6 It appears that puppet 2.7.3 does not play nicely with stdlib 4.2.0. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e72cd4..1288819 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ rvm: - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - PUPPET_GEM_VERSION="~> 3.0" @@ -25,13 +25,13 @@ matrix: fast_finish: true exclude: - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - rvm: 2.0.0 From 5cdd051dea2c40e3da754337551be4830f2d7b89 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 28 May 2014 09:03:20 -0700 Subject: [PATCH 128/202] add .vagrant to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 143345e..d681eca 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ spec/fixtures .rspec_system .bundle *.sw* +.vagrant From f66ca3c1b7d67be9143d20d10eed101265bba442 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 2 Jun 2014 16:10:29 -0400 Subject: [PATCH 129/202] Remove all the eq() checks as this breaks in PE3.3. --- spec/acceptance/backup_spec.rb | 10 ++++---- spec/acceptance/concat_spec.rb | 4 ++-- spec/acceptance/empty_spec.rb | 4 ++-- spec/acceptance/fragment_source_spec.rb | 8 +++---- spec/acceptance/newline_spec.rb | 32 ++----------------------- spec/acceptance/order_spec.rb | 16 ++++++------- spec/acceptance/replace_spec.rb | 20 ++++++++-------- spec/acceptance/symbolic_name_spec.rb | 4 ++-- spec/acceptance/warn_spec.rb | 12 +++++----- 9 files changed, 40 insertions(+), 70 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index c09c178..efd19a5 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -22,10 +22,9 @@ describe 'concat backup parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fa it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stderr).to eq("") expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' end - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -55,8 +54,8 @@ describe 'concat backup parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fa # XXX Puppet doesn't mention anything about filebucketing with a given # extension like .backup it 'applies the manifest twice no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -91,10 +90,9 @@ describe 'concat backup parameter', :unless => UNSUPPORTED_PLATFORMS.include?(fa it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stderr).to eq("") expect(r.stdout).to_not match(/Filebucketed/) end - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index b4f7352..d2950e7 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -17,8 +17,8 @@ describe 'basic concat test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('os shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end end diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 8eb0a96..21da4a3 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -12,8 +12,8 @@ describe 'concat force empty parameter', :unless => UNSUPPORTED_PLATFORMS.includ EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 3f6eb49..610ec5c 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -39,8 +39,8 @@ describe 'concat::fragment source', :unless => UNSUPPORTED_PLATFORMS.include?(fa EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/foo") do @@ -95,8 +95,8 @@ describe 'concat::fragment source', :unless => UNSUPPORTED_PLATFORMS.include?(fa EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/result_file1") do it { should be_file } diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index fb3f17d..f102bf1 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -19,8 +19,8 @@ describe 'concat ensure_newline parameter', :unless => UNSUPPORTED_PLATFORMS.inc EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -29,32 +29,4 @@ describe 'concat ensure_newline parameter', :unless => UNSUPPORTED_PLATFORMS.inc end end - #context '=> true' do - # pp = <<-EOS - # include concat::setup - # concat { '#{basedir}/file': - # ensure_newline => true, - # } - # concat::fragment { '1': - # target => '#{basedir}/file', - # content => '1', - # } - # concat::fragment { '2': - # target => '#{basedir}/file', - # content => '2', - # } - # EOS - - # it 'applies the manifest twice with no stderr' do - # expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - # expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") - # #XXX ensure_newline => true causes changes on every run because the files - # #are modified in place. - # end - - # describe file("#{basedir}/file") do - # it { should be_file } - # it { should contain "1\n2\n" } - # end - #end end diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index 1c79ab4..ff7e602 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -28,8 +28,8 @@ describe 'concat order', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamil EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/foo") do @@ -62,8 +62,8 @@ describe 'concat order', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamil EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/foo") do @@ -105,8 +105,8 @@ describe 'concat::fragment order', :unless => UNSUPPORTED_PLATFORMS.include?(fac EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/foo") do @@ -140,8 +140,8 @@ describe 'concat::fragment order', :unless => UNSUPPORTED_PLATFORMS.include?(fac EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/foo") do diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index e84140f..4d6c893 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -30,8 +30,8 @@ describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -69,8 +69,8 @@ describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -113,8 +113,8 @@ describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end # XXX specinfra doesn't support be_linked_to on AIX @@ -159,8 +159,8 @@ describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -236,8 +236,8 @@ describe 'replacement of', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index 57a9e95..adba2c2 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -22,8 +22,8 @@ describe 'symbolic name', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfami EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index b036884..11acc2e 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -23,8 +23,8 @@ describe 'concat warn =>', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -55,8 +55,8 @@ describe 'concat warn =>', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do @@ -87,8 +87,8 @@ describe 'concat warn =>', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfam EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do From 13ae29d24badccd6ac9bf79e4af7e6bd779199bd Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 4 Jun 2014 14:04:16 -0400 Subject: [PATCH 130/202] Update for the 1.0.3 release being unsupported. --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec049a0..cffb151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ -## - Supported Release 1.0.3 +##2014-06-04 - Release 1.0.3 ###Summary -This is a supported release. No functional changes were made from 1.0.2. +This release adds compatibility for PE3.3 and fixes tests. ####Features - Added test support for Ubuntu Trusty. From c0a918e4f31d7973d96ce702084ba0d021641a51 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 9 Jun 2014 11:30:17 -0400 Subject: [PATCH 131/202] Pin rspec to 2.x. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 56b9775..814a2d8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :test do gem 'rake', :require => false + gem 'rspec', '~> 2.11', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'beaker', :require => false From d25226e36ac2d8b3d5570a97ead2cf63e5891201 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 9 Jun 2014 17:11:51 -0400 Subject: [PATCH 132/202] Try to force it to use the correct version of beaker-rspec. --- Gemfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 814a2d8..4c72c2c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,7 @@ group :development, :test do gem 'rspec', '~> 2.11', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false + gem 'beaker-rspec', '>= 2.2', :require => false gem 'puppet-lint', :require => false gem 'serverspec', :require => false gem 'pry', :require => false From 90f70e86a329e351140f543e1b5ce55ff8d108e0 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 11 Jun 2014 17:25:08 -0400 Subject: [PATCH 133/202] 'wheel' is the root group for osx. --- spec/acceptance/concat_spec.rb | 3 +++ spec/acceptance/fragment_source_spec.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index d2950e7..708559a 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -4,6 +4,9 @@ case fact('osfamily') when 'AIX' username = 'root' groupname = 'system' +when 'Darwin' + username = 'root' + groupname = 'wheel' when 'windows' username = 'Administrator' groupname = 'Administrators' diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 610ec5c..82a3cba 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -4,6 +4,9 @@ case fact('osfamily') when 'AIX' username = 'root' groupname = 'system' +when 'Darwin' + username = 'root' + groupname = 'wheel' when 'windows' username = 'Administrator' groupname = 'Administrators' From 070f184ce3331c757121eb44af3a5337f209cbb7 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 17 Jun 2014 11:00:54 -0400 Subject: [PATCH 134/202] Prep for 1.0.4 release. --- CHANGELOG.md | 14 ++++++++++++++ Modulefile | 2 +- metadata.json | 8 +++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cffb151..580f6c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +##2014-06-25 - Supported Release 1.0.4 +###Summary + +This release has test fixes. + +####Features +- Added test support for OSX. + +####Bugfixes + +####Known bugs + +* Not supported on Windows. + ##2014-06-04 - Release 1.0.3 ###Summary diff --git a/Modulefile b/Modulefile index 4f8a0aa..37a6bf1 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-concat' -version '1.0.3' +version '1.0.4' source 'git://github.com/puppetlabs/puppetlabs-concat.git' author 'Puppetlabs' license 'Apache 2.0' diff --git a/metadata.json b/metadata.json index 25f9735..84ef010 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-concat", - "version": "1.0.3", + "version": "1.0.4", "source": "https://github.com/puppetlabs/puppetlabs-concat", "author": "Puppet Labs", "license": "Apache-2.0", @@ -77,6 +77,12 @@ "6.1", "7.1" ] + }, + { + "operatingsystem": "OSX", + "operatingsystemrelease": [ + "10.9" + ] } ], "requirements": [ From da59390ed20e22455790f664af4f59b2fe9f2175 Mon Sep 17 00:00:00 2001 From: Luis Fernandez Alvarez Date: Wed, 18 Jun 2014 09:09:47 +0200 Subject: [PATCH 135/202] Add quotes to the ruby script location Without this patch, if the ruby script is located in a path with spaces, it will not work. --- manifests/setup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index 549284e..fbc6e51 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -42,7 +42,7 @@ class concat::setup { $script_mode = $::osfamily ? { 'windows' => undef, default => '0755' } $script_command = $::osfamily? { - 'windows' => "ruby.exe ${script_path}", + 'windows' => "ruby.exe '${script_path}'", default => $script_path } From 222ecc020ac0ee2347190cc4c23d3fa0952a962b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sat, 21 Jun 2014 14:16:47 +0200 Subject: [PATCH 136/202] small typo: missing losing ' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f26ee7..495cce5 100644 --- a/README.md +++ b/README.md @@ -400,7 +400,7 @@ concatenated file and this feature has been removed. ```puppet include concat::setup # generates deprecation warning -class { 'concat::setup: } # generates deprecation warning +class { 'concat::setup': } # generates deprecation warning ``` The `concat::setup` class is deprecated as a public API of this module and From 551d8308c1573c2454737aa97008a93e13afbe2a Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 08:19:44 -0700 Subject: [PATCH 137/202] Add configuration file for modulesync https://github.com/puppetlabs/modulesync --- .sync.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .sync.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..1962bec --- /dev/null +++ b/.sync.yml @@ -0,0 +1,30 @@ +--- +.travis.yml: + additional: + - + configs: + before_install: + - gem update --system 2.1.11 + - gem --version + comments: + - work around RubyGems 2.2.0 breaking ruby 1.8.7 + - https://github.com/rubygems/rubygems/pull/763 + - https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 + excludes: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env_matrix: + - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.0" From 2b51a83b9baeebcd795d94a8051ba598b6353ae2 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 17:23:15 -0700 Subject: [PATCH 138/202] Sync files --- .gitignore | 13 +- .travis.yml | 47 +++-- CONTRIBUTING.md | 234 +++++++++++++++++++++ Gemfile | 5 +- Rakefile | 7 +- spec/acceptance/nodesets/centos-65-x64.yml | 10 + spec/spec.opts | 6 + 7 files changed, 289 insertions(+), 33 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 spec/acceptance/nodesets/centos-65-x64.yml create mode 100644 spec/spec.opts diff --git a/.gitignore b/.gitignore index d681eca..b5b7a00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ -.pkg +pkg/ Gemfile.lock -vendor -spec/fixtures -.rspec_system -.bundle -*.sw* -.vagrant +vendor/ +spec/fixtures/ +.vagrant/ +.bundle/ +coverage/ diff --git a/.travis.yml b/.travis.yml index 1288819..b021033 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,37 +4,38 @@ branches: - master language: ruby bundler_args: --without development -script: bundle exec rake spec SPEC_OPTS='--format documentation' -# work around RubyGems 2.2.0 breaking ruby 1.8.7 -# https://github.com/rubygems/rubygems/pull/763 -# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 -before_install: - - gem update --system 2.1.11 - - gem --version +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" rvm: - 1.8.7 - 1.9.3 - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - PUPPET_GEM_VERSION="~> 3.0" + - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.0" matrix: fast_finish: true exclude: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" notifications: email: false +# work around RubyGems 2.2.0 breaking ruby 1.8.7 +# https://github.com/rubygems/rubygems/pull/763 +# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 +before_install: +- gem update --system 2.1.11 +- gem --version + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e128847 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,234 @@ +Checklist (and a short version for the impatient) +================================================= + + * Commits: + + - Make commits of logical units. + + - Check for unnecessary whitespace with "git diff --check" before + committing. + + - Commit using Unix line endings (check the settings around "crlf" in + git-config(1)). + + - Do not check in commented out code or unneeded files. + + - The first line of the commit message should be a short + description (50 characters is the soft limit, excluding ticket + number(s)), and should skip the full stop. + + - Associate the issue in the message. The first line should include + the issue number in the form "(#XXXX) Rest of message". + + - The body should provide a meaningful commit message, which: + + - uses the imperative, present tense: "change", not "changed" or + "changes". + + - includes motivation for the change, and contrasts its + implementation with the previous behavior. + + - Make sure that you have tests for the bug you are fixing, or + feature you are adding. + + - Make sure the test suites passes after your commit: + `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below + + - When introducing a new feature, make sure it is properly + documented in the README.md + + * Submission: + + * Pre-requisites: + + - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) + + - Make sure you have a [GitHub account](https://github.com/join) + + - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + + * Preferred method: + + - Fork the repository on GitHub. + + - Push your changes to a topic branch in your fork of the + repository. (the format ticket/1234-short_description_of_change is + usually preferred for this project). + + - Submit a pull request to the repository in the puppetlabs + organization. + +The long version +================ + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sign the Contributor License Agreement + + Before we can accept your changes, we do need a signed Puppet + Labs Contributor License Agreement (CLA). + + You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) + + If you have any questions about the CLA, please feel free to + contact Puppet Labs via email at cla-submissions@puppetlabs.com. + + 3. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on "master". + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 4. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +Testing +======= + +Getting Started +--------------- + +Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby +package manager such as [bundler](http://bundler.io/) what Ruby packages, +or Gems, are required to build, develop, and test this software. + +Please make sure you have [bundler installed](http://bundler.io/#getting-started) +on your system, then use it to install all dependencies needed for this project, +by running + +```shell +% bundle install +Fetching gem metadata from https://rubygems.org/........ +Fetching gem metadata from https://rubygems.org/.. +Using rake (10.1.0) +Using builder (3.2.2) +-- 8><-- many more --><8 -- +Using rspec-system-puppet (2.2.0) +Using serverspec (0.6.3) +Using rspec-system-serverspec (1.0.0) +Using bundler (1.3.5) +Your bundle is complete! +Use `bundle show [gemname]` to see where a bundled gem is installed. +``` + +NOTE some systems may require you to run this command with sudo. + +If you already have those gems installed, make sure they are up-to-date: + +```shell +% bundle update +``` + +With all dependencies in place and up-to-date we can now run the tests: + +```shell +% rake spec +``` + +This will execute all the [rspec tests](http://rspec-puppet.com/) tests +under [spec/defines](./spec/defines), [spec/classes](./spec/classes), +and so on. rspec tests may have the same kind of dependencies as the +module they are testing. While the module defines in its [Modulefile](./Modulefile), +rspec tests define them in [.fixtures.yml](./fixtures.yml). + +Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) +tests. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/)) with, controlling it with +[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test +scenarios. In order to run these, you will need both of those tools +installed on your system. + +You can run them by issuing the following command + +```shell +% rake spec_clean +% rspec spec/acceptance +``` + +This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), +install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +and then run all the tests under [spec/acceptance](./spec/acceptance). + +Writing Tests +------------- + +XXX getting started writing tests. + +If you have commit access to the repository +=========================================== + +Even if you have commit access to the repository, you will still need to +go through the process above, and have someone else review and merge +in your changes. The rule is that all changes must be reviewed by a +developer on the project (that did not write the code) to ensure that +all changes go through a code review process. + +Having someone other than the author of the topic branch recorded as +performing the merge is the record that they performed the code +review. + + +Additional Resources +==================== + +* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) + +* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) + +* [Patchwork](https://patchwork.puppetlabs.com) + +* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) + +* [General GitHub documentation](http://help.github.com/) + +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) + diff --git a/Gemfile b/Gemfile index 56b9775..9074f1e 100644 --- a/Gemfile +++ b/Gemfile @@ -4,11 +4,12 @@ group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false gem 'beaker', :require => false gem 'beaker-rspec', :require => false - gem 'puppet-lint', :require => false - gem 'serverspec', :require => false gem 'pry', :require => false + gem 'simplecov', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 23aea87..5868545 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,10 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.fail_on_warnings PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_quoted_booleans') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_class_parameter_defaults') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml new file mode 100644 index 0000000..4e2cb80 --- /dev/null +++ b/spec/acceptance/nodesets/centos-65-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-65-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 + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..91cd642 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace From ad7198219620dd8da41a2572c9b880a499092f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Helleboid=20-=20chtitux?= Date: Thu, 26 Jun 2014 10:45:35 +0200 Subject: [PATCH 139/202] README.md : add missing ',' Small typo, a ',' was missing on the minimal exampel conf --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 495cce5..b884a0a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ concat { '/tmp/file': } concat::fragment { 'tmpfile': - target => '/tmp/file' + target => '/tmp/file', content => 'test contents', order => '01' } From 4b191654cb391c5491da57d5f583709defd11401 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 27 Jun 2014 09:29:18 -0700 Subject: [PATCH 140/202] Update .sync.yml to support new .travis.yml configs --- .sync.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/.sync.yml b/.sync.yml index 1962bec..ed97d53 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,30 +1 @@ --- -.travis.yml: - additional: - - - configs: - before_install: - - gem update --system 2.1.11 - - gem --version - comments: - - work around RubyGems 2.2.0 breaking ruby 1.8.7 - - https://github.com/rubygems/rubygems/pull/763 - - https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 - excludes: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - env_matrix: - - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - PUPPET_GEM_VERSION="~> 3.0" From d6a8ceeb1a4b68501505ba8b547505906c6f175d Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 27 Jun 2014 10:52:12 -0700 Subject: [PATCH 141/202] Synchronize .travis.yml --- .travis.yml | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index b021033..c72d5e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,41 +1,17 @@ --- -branches: - only: - - master language: ruby bundler_args: --without development script: "bundle exec rake spec SPEC_OPTS='--format documentation'" -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 -env: - matrix: - - PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - - PUPPET_GEM_VERSION="~> 3.0" matrix: fast_finish: true - exclude: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 1.9.3 + include: + - rvm: 1.8.7 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="2.7.6" FACTER_GEM_VERSION="1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" notifications: email: false -# work around RubyGems 2.2.0 breaking ruby 1.8.7 -# https://github.com/rubygems/rubygems/pull/763 -# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 -before_install: -- gem update --system 2.1.11 -- gem --version - From ec789e11ad7774febe18218173cbe7fb21ee8c67 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 30 Jun 2014 10:57:48 -0700 Subject: [PATCH 142/202] Update Gemfile for .travis.yml defaults --- Gemfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index 9074f1e..e960f7c 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,12 @@ group :development, :test do gem 'simplecov', :require => false end +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false +end + if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false else From 9c94193b3b007b90aed55c1f387b6460ee5325a8 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Thu, 3 Jul 2014 09:53:38 -0700 Subject: [PATCH 143/202] Add validate and lint tasks to travis script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c72d5e2..a40ae50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: ruby bundler_args: --without development -script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true include: From 0ce713fd9c96e018af17ab49cf572993d3ca9df0 Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Wed, 9 Jul 2014 13:45:16 +1000 Subject: [PATCH 144/202] fix concat broken on windows due to case sensitive regexp -- made it case insensitive --- manifests/setup.pp | 4 ++-- spec/unit/classes/concat_setup_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index fbc6e51..1a6af64 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -31,8 +31,8 @@ class concat::setup { # this goes smoothly, we should move towards completely eliminating the .sh # version. $script_name = $::osfamily? { - /(Windows|Solaris)/ => 'concatfragments.rb', - default => 'concatfragments.sh' + /(?i:(Windows|Solaris))/ => 'concatfragments.rb', + default => 'concatfragments.sh' } $script_path = "${concatdir}/bin/${script_name}" diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 4e83cb2..3096e73 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -61,12 +61,12 @@ describe 'concat::setup', :type => :class do end end # on osfamily Solaris - context "on osfamily Windows" do + context "on osfamily windows" do concatdir = '/foo' let(:facts) do { :concat_basedir => concatdir, - :osfamily => 'Windows', + :osfamily => 'windows', :id => 'batman', } end @@ -80,5 +80,5 @@ describe 'concat::setup', :type => :class do :backup => false, }) end - end # on osfamily Windows + end # on osfamily windows end From 4fa5222cdd7e436d18063db86d99ca219faff27c Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Wed, 9 Jul 2014 16:11:08 +1000 Subject: [PATCH 145/202] added missing line endings (-l) support for windows and solaris --- files/concatfragments.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) mode change 100755 => 100644 files/concatfragments.rb diff --git a/files/concatfragments.rb b/files/concatfragments.rb old mode 100755 new mode 100644 index cb66b03..904f824 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -45,7 +45,8 @@ settings = { :test => false, :force => false, :warn => "", - :sortarg => "" + :sortarg => "", + :newline => false } OptionParser.new do |opts| @@ -77,6 +78,10 @@ OptionParser.new do |opts| opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do settings[:sortarg] = "-n" end + + opts.on("-l", "--line", "Append a newline") do + settings[:newline] = true + end end.parse! # do we have -o? @@ -119,8 +124,15 @@ end # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir open('fragments.concat', 'a') do |f| Dir.entries("fragments").sort.each{ |entry| + if File.file?(File.join("fragments", entry)) - f << File.read(File.join("fragments", entry)) + f << File.read(File.join("fragments", entry)) + + # append a newline if we were asked to (invoked with -l) + if settings[:newline] + f << "\n" + end + end } end From 8e6fe8c45987fba26be907893568779ad5efe5b6 Mon Sep 17 00:00:00 2001 From: Tomas Doran Date: Thu, 10 Jul 2014 18:35:12 -0400 Subject: [PATCH 146/202] Fix errors with the future parser. Error: Illegal name. The given name _ensure does not conform to the naming rule \A((::)?[a-z0-9]w*)(::[a-z0-9]w*)*\z at /etc/puppet/vendor/modules/concat/manifests/fragment.pp:57:5 --- manifests/fragment.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index daa6a23..28f8251 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -56,12 +56,12 @@ define concat::fragment( warning('The $backup parameter to concat::fragment is deprecated and has no effect') } if $ensure == undef { - $_ensure = getparam(Concat[$target], 'ensure') + $my_ensure = getparam(Concat[$target], 'ensure') } else { if ! ($ensure in [ 'present', 'absent' ]) { warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') } - $_ensure = $ensure + $my_ensure = $ensure } include concat::setup @@ -80,18 +80,18 @@ define concat::fragment( # be paranoid and only allow the fragment's file resource's ensure param to # be file, absent, or a file target - $safe_ensure = $_ensure ? { + $safe_ensure = $my_ensure ? { '' => 'file', undef => 'file', 'file' => 'file', 'present' => 'file', 'absent' => 'absent', - default => $_ensure, + default => $my_ensure, } # if it looks line ensure => /target syntax was used, fish that out - if ! ($_ensure in ['', 'present', 'absent', 'file' ]) { - $ensure_target = $_ensure + if ! ($my_ensure in ['', 'present', 'absent', 'file' ]) { + $ensure_target = $my_ensure } else { $ensure_target = undef } From ca8e036bacd4f33a0fd135c941c5c40f9a681499 Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Sat, 2 Aug 2014 00:18:16 +0100 Subject: [PATCH 147/202] ensure concat file fragments are always replaced --- manifests/fragment.pp | 1 + .../fragments_are_always_replaced_spec.rb | 119 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 spec/acceptance/fragments_are_always_replaced_spec.rb diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 28f8251..0af7edf 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -117,6 +117,7 @@ define concat::fragment( source => $source, content => $content, backup => false, + replace => true, alias => "concat_fragment_${name}", notify => Exec["concat_${target}"] } diff --git a/spec/acceptance/fragments_are_always_replaced_spec.rb b/spec/acceptance/fragments_are_always_replaced_spec.rb new file mode 100644 index 0000000..a207b05 --- /dev/null +++ b/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -0,0 +1,119 @@ +require 'spec_helper_acceptance' + +describe 'concat::fragment replace' do + context 'should create fragment files' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir /tmp/concat') + end + + pp1 = <<-EOS + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace unset run 1', + } + EOS + pp2 = <<-EOS + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace unset run 2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should_not contain 'caller has replace unset run 1' } + it { should contain 'caller has replace unset run 2' } + end + end # should create fragment files + + context 'should replace its own fragment files when caller has File { replace=>true } set' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir /tmp/concat') + end + + pp1 = <<-EOS + File { replace=>true } + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace true set run 1', + } + EOS + pp2 = <<-EOS + File { replace=>true } + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace true set run 2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should_not contain 'caller has replace true set run 1' } + it { should contain 'caller has replace true set run 2' } + end + end # should replace its own fragment files when caller has File(replace=>true) set + + context 'should replace its own fragment files even when caller has File { replace=>false } set' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir /tmp/concat') + end + + pp1 = <<-EOS + File { replace=>false } + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace false set run 1', + } + EOS + pp2 = <<-EOS + File { replace=>false } + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'caller has replace false set run 2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should_not contain 'caller has replace false set run 1' } + it { should contain 'caller has replace false set run 2' } + end + end # should replace its own fragment files even when caller has File(replace=>false) set + +end From b4e1c0c38745b75d7c2ad4633e021fcd2e6e3749 Mon Sep 17 00:00:00 2001 From: Axel Bock Date: Wed, 13 Aug 2014 08:50:08 +0200 Subject: [PATCH 148/202] fix: permitting $backup to be a boolean value --- manifests/init.pp | 4 +++- spec/unit/defines/concat_spec.rb | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 91d82eb..4a68403 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -75,7 +75,9 @@ define concat( fail('$warn is not a string or boolean') } validate_bool($force) - validate_string($backup) + if ! is_bool($backup) and ! is_string($backup) { + fail('$backup must be string or bool!') + } validate_bool($replace) validate_re($order, '^alpha$|^numeric$') validate_bool($ensure_newline) diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 9fdd7b2..5dfdfd2 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -307,10 +307,18 @@ describe 'concat', :type => :define do end context 'false' do + it_behaves_like 'concat', '/etc/foo.bar', { :backup => false } + end + + context 'true' do + it_behaves_like 'concat', '/etc/foo.bar', { :backup => true } + end + + context 'true' do let(:title) { '/etc/foo.bar' } - let(:params) {{ :backup => false }} + let(:params) {{ :backup => [] }} it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not a string/) + expect { should }.to raise_error(Puppet::Error, /backup must be string or bool/) end end end # backup => From b0a365ba37896ae49676b2d1481bc7e728c66eb4 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 19 Aug 2014 10:17:45 -0700 Subject: [PATCH 149/202] Remove Puppet 2.7 from travis matrix --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a40ae50..d497009 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,6 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake matrix: fast_finish: true include: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 From bf1f3dedd63ef9d9881c10410fb7c248194e6b80 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 19 Aug 2014 10:51:01 -0700 Subject: [PATCH 150/202] Add testing on Ruby 1.8.7 with Puppet 3 to travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d497009..66e90e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake matrix: fast_finish: true include: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 From e464dfc771c55389e4c83d3b415b938d69208fe5 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 19 Aug 2014 13:45:42 -0700 Subject: [PATCH 151/202] Pin puppet-lint to 0.3.2 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e960f7c..081b1a2 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ group :development, :test do gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'serverspec', :require => false - gem 'puppet-lint', :require => false + gem 'puppet-lint', '0.3.2', :require => false gem 'beaker', :require => false gem 'beaker-rspec', :require => false gem 'pry', :require => false From 52a75bc10c34392659448afcb7feb719b7e26b6f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 28 Aug 2014 11:26:34 -0400 Subject: [PATCH 152/202] Update spec_helper for consistency --- spec/spec_helper_acceptance.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 22bd72f..e93a9f9 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -2,11 +2,12 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - if hosts.first.is_pe? - install_pe - else - install_puppet - end + # 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' } + + if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end + hosts.each do |host| on hosts, "mkdir -p #{host['distmoduledir']}" end From 7e222ae8a851266e286d2d1083740a3a03a4daec Mon Sep 17 00:00:00 2001 From: Matt Ezell Date: Tue, 2 Sep 2014 14:39:37 -0400 Subject: [PATCH 153/202] Remove documentation for deprecated $warn_message parameter Commit 8a500af removed $warn_message. Also remove it from the documentation --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b884a0a..f01c287 100644 --- a/README.md +++ b/README.md @@ -173,17 +173,13 @@ Set the mode of the combined file. #####`warn` Determine if a warning message should be added at the top of the file to let -users know it was autogenerated by Puppet. +users know it was autogenerated by Puppet. It should be a boolean or a string +containing the contents of the warning message. ######Example - warn => true - warn => false - -#####`warn_message` -Set the contents of the warning message. - -######Example -- warn_message => 'This file is autogenerated!' +- warn => '# This file is autogenerated!' #####`force` Determine if empty files are allowed when no fragments were added. From 3d167883ddf9cb9d7a10663732544499ce2c4f5a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 5 Sep 2014 16:21:29 -0400 Subject: [PATCH 154/202] Remove dependency on stdlib4 --- Modulefile | 9 -- .../parser/functions/concat_getparam.rb | 35 ++++++ lib/puppet/parser/functions/concat_is_bool.rb | 22 ++++ manifests/fragment.pp | 2 +- manifests/init.pp | 2 +- metadata.json | 111 ++++++++++++++++++ 6 files changed, 170 insertions(+), 11 deletions(-) delete mode 100644 Modulefile create mode 100644 lib/puppet/parser/functions/concat_getparam.rb create mode 100644 lib/puppet/parser/functions/concat_is_bool.rb create mode 100644 metadata.json diff --git a/Modulefile b/Modulefile deleted file mode 100644 index bc1f199..0000000 --- a/Modulefile +++ /dev/null @@ -1,9 +0,0 @@ -name 'puppetlabs-concat' -version '1.1.0' -source 'git://github.com/puppetlabs/puppetlabs-concat.git' -author 'Puppetlabs' -license 'Apache 2.0' -summary 'Concat module' -description 'Concat module' -project_page 'http://github.com/puppetlabs/puppetlabs-concat' -dependency 'puppetlabs/stdlib', '>= 4.2.0' diff --git a/lib/puppet/parser/functions/concat_getparam.rb b/lib/puppet/parser/functions/concat_getparam.rb new file mode 100644 index 0000000..1757bdc --- /dev/null +++ b/lib/puppet/parser/functions/concat_getparam.rb @@ -0,0 +1,35 @@ +# Test whether a given class or definition is defined +require 'puppet/parser/functions' + +Puppet::Parser::Functions.newfunction(:concat_getparam, + :type => :rvalue, + :doc => <<-'ENDOFDOC' +Takes a resource reference and name of the parameter and +returns value of resource's parameter. + +*Examples:* + + define example_resource($param) { + } + + example_resource { "example_resource_instance": + param => "param_value" + } + + concat_getparam(Example_resource["example_resource_instance"], "param") + +Would return: param_value +ENDOFDOC +) do |vals| + reference, param = vals + raise(ArgumentError, 'Must specify a reference') unless reference + raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String + + return '' if param.empty? + + if resource = findresource(reference.to_s) + return resource[param] if resource[param] + end + + return '' +end diff --git a/lib/puppet/parser/functions/concat_is_bool.rb b/lib/puppet/parser/functions/concat_is_bool.rb new file mode 100644 index 0000000..c2c2a9f --- /dev/null +++ b/lib/puppet/parser/functions/concat_is_bool.rb @@ -0,0 +1,22 @@ +# +# concat_is_bool.rb +# + +module Puppet::Parser::Functions + newfunction(:concat_is_bool, :type => :rvalue, :doc => <<-EOS +Returns true if the variable passed to this function is a boolean. + EOS + ) do |arguments| + + raise(Puppet::ParseError, "concat_is_bool(): Wrong number of arguments " + + "given (#{arguments.size} for 1)") if arguments.size != 1 + + type = arguments[0] + + result = type.is_a?(TrueClass) || type.is_a?(FalseClass) + + return result + end +end + +# vim: set ts=2 sw=2 et : diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 0af7edf..34ec4c2 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -56,7 +56,7 @@ define concat::fragment( warning('The $backup parameter to concat::fragment is deprecated and has no effect') } if $ensure == undef { - $my_ensure = getparam(Concat[$target], 'ensure') + $my_ensure = concat_getparam(Concat[$target], 'ensure') } else { if ! ($ensure in [ 'present', 'absent' ]) { warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') diff --git a/manifests/init.pp b/manifests/init.pp index 4a68403..a9fa86a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -75,7 +75,7 @@ define concat( fail('$warn is not a string or boolean') } validate_bool($force) - if ! is_bool($backup) and ! is_string($backup) { + if ! concat_is_bool($backup) and ! is_string($backup) { fail('$backup must be string or bool!') } validate_bool($replace) diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..ede05f9 --- /dev/null +++ b/metadata.json @@ -0,0 +1,111 @@ +{ + "name": "puppetlabs-concat", + "version": "1.1.0", + "author": "Puppet Labs", + "summary": "Concat module", + "license": "Apache-2.0", + "source": "https://github.com/puppetlabs/puppetlabs-concat", + "project_page": "https://github.com/puppetlabs/puppetlabs-concat", + "issues_url": "https://github.com/puppetlabs/puppetlabs-concat/issues", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10", + "11" + ] + }, + { + "operatingsystem": "Windows", + "operatingsystemrelease": [ + "Server 2003 R2", + "Server 2008 R2", + "Server 2012", + "Server 2012 R2" + ] + }, + { + "operatingsystem": "AIX", + "operatingsystemrelease": [ + "5.3", + "6.1", + "7.1" + ] + }, + { + "operatingsystem": "OSX", + "operatingsystemrelease": [ + "10.9" + ] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": "3.x" + }, + { + "name": "puppet", + "version_requirement": "3.x" + } + ], + "dependencies": [ + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 3.2.0 < 5.0.0" + } + ] +} From d56febe3240f7b7c8e20be61b4fd8f85323b549f Mon Sep 17 00:00:00 2001 From: Pi3r Date: Mon, 8 Sep 2014 15:50:16 +0200 Subject: [PATCH 155/202] Update README.md Unless I misread the [code] (https://github.com/puppetlabs/puppetlabs-concat/blob/master/manifests/fragment.pp#L61-L63), only 'present' or 'absent' should be used. All other options are deprecated ? --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index f01c287..2ed9024 100644 --- a/README.md +++ b/README.md @@ -251,8 +251,6 @@ Control the file of fragment created. ######Example - ensure => 'present' - ensure => 'absent' -- ensure => 'file' -- ensure => 'directory' #####`mode` Set the mode of the fragment. From e015a1fdf731bb7ea169b553daae1eb80a5bb40f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Sep 2014 14:24:29 -0400 Subject: [PATCH 156/202] Lack of idempotency with `ensure => 'absent'` Need to add an unless to the exec in the case we have `ensure => 'absent'` for the concat, otherwise the exec (of true) runs every time. --- manifests/init.pp | 4 +++- spec/unit/defines/concat_spec.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index a9fa86a..77f9d5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -223,10 +223,12 @@ define concat( default => '/bin:/usr/bin', } + # Need to have an unless here for idempotency. exec { "concat_${name}": alias => "concat_${fragdir}", command => $absent_exec_command, - path => $absent_exec_path + unless => $absent_exec_command, + path => $absent_exec_path, } } } diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 5dfdfd2..e7be4d5 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -144,6 +144,7 @@ describe 'concat', :type => :define do should contain_exec("concat_#{title}").with({ :alias => "concat_#{fragdir}", :command => 'true', + :unless => 'true', :path => '/bin:/usr/bin', }) end From 0acefbb79d1fa176697a500054a2108ffbf30eaf Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Sep 2014 15:01:30 -0400 Subject: [PATCH 157/202] Stop checking for empty stderr --- spec/acceptance/backup_spec.rb | 8 +++---- spec/acceptance/concat_spec.rb | 8 +++---- spec/acceptance/deprecation_warnings_spec.rb | 8 +++---- spec/acceptance/empty_spec.rb | 4 ++-- spec/acceptance/fragment_source_spec.rb | 8 +++---- .../fragments_are_always_replaced_spec.rb | 24 +++++++++---------- spec/acceptance/newline_spec.rb | 8 +++---- spec/acceptance/order_spec.rb | 16 ++++++------- spec/acceptance/quoted_paths_spec.rb | 4 ++-- spec/acceptance/replace_spec.rb | 20 ++++++++-------- spec/acceptance/symbolic_name_spec.rb | 4 ++-- spec/acceptance/warn_spec.rb | 12 +++++----- 12 files changed, 62 insertions(+), 62 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 7b2858d..5440781 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -23,7 +23,7 @@ describe 'concat backup parameter' do expect(r.stderr).to eq("") expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' end - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -52,8 +52,8 @@ describe 'concat backup parameter' do # XXX Puppet doesn't mention anything about filebucketing with a given # extension like .backup it 'applies the manifest twice no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -90,7 +90,7 @@ describe 'concat backup parameter' do expect(r.stderr).to eq("") expect(r.stdout).to_not match(/Filebucketed/) end - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 89919cc..8a45e97 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -4,8 +4,8 @@ describe 'basic concat test' do shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{default['puppetvardir']}/concat") do @@ -192,8 +192,8 @@ describe 'basic concat test' do # Can't used shared examples as this will always trigger the exec when # absent is set. it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index f139d81..6f8fce1 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -111,8 +111,8 @@ describe 'deprecation warnings' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -149,8 +149,8 @@ describe 'deprecation warnings' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 0999528..0a7ac86 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -12,8 +12,8 @@ describe 'concat force empty parameter' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 3afd534..7edd380 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -25,8 +25,8 @@ describe 'concat::fragment source' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -80,8 +80,8 @@ describe 'concat::fragment source' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/result_file1') do it { should be_file } diff --git a/spec/acceptance/fragments_are_always_replaced_spec.rb b/spec/acceptance/fragments_are_always_replaced_spec.rb index a207b05..2c999f7 100644 --- a/spec/acceptance/fragments_are_always_replaced_spec.rb +++ b/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -25,10 +25,10 @@ describe 'concat::fragment replace' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + apply_manifest(pp1, :catch_failures => true) + apply_manifest(pp1, :catch_changes => true) + apply_manifest(pp2, :catch_failures => true) + apply_manifest(pp2, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -64,10 +64,10 @@ describe 'concat::fragment replace' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + apply_manifest(pp1, :catch_failures => true) + apply_manifest(pp1, :catch_changes => true) + apply_manifest(pp2, :catch_failures => true) + apply_manifest(pp2, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -103,10 +103,10 @@ describe 'concat::fragment replace' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp1, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp1, :catch_changes => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp2, :catch_changes => true).stderr).to eq("") + apply_manifest(pp1, :catch_failures => true) + apply_manifest(pp1, :catch_changes => true) + apply_manifest(pp2, :catch_failures => true) + apply_manifest(pp2, :catch_changes => true) end describe file('/tmp/concat/foo') do diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 1e989df..d0801ee 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -17,8 +17,8 @@ describe 'concat ensure_newline parameter' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -43,8 +43,8 @@ describe 'concat ensure_newline parameter' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) #XXX ensure_newline => true causes changes on every run because the files #are modified in place. end diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index 8bcb713..5d90549 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -26,8 +26,8 @@ describe 'concat order' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -56,8 +56,8 @@ describe 'concat order' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -94,8 +94,8 @@ describe 'concat::fragment order' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/foo') do @@ -125,8 +125,8 @@ describe 'concat::fragment order' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/foo') do diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index d1a2b5f..0b6695d 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -21,8 +21,8 @@ describe 'quoted paths' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat test/foo') do diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 7b31e09..39dd548 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -28,8 +28,8 @@ describe 'replacement of' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -66,8 +66,8 @@ describe 'replacement of' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -109,8 +109,8 @@ describe 'replacement of' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -153,8 +153,8 @@ describe 'replacement of' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -228,8 +228,8 @@ describe 'replacement of' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index 7267f5e..574e1d1 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -20,8 +20,8 @@ describe 'symbolic name' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index cb0b743..536eb2a 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -21,8 +21,8 @@ describe 'concat warn =>' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -52,8 +52,8 @@ describe 'concat warn =>' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do @@ -83,8 +83,8 @@ describe 'concat warn =>' do EOS it 'applies the manifest twice with no stderr' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") - expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end describe file('/tmp/concat/file') do From 166189dc25f43be81f22179343fdd80c9f51b081 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Sep 2014 16:03:22 -0400 Subject: [PATCH 158/202] Missed two stderr checks --- spec/acceptance/backup_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 5440781..156776d 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -20,7 +20,6 @@ describe 'concat backup parameter' do it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stderr).to eq("") expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' end apply_manifest(pp, :catch_changes => true) @@ -87,7 +86,6 @@ describe 'concat backup parameter' do it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stderr).to eq("") expect(r.stdout).to_not match(/Filebucketed/) end apply_manifest(pp, :catch_changes => true) From 77d6502a2d0428eba4eaf03000512e8d4d15ba5d Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Sep 2014 16:48:08 -0400 Subject: [PATCH 159/202] 1.1.1 prep --- CHANGELOG => CHANGELOG.md | 127 ++++++++++++++++++++++++++++++-------- metadata.json | 2 +- 2 files changed, 103 insertions(+), 26 deletions(-) rename CHANGELOG => CHANGELOG.md (65%) diff --git a/CHANGELOG b/CHANGELOG.md similarity index 65% rename from CHANGELOG rename to CHANGELOG.md index c66b922..f889866 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,21 +1,41 @@ -2014-05-14 1.1.0 +##2014-09-10 - Supported Release 1.1.1 -Summary +###Summary + +This is a bugfix release, and the first supported release of the 1.1.x series. + +####Bugfixes +- Make the `$order` parameter default to a string and be validated as an integer + or a string +- Use the ruby script on Solaris to not break Sol10 support +- Add quotes to the ryby script location for Windows +- Fix typos in README.md +- Make regex in concat::setup case-insensitive to make it work on Windows +- Make sure concat fragments are always replaced +- Fix validation to allow `$backup` to be a boolean +- Remove dependency on stdlib 4.x +- Fix for lack of idempotency with `ensure => 'absent'` +- Fix tests and spec_helper +- Synchronized files for more consistency across modules via modulesync + +##2014-05-14 - Release 1.1.0 + +###Summary This release is primarily a bugfix release since 1.1.0-rc1. -Features: +####Features - Improved testing, with tests moved to beaker -Bugfixes: +####Bugfixes - No longer attempts to set fragment owner and mode on Windows - Fix numeric sorting - Fix incorrect quoting - Fix newlines -2014-01-03 1.1.0-rc1 +##2014-01-03 - Release 1.1.0-rc1 -Summary: +###Summary This release of concat was 90% written by Joshua Hoblitt, and the module team would like to thank him for the huge amount of work he put into this release. @@ -33,49 +53,106 @@ warnings and we'll be aggressively moving for a 2.0 to remove those too. For further information on deprecations, please read: https://github.com/puppetlabs/puppetlabs-concat/blob/master/README.md#api-deprecations -Removed: +####Removed - Puppet 0.24 support. - Filebucket backup of all file resources except the target concatenated file. - Default owner/user/group values. - Purging of long unused /usr/local/bin/concatfragments.sh -Features: +###Features - Windows support via a ruby version of the concat bash script. - Huge amount of acceptance testing work added. - Documentation (README) completely rewritten. - New parameters in concat: - `ensure`: Controls if the file should be present/absent at all. -- Remove requirement to include concat::setup in manifests. -- Made `gnu` parameter deprecated. -- Added parameter validation. + - Remove requirement to include concat::setup in manifests. + - Made `gnu` parameter deprecated. + - Added parameter validation. -Bugfixes: -- Ensure concat::setup runs before concat::fragment in all cases. -- Pluginsync references updated for modern Puppet. -- Fix incorrect group parameter. -- Use $owner instead of $id to avoid confusion with $::id -- Compatibility fixes for Puppet 2.7/ruby 1.8.7 -- Use LC_ALL=C instead of LANG=C -- Always exec the concatfragments script as root when running as root. -- Syntax and other cleanup changes. +###Bugfixes + - Ensure concat::setup runs before concat::fragment in all cases. + - Pluginsync references updated for modern Puppet. + - Fix incorrect group parameter. + - Use $owner instead of $id to avoid confusion with $::id + - Compatibility fixes for Puppet 2.7/ruby 1.8.7 + - Use LC_ALL=C instead of LANG=C + - Always exec the concatfragments script as root when running as root. + - Syntax and other cleanup changes. -2013-08-09 1.0.0 +##2014-06-25 - Supported Release 1.0.4 +###Summary -Summary: +This release has test fixes. + +####Features +- Added test support for OSX. + +####Bugfixes + +####Known bugs + +* Not supported on Windows. + +##2014-06-04 - Release 1.0.3 +###Summary + +This release adds compatibility for PE3.3 and fixes tests. + +####Features +- Added test support for Ubuntu Trusty. + +####Bugfixes + +####Known bugs + +*Not supported on Windows. + +##2014-03-04 - Supported Release 1.0.2 +###Summary + +This is a supported release. No functional changes were made from 1.0.1. + +####Features +- Huge amount of tests backported from 1.1. +- Documentation rewrite. + +####Bugfixes + +####Known Bugs + +* Not supported on Windows. + + +##2014-02-12 - 1.0.1 + +###Summary + +Minor bugfixes for sorting of fragments and ordering of resources. + +####Bugfixes +- LANG => C replaced with LC_ALL => C to reduce spurious recreation of +fragments. +- Corrected pluginsync documentation. +- Ensure concat::setup always runs before fragments. + + +##2013-08-09 - 1.0.0 + +###Summary Many new features and bugfixes in this release, and if you're a heavy concat user you should test carefully before upgrading. The features should all be backwards compatible but only light testing has been done from our side before this release. -Features: +####Features - New parameters in concat: - `replace`: specify if concat should replace existing files. - `ensure_newline`: controls if fragments should contain a newline at the end. - Improved README documentation. - Add rspec:system tests (rake spec:system to test concat) -Bugfixes +####Bugfixes - Gracefully handle \n in a fragment resource name. - Adding more helpful message for 'pluginsync = true' - Allow passing `source` and `content` directly to file resource, rather than @@ -85,7 +162,7 @@ defining resource defaults. - Allow WARNMSG to contain/start with '#'. - Replace while-read pattern with for-do in order to support Solaris. -CHANGELOG: +####CHANGELOG: - 2010/02/19 - initial release - 2010/03/12 - add support for 0.24.8 and newer - make the location of sort configurable diff --git a/metadata.json b/metadata.json index ede05f9..51f42f9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-concat", - "version": "1.1.0", + "version": "1.1.1", "author": "Puppet Labs", "summary": "Concat module", "license": "Apache-2.0", From 98d70da9fdb597e5a62995b789b05b8885bbfb8e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 11 Jun 2014 17:25:08 -0400 Subject: [PATCH 160/202] 'wheel' is the root group for osx. Conflicts: spec/acceptance/concat_spec.rb spec/acceptance/fragment_source_spec.rb --- spec/acceptance/concat_spec.rb | 135 +++++++++--------------- spec/acceptance/fragment_source_spec.rb | 115 +++++++++++--------- 2 files changed, 113 insertions(+), 137 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 8a45e97..3668217 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,6 +1,22 @@ require 'spec_helper_acceptance' -describe 'basic concat test' do +case fact('osfamily') +when 'AIX' + username = 'root' + groupname = 'system' +when 'Darwin' + username = 'root' + groupname = 'wheel' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' +end + +describe 'basic concat test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + basedir = default.tmpdir('concat') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do @@ -10,64 +26,64 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat") do it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/bin") do it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do it { should be_file } - it { should be_owned_by 'root' } - #it { should be_grouped_into 'root' } + it { should be_owned_by username } + #it { should be_grouped_into groupname } it { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 750 } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 750 } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 640 } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 640 } end end context 'owner/group root' do pp = <<-EOS - concat { '/tmp/concat/file': - owner => 'root', - group => 'root', + concat { '#{basedir}/file': + owner => '#{username}', + group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => '2', order => '02', } @@ -75,89 +91,34 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/concat/file') do + describe file('#{basedir}/file') do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 644 } it { should contain '1' } it { should contain '2' } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 640 } end describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } + it { should be_owned_by username } + it { should be_grouped_into groupname } it { should be_mode 640 } end end - context 'owner/group non-root' do - before(:all) do - shell "groupadd -g 64444 bob" - shell "useradd -u 42 -g 64444 bob" - end - after(:all) do - shell "userdel bob" - end - - pp=" - concat { '/tmp/concat/file': - owner => 'bob', - group => 'bob', - mode => '0644', - } - - concat::fragment { '1': - target => '/tmp/concat/file', - content => '1', - order => '01', - } - - concat::fragment { '2': - target => '/tmp/concat/file', - content => '2', - order => '02', - } - " - - it_behaves_like 'successfully_applied', pp - - describe file('/tmp/concat/file') do - it { should be_file } - it { should be_owned_by 'bob' } - it { should be_grouped_into 'bob' } - it { should be_mode 644 } - it { should contain '1' } - it { should contain '2' } - end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do - it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 640 } - it { should contain '1' } - end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do - it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 640 } - it { should contain '2' } - end - end - context 'ensure' do context 'works when set to present with path set' do pp=" concat { 'file': ensure => present, - path => '/tmp/concat/file', + path => '#{basedir}/file', mode => '0644', } concat::fragment { '1': @@ -169,7 +130,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('/tmp/concat/file') do + describe file('#{basedir}/file') do it { should be_file } it { should be_mode 644 } it { should contain '1' } @@ -179,7 +140,7 @@ describe 'basic concat test' do pp=" concat { 'file': ensure => absent, - path => '/tmp/concat/file', + path => '#{basedir}/file', mode => '0644', } concat::fragment { '1': @@ -193,10 +154,10 @@ describe 'basic concat test' do # absent is set. it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/file') do + describe file('#{basedir}/file') do it { should_not be_file } end end diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 7edd380..9c5427a 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -1,26 +1,45 @@ require 'spec_helper_acceptance' -describe 'concat::fragment source' do - context 'should read file fragments from local system' do - before(:all) do - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - shell("/bin/echo 'file2 contents' > /tmp/concat/file2") - end +case fact('osfamily') +when 'AIX' + username = 'root' + groupname = 'system' +when 'Darwin' + username = 'root' + groupname = 'wheel' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' +end +describe 'concat::fragment source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + basedir = default.tmpdir('concat') + context 'should read file fragments from local system' do pp = <<-EOS - concat { '/tmp/concat/foo': } + file { '#{basedir}/file1': + content => "file1 contents\n" + } + file { '#{basedir}/file2': + content => "file2 contents\n" + } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', - source => '/tmp/concat/file1', + target => '#{basedir}/foo', + source => '#{basedir}/file1', + require => File['#{basedir}/file1'], } concat::fragment { '2': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'string1 contents', } concat::fragment { '3': - target => '/tmp/concat/foo', - source => '/tmp/concat/file2', + target => '#{basedir}/foo', + source => '#{basedir}/file2', + require => File['#{basedir}/file2'], } EOS @@ -29,7 +48,7 @@ describe 'concat::fragment source' do apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file('#{basedir}/foo') do it { should be_file } it { should contain 'file1 contents' } it { should contain 'string1 contents' } @@ -38,43 +57,45 @@ describe 'concat::fragment source' do end # should read file fragments from local system context 'should create files containing first match only.' do - before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - shell("/bin/echo 'file2 contents' > /tmp/concat/file2") - end - pp = <<-EOS - concat { '/tmp/concat/result_file1': - owner => root, - group => root, + file { '#{basedir}/file1': + content => "file1 contents\n" + } + file { '#{basedir}/file2': + content => "file2 contents\n" + } + concat { '#{basedir}/result_file1': + owner => '#{username}', + group => '#{groupname}', mode => '0644', } - concat { '/tmp/concat/result_file2': - owner => root, - group => root, + concat { '#{basedir}/result_file2': + owner => '#{username}', + group => '#{groupname}', mode => '0644', } - concat { '/tmp/concat/result_file3': - owner => root, - group => root, + concat { '#{basedir}/result_file3': + owner => '#{username}', + group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/result_file1', - source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + target => '#{basedir}/result_file1', + source => [ '#{basedir}/file1', '#{basedir}/file2' ], + require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], order => '01', } concat::fragment { '2': - target => '/tmp/concat/result_file2', - source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], + target => '#{basedir}/result_file2', + source => [ '#{basedir}/file2', '#{basedir}/file1' ], + require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], order => '01', } concat::fragment { '3': - target => '/tmp/concat/result_file3', - source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + target => '#{basedir}/result_file3', + source => [ '#{basedir}/file1', '#{basedir}/file2' ], + require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], order => '01', } EOS @@ -83,17 +104,17 @@ describe 'concat::fragment source' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/result_file1') do + describe file('#{basedir}/result_file1') do it { should be_file } it { should contain 'file1 contents' } it { should_not contain 'file2 contents' } end - describe file('/tmp/concat/result_file2') do + describe file('#{basedir}/result_file2') do it { should be_file } it { should contain 'file2 contents' } it { should_not contain 'file1 contents' } end - describe file('/tmp/concat/result_file3') do + describe file('#{basedir}/result_file3') do it { should be_file } it { should contain 'file1 contents' } it { should_not contain 'file2 contents' } @@ -101,22 +122,16 @@ describe 'concat::fragment source' do end context 'should fail if no match on source.' do - before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') - shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither') - end - pp = <<-EOS - concat { '/tmp/concat/fail_no_source': - owner => root, - group => root, + concat { '#{basedir}/fail_no_source': + owner => '#{username}', + group => '#{groupname}', mode => '0644', } concat::fragment { '1': - target => '/tmp/concat/fail_no_source', - source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], + target => '#{basedir}/fail_no_source', + source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ], order => '01', } EOS @@ -124,7 +139,7 @@ describe 'concat::fragment source' do it 'applies the manifest with resource failures' do apply_manifest(pp, :expect_failures => true) end - describe file('/tmp/concat/fail_no_source') do + describe file('#{basedir}/fail_no_source') do #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. it { should_not be_file } it { should_not be_directory } From a6590ba98d63d68216fb2a5a0de2836fb3821164 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 10 Sep 2014 12:26:28 -0400 Subject: [PATCH 161/202] There are no UNSUPPORTED_PLATFORMS defined for 1.1 --- spec/acceptance/concat_spec.rb | 2 +- spec/acceptance/fragment_source_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 3668217..72981e6 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -15,7 +15,7 @@ else groupname = 'root' end -describe 'basic concat test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do +describe 'basic concat test' do basedir = default.tmpdir('concat') shared_examples 'successfully_applied' do |pp| diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index 9c5427a..3c4d9ae 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -15,7 +15,7 @@ else groupname = 'root' end -describe 'concat::fragment source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do +describe 'concat::fragment source' do basedir = default.tmpdir('concat') context 'should read file fragments from local system' do pp = <<-EOS From 968dac5a311e3ab65d48a9602b7373922f271ef4 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Wed, 10 Sep 2014 10:07:24 -0700 Subject: [PATCH 162/202] Remove deprecated puppet_module_install in favor of copy_module_to --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index e93a9f9..363f4d0 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -23,8 +23,8 @@ RSpec.configure do |c| # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'concat') hosts.each do |host| + copy_module_to(host, :source => proj_root, :module_name => 'concat') on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } end end From f81ef495e3fb48148b913468ef3f566b225a7bb3 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 10 Sep 2014 19:06:17 -0400 Subject: [PATCH 163/202] Fixing up tests --- spec/acceptance/backup_spec.rb | 52 ++++++++++++------- spec/acceptance/concat_spec.rb | 45 +++++++++++++---- spec/acceptance/empty_spec.rb | 1 - spec/acceptance/newline_spec.rb | 12 ++++- spec/acceptance/order_spec.rb | 1 - spec/acceptance/replace_spec.rb | 90 +++++++++++++++++++++------------ 6 files changed, 138 insertions(+), 63 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index bd30c6c..1989f44 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -3,18 +3,24 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do basedir = default.tmpdir('concat') context '=> puppet' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + content => "old contents\n", + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "old contents\n", - } concat { '#{basedir}/file': - backup => 'puppet', - require => File['#{basedir}/file'], + backup => 'puppet', } concat::fragment { 'new file': target => '#{basedir}/file', content => 'new contents', - require => File['#{basedir}/file'], } EOS @@ -32,18 +38,24 @@ describe 'concat backup parameter' do end context '=> .backup' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + content => "old contents\n", + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "old contents\n", - } concat { '#{basedir}/file': - backup => '.backup', - require => File['#{basedir}/file'], + backup => '.backup', } concat::fragment { 'new file': target => '#{basedir}/file', content => 'new contents', - require => File['#{basedir}/file'], } EOS @@ -67,18 +79,24 @@ describe 'concat backup parameter' do # XXX The backup parameter uses validate_string() and thus can't be the # boolean false value, but the string 'false' has the same effect in Puppet 3 context "=> 'false'" do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + content => "old contents\n", + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "old contents\n", - } concat { '#{basedir}/file': backup => '.backup', - require => File['#{basedir}/file'], } concat::fragment { 'new file': target => '#{basedir}/file', content => 'new contents', - require => File['#{basedir}/file'], } EOS diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 44a9a23..31c1647 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -17,6 +17,7 @@ end describe 'basic concat test' do basedir = default.tmpdir('concat') + safe_basedir = basedir.gsub('/','_') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do @@ -32,7 +33,7 @@ describe 'basic concat test' do should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin") do + describe file("#{default['puppetvardir']}/concat/bin") do it { should be_directory } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -48,7 +49,7 @@ describe 'basic concat test' do should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -56,7 +57,7 @@ describe 'basic concat test' do should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -64,7 +65,7 @@ describe 'basic concat test' do should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -72,7 +73,7 @@ describe 'basic concat test' do should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -83,6 +84,14 @@ describe 'basic concat test' do end context 'owner/group root' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) + end pp = <<-EOS concat { '#{basedir}/file': owner => '#{username}', @@ -105,7 +114,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('#{basedir}/file') do + describe file("#{basedir}/file") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -115,7 +124,7 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -123,7 +132,7 @@ describe 'basic concat test' do should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do + describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } @@ -135,6 +144,14 @@ describe 'basic concat test' do context 'ensure' do context 'works when set to present with path set' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) + end pp=" concat { 'file': ensure => present, @@ -150,7 +167,7 @@ describe 'basic concat test' do it_behaves_like 'successfully_applied', pp - describe file('#{basedir}/file') do + describe file("#{basedir}/file") do it { should be_file } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 644 @@ -159,6 +176,14 @@ describe 'basic concat test' do end end context 'works when set to absent with path set' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) + end pp=" concat { 'file': ensure => absent, @@ -177,7 +202,7 @@ describe 'basic concat test' do apply_manifest(pp, :catch_changes => true) end - describe file('#{basedir}/file') do + describe file("#{basedir}/file") do it { should_not be_file } end end diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 27175ab..dc57cb7 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -4,7 +4,6 @@ describe 'concat force empty parameter' do basedir = default.tmpdir('concat') context 'should run successfully' do pp = <<-EOS - include concat::setup concat { '#{basedir}/file': mode => '0644', force => true, diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 95a32af..5554962 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -3,8 +3,16 @@ require 'spec_helper_acceptance' describe 'concat ensure_newline parameter' do basedir = default.tmpdir('concat') context '=> false' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory + } + EOS + + apply_manifest(pp) + end pp = <<-EOS - include concat::setup concat { '#{basedir}/file': ensure_newline => false, } @@ -49,7 +57,7 @@ describe 'concat ensure_newline parameter' do apply_manifest(pp, :catch_changes => true) end - describe file('#{basedir}/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain "1\n2\n" } end diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index a3c80b6..fd7b05b 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -5,7 +5,6 @@ describe 'concat order' do context '=> alpha' do pp = <<-EOS - include concat::setup concat { '#{basedir}/foo': order => 'alpha' } diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 88e3524..c200cb2 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -4,25 +4,30 @@ describe 'replacement of' do basedir = default.tmpdir('concat') context 'file' do context 'should not succeed' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + content => "file exists\n" + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "file exists\n" - } concat { '#{basedir}/file': replace => false, - require => File['#{basedir}/file'], } concat::fragment { '1': target => '#{basedir}/file', content => '1', - require => File['#{basedir}/file'], } concat::fragment { '2': target => '#{basedir}/file', content => '2', - require => File['#{basedir}/file'], } EOS @@ -40,25 +45,30 @@ describe 'replacement of' do end context 'should succeed' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + content => "file exists\n" + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "file exists\n" - } concat { '#{basedir}/file': replace => true, - require => File['#{basedir}/file'], } concat::fragment { '1': target => '#{basedir}/file', content => '1', - require => File['#{basedir}/file'], } concat::fragment { '2': target => '#{basedir}/file', content => '2', - require => File['#{basedir}/file'], } EOS @@ -81,30 +91,32 @@ describe 'replacement of' do # XXX the core puppet file type will replace a symlink with a plain file # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + ensure => link, + target => '#{basedir}/dangling', + } + EOS + apply_manifest(pp) + end pp = <<-EOS - file { '#{basedir}/file': - content => "file exists\n" - } - file { '{basedir}/dangling': - ensure => link, - target => File['#{basedir}/file'], - } concat { '#{basedir}/file': replace => false, - require => File['{basedir}/dangling'], } concat::fragment { '1': target => '#{basedir}/file', content => '1', - require => File['{basedir}/dangling'], } concat::fragment { '2': target => '#{basedir}/file', content => '2', - require => File['{basedir}/dangling'], } EOS @@ -129,29 +141,32 @@ describe 'replacement of' do # XXX the core puppet file type will replace a symlink with a plain file # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + ensure => link, + target => '#{basedir}/dangling', + } + EOS + apply_manifest(pp) + end + pp = <<-EOS - file { '#{basedir}/file': - content => "file exists\n" - } - file { '{basedir}/dangling': - ensure => link, - target => File['#{basedir}/file'], - } concat { '#{basedir}/file': replace => true, - require => File['{basedir}/dangling'], } concat::fragment { '1': target => '#{basedir}/file', content => '1', - require => File['{basedir}/dangling'], } concat::fragment { '2': target => '#{basedir}/file', content => '2', - require => File['{basedir}/dangling'], } EOS @@ -170,6 +185,17 @@ describe 'replacement of' do context 'directory' do context 'should not succeed' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file': + ensure => directory, + } + EOS + apply_manifest(pp) + end pp = <<-EOS concat { '#{basedir}/file': } From 41d8273dfe214fefd628929fad0b548c7bc5f520 Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Wed, 9 Jul 2014 16:11:08 +1000 Subject: [PATCH 164/202] added missing line endings (-l) support for windows and solaris --- files/concatfragments.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) mode change 100755 => 100644 files/concatfragments.rb diff --git a/files/concatfragments.rb b/files/concatfragments.rb old mode 100755 new mode 100644 index cb66b03..904f824 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -45,7 +45,8 @@ settings = { :test => false, :force => false, :warn => "", - :sortarg => "" + :sortarg => "", + :newline => false } OptionParser.new do |opts| @@ -77,6 +78,10 @@ OptionParser.new do |opts| opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do settings[:sortarg] = "-n" end + + opts.on("-l", "--line", "Append a newline") do + settings[:newline] = true + end end.parse! # do we have -o? @@ -119,8 +124,15 @@ end # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir open('fragments.concat', 'a') do |f| Dir.entries("fragments").sort.each{ |entry| + if File.file?(File.join("fragments", entry)) - f << File.read(File.join("fragments", entry)) + f << File.read(File.join("fragments", entry)) + + # append a newline if we were asked to (invoked with -l) + if settings[:newline] + f << "\n" + end + end } end From 344f6adb36910f3f6cb447669d7b32aed8a624a2 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 11 Sep 2014 12:18:05 -0400 Subject: [PATCH 165/202] Try to remove all the platform dependent stuff And updated the tests to work as planned --- spec/acceptance/concat_spec.rb | 35 ++++---- spec/acceptance/deprecation_warnings_spec.rb | 79 ++++++++++--------- .../fragments_are_always_replaced_spec.rb | 56 ++++++++----- spec/acceptance/quoted_paths_spec.rb | 21 +++-- 4 files changed, 108 insertions(+), 83 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 31c1647..2b4fc91 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -2,17 +2,25 @@ require 'spec_helper_acceptance' case fact('osfamily') when 'AIX' - username = 'root' - groupname = 'system' + username = 'root' + groupname = 'system' + scriptname = 'concatfragments.sh' when 'Darwin' - username = 'root' - groupname = 'wheel' + username = 'root' + groupname = 'wheel' + scriptname = 'concatfragments.sh' when 'windows' - username = 'Administrator' - groupname = 'Administrators' + username = 'Administrator' + groupname = 'Administrators' + scriptname = 'concatfragments.rb' +when 'solaris' + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.rb' else - username = 'root' - groupname = 'root' + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.sh' end describe 'basic concat test' do @@ -28,7 +36,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } @@ -36,15 +43,13 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do + describe file("#{default['puppetvardir']}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - #it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } @@ -52,7 +57,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } @@ -60,7 +64,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } @@ -68,7 +71,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } @@ -76,7 +78,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } @@ -127,7 +128,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } @@ -135,7 +135,6 @@ describe 'basic concat test' do describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index 6f8fce1..93ad411 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper_acceptance' describe 'deprecation warnings' do + basedir = default.tmpdir('concat') shared_examples 'has_warning'do |pp, w| it 'applies the manifest twice with a stderr regex' do @@ -11,11 +12,11 @@ describe 'deprecation warnings' do context 'concat gnu parameter' do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': gnu => 'foo', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS @@ -28,11 +29,11 @@ describe 'deprecation warnings' do ['true', 'yes', 'on'].each do |warn| context warn do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => '#{warn}', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS @@ -40,7 +41,7 @@ describe 'deprecation warnings' do it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain 'bar' } @@ -51,11 +52,11 @@ describe 'deprecation warnings' do ['false', 'no', 'off'].each do |warn| context warn do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => '#{warn}', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS @@ -63,7 +64,7 @@ describe 'deprecation warnings' do it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain 'bar' } @@ -75,37 +76,39 @@ describe 'deprecation warnings' do context 'concat::fragment ensure parameter' do context 'target file exists' do before(:all) do - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - end - after(:all) do - # XXX this test may leave behind a symlink in the fragment directory - # which could cause warnings and/or breakage from the subsequent tests - # unless we clean it up. - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') + shell("/bin/echo 'file1 contents' > #{basedir}/file1") + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file1': + content => "file1 contents\n", + } + EOS + apply_manifest(pp) end pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - ensure => '/tmp/concat/file1', + target => '#{basedir}/file', + ensure => '#{basedir}/file1', } EOS w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'file1 contents' } end describe 'the fragment can be changed from a symlink to a plain file' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new content', } EOS @@ -115,7 +118,7 @@ describe 'deprecation warnings' do apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new content' } it { should_not contain 'file1 contents' } @@ -125,25 +128,25 @@ describe 'deprecation warnings' do context 'target does not exist' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - ensure => '/tmp/concat/file1', + target => '#{basedir}/file', + ensure => '#{basedir}/file1', } EOS w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } end describe 'the fragment can be changed from a symlink to a plain file' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new content', } EOS @@ -153,7 +156,7 @@ describe 'deprecation warnings' do apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new content' } end @@ -164,9 +167,9 @@ describe 'deprecation warnings' do context 'concat::fragment mode parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', mode => 'bar', } @@ -178,9 +181,9 @@ describe 'deprecation warnings' do context 'concat::fragment owner parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', owner => 'bar', } @@ -192,9 +195,9 @@ describe 'deprecation warnings' do context 'concat::fragment group parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', group => 'bar', } @@ -206,9 +209,9 @@ describe 'deprecation warnings' do context 'concat::fragment backup parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', backup => 'bar', } diff --git a/spec/acceptance/fragments_are_always_replaced_spec.rb b/spec/acceptance/fragments_are_always_replaced_spec.rb index 2c999f7..ac714a9 100644 --- a/spec/acceptance/fragments_are_always_replaced_spec.rb +++ b/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -1,25 +1,31 @@ require 'spec_helper_acceptance' describe 'concat::fragment replace' do + basedir = default.tmpdir('concat') + context 'should create fragment files' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace unset run 1', } EOS pp2 = <<-EOS - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace unset run 2', } EOS @@ -31,7 +37,7 @@ describe 'concat::fragment replace' do apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace unset run 1' } it { should contain 'caller has replace unset run 2' } @@ -40,25 +46,29 @@ describe 'concat::fragment replace' do context 'should replace its own fragment files when caller has File { replace=>true } set' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS File { replace=>true } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace true set run 1', } EOS pp2 = <<-EOS File { replace=>true } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace true set run 2', } EOS @@ -70,7 +80,7 @@ describe 'concat::fragment replace' do apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace true set run 1' } it { should contain 'caller has replace true set run 2' } @@ -79,25 +89,29 @@ describe 'concat::fragment replace' do context 'should replace its own fragment files even when caller has File { replace=>false } set' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS File { replace=>false } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace false set run 1', } EOS pp2 = <<-EOS File { replace=>false } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace false set run 2', } EOS @@ -109,7 +123,7 @@ describe 'concat::fragment replace' do apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace false set run 1' } it { should contain 'caller has replace false set run 2' } diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index 0b6695d..028901a 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -1,21 +1,30 @@ require 'spec_helper_acceptance' describe 'quoted paths' do + basedir = default.tmpdir('concat') + before(:all) do - shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat') - shell('mkdir -p "/tmp/concat test"') + 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 { '/tmp/concat test/foo': + concat { '#{basedir}/concat test/foo': } concat::fragment { '1': - target => '/tmp/concat test/foo', + target => '#{basedir}/concat test/foo', content => 'string1', } concat::fragment { '2': - target => '/tmp/concat test/foo', + target => '#{basedir}/concat test/foo', content => 'string2', } EOS @@ -25,7 +34,7 @@ describe 'quoted paths' do apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat test/foo') do + describe file("#{basedir}/concat test/foo") do it { should be_file } it { should contain "string1\nsring2" } end From 0cb0b1ab0b27d6bd7cad0fe861fff7f75db142b5 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 11 Sep 2014 12:46:42 -0400 Subject: [PATCH 166/202] Work-around. --- spec/spec_helper_acceptance.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 363f4d0..48306ee 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -24,7 +24,11 @@ RSpec.configure do |c| c.before :suite do # Install module and dependencies hosts.each do |host| - copy_module_to(host, :source => proj_root, :module_name => 'concat') + on host, "mkdir -p #{host['distmoduledir']}/concat" + %w(files lib manifests metadata.json).each do |file| + scp_to host, "#{proj_root}/#{file}", "#{host['distmoduledir']}/concat" + end + #copy_module_to(host, :source => proj_root, :module_name => 'concat') on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } end end From d45f1e60d7cc57dabee146cae64e238aae21a6ca Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 11 Sep 2014 13:56:55 -0400 Subject: [PATCH 167/202] Windows and solaris fixes Solaris doesn't support multi-line grep. More fixes for install on windows. --- spec/acceptance/concat_spec.rb | 2 +- spec/acceptance/newline_spec.rb | 4 +++- spec/acceptance/quoted_paths_spec.rb | 4 +++- spec/spec_helper_acceptance.rb | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 2b4fc91..e93ce10 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -13,7 +13,7 @@ when 'windows' username = 'Administrator' groupname = 'Administrators' scriptname = 'concatfragments.rb' -when 'solaris' +when 'Solaris' username = 'root' groupname = 'root' scriptname = 'concatfragments.rb' diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 5554962..d182f2a 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -59,7 +59,9 @@ describe 'concat ensure_newline parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should contain "1\n2\n" } + it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) { + should contain "1\n2\n" + } end end end diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index 028901a..165c153 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -36,7 +36,9 @@ describe 'quoted paths' do describe file("#{basedir}/concat test/foo") do it { should be_file } - it { should contain "string1\nsring2" } + it("should contain string1\nstring2", :unless => (fact('osfamily') == 'Solaris')) { + should contain "string1\nstring2" + } end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 48306ee..b34a188 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -25,8 +25,11 @@ RSpec.configure do |c| # Install module and dependencies hosts.each do |host| on host, "mkdir -p #{host['distmoduledir']}/concat" + result = on host, "echo #{host['distmoduledir']}/concat" + target = result.raw_output.chomp + %w(files lib manifests metadata.json).each do |file| - scp_to host, "#{proj_root}/#{file}", "#{host['distmoduledir']}/concat" + scp_to host, "#{proj_root}/#{file}", target end #copy_module_to(host, :source => proj_root, :module_name => 'concat') on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } From 6f86a98066eab35f5e3162232fd8fe233309379f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 11 Sep 2014 15:41:41 -0400 Subject: [PATCH 168/202] Windows fixes --- spec/acceptance/concat_spec.rb | 26 ++++++++++++-------- spec/acceptance/deprecation_warnings_spec.rb | 4 +-- spec/acceptance/replace_spec.rb | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index e93ce10..10f72d9 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -5,27 +5,33 @@ when 'AIX' username = 'root' groupname = 'system' scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] when 'Darwin' username = 'root' groupname = 'wheel' scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] when 'windows' username = 'Administrator' groupname = 'Administrators' scriptname = 'concatfragments.rb' + result = on default, "echo #{default['puppetvardir']}" + vardir = result.raw_output.chomp when 'Solaris' username = 'root' groupname = 'root' scriptname = 'concatfragments.rb' + vardir = default['puppetvardir'] else username = 'root' groupname = 'root' scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] end describe 'basic concat test' do basedir = default.tmpdir('concat') - safe_basedir = basedir.gsub('/','_') + safe_basedir = basedir.gsub(/[\/:]/,'_') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do @@ -33,49 +39,49 @@ describe 'basic concat test' do apply_manifest(pp, :catch_changes => true) end - describe file("#{default['puppetvardir']}/concat") do + describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin") do + describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin/#{scriptname}") do + describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file") do + describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat.out") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { @@ -125,14 +131,14 @@ describe 'basic concat test' do it { should contain '1' } it { should contain '2' } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/01_1") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/02_2") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index 93ad411..7b0f5c5 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -104,7 +104,7 @@ describe 'deprecation warnings' do it { should contain 'file1 contents' } end - describe 'the fragment can be changed from a symlink to a plain file' do + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do pp = <<-EOS concat { '#{basedir}/file': } concat::fragment { 'foo': @@ -142,7 +142,7 @@ describe 'deprecation warnings' do it { should be_file } end - describe 'the fragment can be changed from a symlink to a plain file' do + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact('osfamily') == 'windows') do pp = <<-EOS concat { '#{basedir}/file': } concat::fragment { 'foo': diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index c200cb2..cc30d12 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -86,7 +86,7 @@ describe 'replacement of' do end end # file - context 'symlink' do + context 'symlink', :unless => (fact("osfamily") == "windows") do context 'should not succeed' do # XXX the core puppet file type will replace a symlink with a plain file # when using ensure => present and source => ... but it will not when using From ed6efe8972c7d7f2d592a012ac9e9bad57d7513e Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Thu, 18 Sep 2014 21:00:05 +1000 Subject: [PATCH 169/202] Reset poisoned defaults from Exec --- manifests/init.pp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 77f9d5f..b021e14 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -140,6 +140,12 @@ define concat( backup => false, } + # reset poisoned Exec defaults + Exec { + user => undef, + group => undef, + } + if $ensure == 'present' { file { $fragdir: ensure => directory, From a8c563f1494199c796b515060852e4abe88d6322 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Mon, 22 Sep 2014 00:57:50 -0400 Subject: [PATCH 170/202] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f889866..54367be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This is a bugfix release, and the first supported release of the 1.1.x series. - Make the `$order` parameter default to a string and be validated as an integer or a string - Use the ruby script on Solaris to not break Sol10 support -- Add quotes to the ryby script location for Windows +- Add quotes to the ruby script location for Windows - Fix typos in README.md - Make regex in concat::setup case-insensitive to make it work on Windows - Make sure concat fragments are always replaced From bc727a7a620b1885391d674d6ffbf96df7231a9e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 3 Oct 2014 15:01:20 -0400 Subject: [PATCH 171/202] Don't test mode and symlinks on windows --- spec/acceptance/concat_spec.rb | 22 ++++++++++---------- spec/acceptance/deprecation_warnings_spec.rb | 5 ++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 10f72d9..d9d835e 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -42,49 +42,49 @@ describe 'basic concat test' do describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end @@ -125,7 +125,7 @@ describe 'basic concat test' do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 644 } it { should contain '1' } @@ -134,14 +134,14 @@ describe 'basic concat test' do describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end @@ -174,7 +174,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 644 } it { should contain '1' } diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index 7b0f5c5..dc2f234 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -73,10 +73,9 @@ describe 'deprecation warnings' do end end - context 'concat::fragment ensure parameter' do + context 'concat::fragment ensure parameter', :unless => fact('osfamily') == 'windows' do context 'target file exists' do before(:all) do - shell("/bin/echo 'file1 contents' > #{basedir}/file1") pp = <<-EOS file { '#{basedir}': ensure => directory, @@ -126,7 +125,7 @@ describe 'deprecation warnings' do end end # target file exists - context 'target does not exist' do + context 'target does not exist', :unless => fact('osfamily') == 'windows' do pp = <<-EOS concat { '#{basedir}/file': } concat::fragment { 'foo': From 006eccc9bc1b3feaff19db82b10f0b694e7b3a55 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 3 Oct 2014 15:22:37 -0400 Subject: [PATCH 172/202] Typo fixes --- spec/acceptance/concat_spec.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index d9d835e..70b1a6d 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -42,49 +42,49 @@ describe 'basic concat test' do describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end @@ -125,7 +125,7 @@ describe 'basic concat test' do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } it { should contain '1' } @@ -134,14 +134,14 @@ describe 'basic concat test' do describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end @@ -174,7 +174,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } it { should contain '1' } From 9ece566992cbd964d9532401bf50bc5a2b7cba82 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 7 Oct 2014 15:19:22 -0400 Subject: [PATCH 173/202] This *should* make tests pass on windows --- spec/acceptance/concat_spec.rb | 2 +- spec/acceptance/replace_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 70b1a6d..7cec1a5 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -124,7 +124,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } + it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index cc30d12..6882345 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -126,7 +126,7 @@ describe 'replacement of' do end # XXX specinfra doesn't support be_linked_to on AIX - describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX") do + describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do it { should be_linked_to "#{basedir}/dangling" } end From ddab08f9d1dc860f6d29575d62bfaa4060324038 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 8 Oct 2014 13:59:14 -0400 Subject: [PATCH 174/202] Update sles metadata --- metadata.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 51f42f9..5a48a8f 100644 --- a/metadata.json +++ b/metadata.json @@ -43,7 +43,9 @@ { "operatingsystem": "SLES", "operatingsystemrelease": [ - "11 SP1" + "10 SP4", + "11 SP1", + "12" ] }, { From 0138787610dba57057e09e20916de3fce7d547f8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 8 Oct 2014 18:06:15 -0400 Subject: [PATCH 175/202] Strict variables test updates --- spec/unit/classes/concat_setup_spec.rb | 23 +++++++++++----- spec/unit/defines/concat_fragment_spec.rb | 33 ++++++++++++++++++++--- spec/unit/defines/concat_spec.rb | 10 ++++++- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 3096e73..b25428e 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -5,7 +5,14 @@ describe 'concat::setup', :type => :class do shared_examples 'setup' do |concatdir| concatdir = '/foo' if concatdir.nil? - let(:facts) {{ :concat_basedir => concatdir }} + let(:facts) do + { + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'Debian', + :id => 'root', + } + end it do should contain_file("#{concatdir}/bin/concatfragments.sh").with({ @@ -44,9 +51,10 @@ describe 'concat::setup', :type => :class do concatdir = '/foo' let(:facts) do { - :concat_basedir => concatdir, - :osfamily => 'Solaris', - :id => 'root', + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'Solaris', + :id => 'root', } end @@ -65,9 +73,10 @@ describe 'concat::setup', :type => :class do concatdir = '/foo' let(:facts) do { - :concat_basedir => concatdir, - :osfamily => 'windows', - :id => 'batman', + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'windows', + :id => 'batman', } end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 3c61aab..64ae7db 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -24,7 +24,14 @@ describe 'concat::fragment', :type => :define do end let(:title) { title } - let(:facts) {{ :concat_basedir => concatdir, :id => id }} + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + :osfamily => 'Debian', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end let(:params) { params } let(:pre_condition) do "concat{ '#{p[:target]}': }" @@ -162,7 +169,13 @@ describe 'concat::fragment', :type => :define do context 'ensure => target and source' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', @@ -178,7 +191,13 @@ describe 'concat::fragment', :type => :define do context 'ensure => target and content' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', @@ -194,7 +213,13 @@ describe 'concat::fragment', :type => :define do context 'source and content' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index e7be4d5..7682cdf 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -33,7 +33,15 @@ describe 'concat', :type => :define do let(:title) { title } let(:params) { params } - let(:facts) {{ :concat_basedir => concatdir, :id => id }} + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + :osfamily => 'Debian', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :kernel => 'Linux', + } + end if p[:ensure] == 'present' it do From 624ae75baabff2a0e4749cfda095671505ac4698 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 24 Oct 2014 14:09:31 -0500 Subject: [PATCH 176/202] Install certs on windows This should allow the install of stdlib to succeed. --- spec/spec_helper_acceptance.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b34a188..713466e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -24,6 +24,10 @@ RSpec.configure do |c| c.before :suite do # Install module and dependencies hosts.each do |host| + if fact_on(host, 'osfamily') == 'windows' + on host, 'powershell.exe -command "(New-Object System.Net.Webclient).DownloadString(\'https://forge.puppetlabs.com\')"' + end + on host, "mkdir -p #{host['distmoduledir']}/concat" result = on host, "echo #{host['distmoduledir']}/concat" target = result.raw_output.chomp From ea3d6e3146a356febb36cb5cb99f7619d49fb3f4 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 24 Oct 2014 17:16:32 -0500 Subject: [PATCH 177/202] 1.1.2 prep --- CHANGELOG.md | 13 +++++++++++++ metadata.json | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54367be..ec4652b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +##2014-10-28 - Supported Release 1.1.2 + +###Summary + +This release includes bugfixes and test improvements. The module was tested against SLES10 and SLES12 and found to work against those platforms with no module improvements. Metadata was updated to include those as supported platforms. + +####Bugfixes +- newline didn't work for Windows and Solaris. This has been fixed. +- Install certs on Windows for acceptance tests +- Update tests to work with strict variables (no module updates were required) +- Update tests to work on Windows +- Fix typo in CHANGELOG.md + ##2014-09-10 - Supported Release 1.1.1 ###Summary diff --git a/metadata.json b/metadata.json index 5a48a8f..62501ab 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,12 @@ { "name": "puppetlabs-concat", - "version": "1.1.1", + "version": "1.1.2", "author": "Puppet Labs", "summary": "Concat module", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-concat", "project_page": "https://github.com/puppetlabs/puppetlabs-concat", - "issues_url": "https://github.com/puppetlabs/puppetlabs-concat/issues", + "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "operatingsystem_support": [ { "operatingsystem": "RedHat", From 8cb4c2447a3fa424cfb1f18b84604fe725360c13 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Mon, 27 Oct 2014 15:59:47 -0700 Subject: [PATCH 178/202] Use apply manifest instead of timeout transaction if it does hang --- spec/spec_helper_acceptance.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 713466e..1a44ad8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -4,9 +4,13 @@ require 'beaker-rspec/helpers/serverspec' 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' } + foss_opts = {:default_action => 'gem_install'} - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end + if default.is_pe?; then + install_pe; + else + install_puppet(foss_opts); + end hosts.each do |host| on hosts, "mkdir -p #{host['distmoduledir']}" @@ -25,7 +29,13 @@ RSpec.configure do |c| # Install module and dependencies hosts.each do |host| if fact_on(host, 'osfamily') == 'windows' - on host, 'powershell.exe -command "(New-Object System.Net.Webclient).DownloadString(\'https://forge.puppetlabs.com\')"' + pp = < ['C:\Windows\System32\WindowsPowershell\v1.0','C:\Windows\Sysnative\WindowsPowershell\v1.0'], + command => 'powershell.exe -command "(New-Object System.Net.Webclient).DownloadString(\"https://forge.puppetlabs.com\")"', + } +EOS + apply_manifest_on(host, pp) end on host, "mkdir -p #{host['distmoduledir']}/concat" @@ -36,7 +46,7 @@ RSpec.configure do |c| scp_to host, "#{proj_root}/#{file}", target end #copy_module_to(host, :source => proj_root, :module_name => 'concat') - on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} end end From 561935586de2d38d7b5a94f44b6986429c0725a9 Mon Sep 17 00:00:00 2001 From: "Joshua M. Keyes" Date: Wed, 12 Nov 2014 18:54:22 -0800 Subject: [PATCH 179/202] Support running a validation command on the destination file. --- README.md | 7 +++++++ manifests/init.pp | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2ed9024..d3e2860 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,13 @@ Ensure there's a newline at the end of the fragments. - ensure_newline => true - ensure_newline => false +#####`validate_cmd` +Ensure the destination file passes the following validation command. + +######Example +- validate_cmd => '/usr/sbin/apache2 -t -f %' +- validate_cmd => '/usr/sbin/visudo -c -f %' + ####concat::fragment #####`target` diff --git a/manifests/init.pp b/manifests/init.pp index b021e14..d0caf25 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -64,6 +64,7 @@ define concat( $replace = true, $order = 'alpha', $ensure_newline = false, + $validate_cmd = undef, $gnu = undef ) { validate_re($ensure, '^present$|^absent$') @@ -173,15 +174,16 @@ define concat( } file { $name: - ensure => present, - owner => $owner, - group => $group, - mode => $mode, - replace => $replace, - path => $path, - alias => "concat_${name}", - source => "${fragdir}/${concat_name}", - backup => $backup, + ensure => present, + owner => $owner, + group => $group, + mode => $mode, + replace => $replace, + path => $path, + alias => "concat_${name}", + source => "${fragdir}/${concat_name}", + validate_cmd => $validate_cmd, + backup => $backup, } # remove extra whitespace from string interpolation to make testing easier From c79d81a8fe47a02ffcc1f2b04859ec9988ceadc2 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 14 Nov 2014 14:36:21 -0800 Subject: [PATCH 180/202] Work around cert issues on solaris and windows This should allow the tests to work. --- spec/spec_helper_acceptance.rb | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 1a44ad8..147b4b4 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -14,6 +14,23 @@ 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_stdlib = <<-EOS + package{'wget':} + exec{'download': + command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz --no-check-certificate", + path => ['/opt/csw/bin/','/usr/bin/'] + } + EOS + apply_manifest_on(host, get_stdlib) + # have to use force otherwise it checks ssl cert even though it is a local file + on host, puppet('module install /root/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} + elsif host['platform'] =~ /windows/i + on host, shell('curl -k -o c:/cygwin64/home/Administrator/puppetlabs-stdlib-4.3.2.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz') + on host, puppet('module install c:/cygwin64/home/Administrator/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies') + else + on host, puppet('module install puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} + end end end @@ -26,27 +43,8 @@ RSpec.configure do |c| # Configure all nodes in nodeset c.before :suite do - # Install module and dependencies hosts.each do |host| - if fact_on(host, 'osfamily') == 'windows' - pp = < ['C:\Windows\System32\WindowsPowershell\v1.0','C:\Windows\Sysnative\WindowsPowershell\v1.0'], - command => 'powershell.exe -command "(New-Object System.Net.Webclient).DownloadString(\"https://forge.puppetlabs.com\")"', - } -EOS - apply_manifest_on(host, pp) - end - - on host, "mkdir -p #{host['distmoduledir']}/concat" - result = on host, "echo #{host['distmoduledir']}/concat" - target = result.raw_output.chomp - - %w(files lib manifests metadata.json).each do |file| - scp_to host, "#{proj_root}/#{file}", target - end - #copy_module_to(host, :source => proj_root, :module_name => 'concat') - on host, puppet('module', 'install', 'puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} + copy_module_to(host, :source => proj_root, :module_name => 'concat') end end From 09a01d80875c8572433c75b19612be6ae8fdb742 Mon Sep 17 00:00:00 2001 From: "Joshua M. Keyes" Date: Sat, 15 Nov 2014 16:48:18 -0800 Subject: [PATCH 181/202] Ensure validate_cmd is a string and fail explicitly otherwise. --- manifests/init.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index d0caf25..fd7b3e1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -82,6 +82,9 @@ define concat( validate_bool($replace) validate_re($order, '^alpha$|^numeric$') validate_bool($ensure_newline) + if $validate_cmd and ! is_string($validate_cmd) { + fail('$validate_cmd must be a string') + } if $gnu { warning('The $gnu parameter to concat is deprecated and has no effect') } From 79c5e45a24a104eecc66149b5e15f9d52ade29bb Mon Sep 17 00:00:00 2001 From: "Joshua M. Keyes" Date: Sat, 15 Nov 2014 16:49:00 -0800 Subject: [PATCH 182/202] Add unit tests for validate_cmd parameter. --- spec/unit/defines/concat_spec.rb | 36 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 7682cdf..3ace38c 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -19,6 +19,7 @@ describe 'concat', :type => :define do :replace => true, :order => 'alpha', :ensure_newline => false, + :validate_cmd => nil, }.merge(params) safe_name = title.gsub('/', '_') @@ -76,15 +77,16 @@ describe 'concat', :type => :define do it do should contain_file(title).with(file_defaults.merge({ - :ensure => 'present', - :owner => p[:owner], - :group => p[:group], - :mode => p[:mode], - :replace => p[:replace], - :path => p[:path], - :alias => "concat_#{title}", - :source => "#{fragdir}/#{concat_name}", - :backup => p[:backup], + :ensure => 'present', + :owner => p[:owner], + :group => p[:group], + :mode => p[:mode], + :replace => p[:replace], + :path => p[:path], + :alias => "concat_#{title}", + :source => "#{fragdir}/#{concat_name}", + :validate_cmd => p[:validate_cmd], + :backup => p[:backup], })) end @@ -380,6 +382,22 @@ describe 'concat', :type => :define do end 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 %' } + end + + [ 1234, true ].each do |cmd| + context cmd do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :validate_cmd => cmd }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/) + end + end + end + end # validate_cmd => + describe 'deprecated parameter' do context 'gnu =>' do context 'foo' do From 0133d3ac4908bfcf1c5073bfee07b3d9e162522d Mon Sep 17 00:00:00 2001 From: "Joshua M. Keyes" Date: Sat, 15 Nov 2014 16:50:15 -0800 Subject: [PATCH 183/202] Add acceptance test for validate_cmd parameter. --- spec/acceptance/validation_spec.rb | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/acceptance/validation_spec.rb diff --git a/spec/acceptance/validation_spec.rb b/spec/acceptance/validation_spec.rb new file mode 100644 index 0000000..08241d6 --- /dev/null +++ b/spec/acceptance/validation_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper_acceptance' + +describe 'concat validate_cmd parameter' do + basedir = default.tmpdir('concat') + context '=> "/usr/bin/test -e %"' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory + } + EOS + + apply_manifest(pp) + end + pp = <<-EOS + concat { '#{basedir}/file': + validate_cmd => '/usr/bin/test -e %', + } + concat::fragment { 'content': + target => '#{basedir}/file', + content => 'content', + } + 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}/file") do + it { should be_file } + it { should contain 'content' } + end + end +end From dc9f4b3f6f46728bfcd7256bec5ab7aa93126feb Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 14 Nov 2014 16:12:09 -0800 Subject: [PATCH 184/202] Use a path that works on both 32 and 64-bit windows --- spec/spec_helper_acceptance.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 147b4b4..aef9f39 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -26,8 +26,8 @@ unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' # have to use force otherwise it checks ssl cert even though it is a local file on host, puppet('module install /root/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} elsif host['platform'] =~ /windows/i - on host, shell('curl -k -o c:/cygwin64/home/Administrator/puppetlabs-stdlib-4.3.2.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz') - on host, puppet('module install c:/cygwin64/home/Administrator/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies') + on host, shell('curl -k -o c:/puppetlabs-stdlib-4.3.2.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz') + on host, puppet('module install c:/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} else on host, puppet('module install puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} end From 4fc1dfc46210a3623aba931f5fd746edb5036280 Mon Sep 17 00:00:00 2001 From: Toni Schmidbauer Date: Tue, 18 Nov 2014 13:55:53 +0100 Subject: [PATCH 185/202] use concatfragments.rb on AIX AIX find does not support the print0 option. It's basically the same as on Solaris: Debug: Executing '/var/lib/puppet/concat/bin/concatfragments.sh -o "/var/lib/puppet/concat/_var_ossec_etc_ossec-agent.conf/fragments.concat.out" -d "/var/lib/puppet/concat/_var_ossec_etc_ossec-agent.conf" -t' Debug: /Stage[main]/Ossec::Client/Concat[/var/ossec/etc/ossec-agent.conf]/Exec[concat_/var/ossec/etc/ossec-agent.conf]/unless: find: bad option -print0 --- manifests/setup.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/setup.pp b/manifests/setup.pp index 1a6af64..f04f2d7 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -31,8 +31,8 @@ class concat::setup { # this goes smoothly, we should move towards completely eliminating the .sh # version. $script_name = $::osfamily? { - /(?i:(Windows|Solaris))/ => 'concatfragments.rb', - default => 'concatfragments.sh' + /(?i:(Windows|Solaris|AIX))/ => 'concatfragments.rb', + default => 'concatfragments.sh' } $script_path = "${concatdir}/bin/${script_name}" From 027484da3a243f9f2db3011616f560879604cf01 Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Thu, 20 Nov 2014 15:20:31 -0800 Subject: [PATCH 186/202] Add metadata summary per FM-1523 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 62501ab..07c8f12 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "name": "puppetlabs-concat", "version": "1.1.2", "author": "Puppet Labs", - "summary": "Concat module", + "summary": "Construct files from multiple fragments.", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-concat", "project_page": "https://github.com/puppetlabs/puppetlabs-concat", From 6f1e97a916eae69f52375187774c4a2c49a62ffe Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Sun, 7 Dec 2014 13:27:57 -0800 Subject: [PATCH 187/202] Define travis matrix in .sync.yml Since the other modules need to wait for a major release before deprecating Puppet 2.7 support, this module's travis.yml is out of sync and will need to stay that way for a while. --- .sync.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.sync.yml b/.sync.yml index ed97d53..08e91a7 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1 +1,9 @@ --- +.travis.yml: + includes: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" From 440a6b7be36cb052d9093aa3c1f7b1d3b1d8041d Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 10:23:21 -0800 Subject: [PATCH 188/202] Update .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md --- .travis.yml | 2 +- CONTRIBUTING.md | 22 ++++--------------- Gemfile | 14 +++++++----- Rakefile | 2 +- .../nodesets/ubuntu-server-10044-x64.yml | 2 +- .../nodesets/ubuntu-server-12042-x64.yml | 2 +- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66e90e3..ec6f08d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: ruby -bundler_args: --without development +bundler_args: --without system_tests script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e128847..f1cbde4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,11 +41,9 @@ Checklist (and a short version for the impatient) * Pre-requisites: - - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) - - Make sure you have a [GitHub account](https://github.com/join) - - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. * Preferred method: @@ -94,17 +92,7 @@ The long version whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. - 2. Sign the Contributor License Agreement - - Before we can accept your changes, we do need a signed Puppet - Labs Contributor License Agreement (CLA). - - You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) - - If you have any questions about the CLA, please feel free to - contact Puppet Labs via email at cla-submissions@puppetlabs.com. - - 3. Sending your patches + 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of @@ -124,7 +112,7 @@ The long version in order to open a pull request. - 4. Update the related GitHub issue. + 3. Update the related GitHub issue. If there is a GitHub issue associated with the change you submitted, then you should update the ticket to include the @@ -220,14 +208,12 @@ review. Additional Resources ==================== -* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) +* [Getting additional help](http://puppetlabs.com/community/get-help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Patchwork](https://patchwork.puppetlabs.com) -* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) - * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) diff --git a/Gemfile b/Gemfile index 081b1a2..0684f19 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,17 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do +group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'serverspec', :require => false - gem 'puppet-lint', '0.3.2', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'pry', :require => false + gem 'puppet-lint', :require => false gem 'simplecov', :require => false + gem 'puppet_facts', :require => false +end + +group :system_tests do + gem 'beaker-rspec', :require => false + gem 'serverspec', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 5868545..e3be95b 100644 --- a/Rakefile +++ b/Rakefile @@ -2,9 +2,9 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_class_parameter_defaults') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml index 5047017..5ca1514 100644 --- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml index 1c7a34c..d065b30 100644 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -7,4 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - type: git + type: foss From ee87c656418d24e088627105feac774296cda903 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 22:52:10 -0800 Subject: [PATCH 189/202] Add json gem The puppet_facts gem implicitly depends on the json gem. On Ruby 1.8.7, json is not built in. On Puppet 2.7, it is not explicitly pulled in by the hiera gem. So we add it here explicitly. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 0684f19..12fd363 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ group :development, :unit_tests do gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false + gem 'json', :require => false end group :system_tests do From ce90edc4b78b01673f0e82ca7c5314d8f0677e01 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 29 Dec 2014 10:40:57 -0800 Subject: [PATCH 190/202] Add IntelliJ files to the ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b5b7a00..b5db85e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +.idea/ +*.iml From cff25a8b60a49649f53a55c77426c7159801081a Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 9 Jan 2015 16:44:58 -0800 Subject: [PATCH 191/202] Fix pending tests With rspec 3, pending() started inverting the logic so that if a pending tests succeeds then it fails (so you can block on a future change). These tests have no body so will always succeed. Anyway, pending -> skip reverts the logic to the usual. --- spec/unit/classes/concat_setup_spec.rb | 2 +- spec/unit/defines/concat_fragment_spec.rb | 10 +++++----- spec/unit/defines/concat_spec.rb | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index b25428e..3252424 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -43,7 +43,7 @@ describe 'concat::setup', :type => :class do context 'deprecated as a public class' do it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 64ae7db..e6f6e03 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -96,7 +96,7 @@ describe 'concat::fragment', :type => :define do let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end # ensure => @@ -244,7 +244,7 @@ describe 'concat::fragment', :type => :define do } it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end # mode => @@ -257,7 +257,7 @@ describe 'concat::fragment', :type => :define do } it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end # owner => @@ -270,7 +270,7 @@ describe 'concat::fragment', :type => :define do } it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end # group => @@ -283,7 +283,7 @@ describe 'concat::fragment', :type => :define do } it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end # backup => diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 7682cdf..2da8330 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -279,7 +279,7 @@ describe 'concat', :type => :define do it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end @@ -386,7 +386,7 @@ describe 'concat', :type => :define do it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'} it 'should create a warning' do - pending('rspec-puppet support for testing warning()') + skip('rspec-puppet support for testing warning()') end end end From 7d49b5f4f8b07a1eabe62948da99ef7104ea383b Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Wed, 14 Jan 2015 13:01:14 -0800 Subject: [PATCH 192/202] Beaker-Rspec broken on Windows, enable ability to pin to older version until fixed --- Gemfile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 12fd363..6bfe6bf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,15 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place, fake_version = nil) + if place =~ /^(git:[^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false @@ -10,19 +20,24 @@ group :development, :unit_tests do gem 'json', :require => false end +beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] group :system_tests do - gem 'beaker-rspec', :require => false + if beaker_rspec_version + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end gem 'serverspec', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false + gem 'facter', *location_for(facterversion) else gem 'facter', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false + gem 'puppet', *location_for(puppetversion) else gem 'puppet', :require => false end From aacf1bd5e14972d0645961354bb80a727bdc3abe Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 4 Feb 2015 17:02:03 +0100 Subject: [PATCH 193/202] Pin rspec gems --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 12fd363..62c5693 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,8 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', :require => false + gem 'rspec-core', '3.1.7', :require => false + gem 'rspec-puppet', '~> 1.0', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'simplecov', :require => false From 3b2e37ab1ea236f4be82b439f19aead2e8ffb8b7 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 14 Nov 2014 15:53:36 -0800 Subject: [PATCH 194/202] MODULES-1456 - make sure ruby is in path on PE Ruby is not in the path for all PE installations, so make sure the concat script is run with ruby in the path. --- manifests/init.pp | 13 ++++++++++++- spec/unit/classes/concat_setup_spec.rb | 3 +++ spec/unit/defines/concat_fragment_spec.rb | 14 +++++++++----- spec/unit/defines/concat_spec.rb | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b021e14..5d68489 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -187,6 +187,17 @@ define concat( # remove extra whitespace from string interpolation to make testing easier $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + # make sure ruby is in the path for PE + if $::is_pe { + if $::kernel == 'windows' { + $command_path = "${::env_windows_installdir}/bin:${::path}" + } else { + $command_path = "/opt/puppet/bin:${::path}" + } + } else { + $command_path = $::path + } + # if puppet is running as root, this exec should also run as root to allow # the concatfragments.sh script to potentially be installed in path that # may not be accessible by a target non-root owner. @@ -196,7 +207,7 @@ define concat( notify => File[$name], subscribe => File[$fragdir], unless => "${command} -t", - path => $::path, + path => $command_path, require => [ File[$fragdir], File["${fragdir}/fragments"], diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 3252424..2aac763 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -11,6 +11,7 @@ describe 'concat::setup', :type => :class do :caller_module_name => 'Test', :osfamily => 'Debian', :id => 'root', + :is_pe => false, } end @@ -55,6 +56,7 @@ describe 'concat::setup', :type => :class do :caller_module_name => 'Test', :osfamily => 'Solaris', :id => 'root', + :is_pe => false, } end @@ -77,6 +79,7 @@ describe 'concat::setup', :type => :class do :caller_module_name => 'Test', :osfamily => 'windows', :id => 'batman', + :is_pe => false, } end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index e6f6e03..dde3a7c 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -30,6 +30,7 @@ describe 'concat::fragment', :type => :define do :id => id, :osfamily => 'Debian', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :is_pe => false, } end let(:params) { params } @@ -71,7 +72,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }} let(:params) {{ :target => false }} it 'should fail' do @@ -92,7 +93,7 @@ describe 'concat::fragment', :type => :define do context 'any value other than \'present\' or \'absent\'' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }} let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} it 'should create a warning' do @@ -113,7 +114,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }} let(:params) {{ :content => false, :target => '/etc/motd' }} it 'should fail' do @@ -134,7 +135,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }} let(:params) {{ :source => false, :target => '/etc/motd' }} it 'should fail' do @@ -155,7 +156,7 @@ describe 'concat::fragment', :type => :define do context 'false' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }} let(:params) {{ :order => false, :target => '/etc/motd' }} it 'should fail' do @@ -174,6 +175,7 @@ describe 'concat::fragment', :type => :define do :concat_basedir => '/tmp', :osfamily => 'Debian', :id => 'root', + :is_pe => false, } end let(:params) do @@ -196,6 +198,7 @@ describe 'concat::fragment', :type => :define do :concat_basedir => '/tmp', :osfamily => 'Debian', :id => 'root', + :is_pe => false, } end let(:params) do @@ -218,6 +221,7 @@ describe 'concat::fragment', :type => :define do :concat_basedir => '/tmp', :osfamily => 'Debian', :id => 'root', + :is_pe => false, } end let(:params) do diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 2da8330..e4d8fba 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -40,6 +40,7 @@ describe 'concat', :type => :define do :osfamily => 'Debian', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :kernel => 'Linux', + :is_pe => false, } end From 7bc211ceba390f4a44ae2857b79eb8237fa2e529 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Mon, 9 Feb 2015 14:42:34 -0800 Subject: [PATCH 195/202] MODULES-1764 Fix missing method for check_is_owned_by for windows Fix tests to use its(:content) instead of deprecated should contain --- spec/acceptance/concat_spec.rb | 64 +++++------ spec/acceptance/deprecation_warnings_spec.rb | 24 +++-- spec/acceptance/empty_spec.rb | 2 +- spec/acceptance/fragment_source_spec.rb | 50 +++++---- .../fragments_are_always_replaced_spec.rb | 18 ++-- spec/acceptance/newline_spec.rb | 8 +- spec/acceptance/order_spec.rb | 102 +++++++----------- spec/acceptance/quoted_paths_spec.rb | 4 +- spec/acceptance/replace_spec.rb | 24 +++-- spec/acceptance/specinfra_stubs.rb | 18 ++++ spec/acceptance/symbolic_name_spec.rb | 6 +- spec/acceptance/warn_spec.rb | 16 +-- spec/spec_helper_acceptance.rb | 10 +- 13 files changed, 189 insertions(+), 157 deletions(-) create mode 100644 spec/acceptance/specinfra_stubs.rb diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 7cec1a5..7a6d95c 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,37 +1,37 @@ require 'spec_helper_acceptance' case fact('osfamily') -when 'AIX' - username = 'root' - groupname = 'system' - scriptname = 'concatfragments.sh' - vardir = default['puppetvardir'] -when 'Darwin' - username = 'root' - groupname = 'wheel' - scriptname = 'concatfragments.sh' - vardir = default['puppetvardir'] -when 'windows' - username = 'Administrator' - groupname = 'Administrators' - scriptname = 'concatfragments.rb' - result = on default, "echo #{default['puppetvardir']}" - vardir = result.raw_output.chomp -when 'Solaris' - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.rb' - vardir = default['puppetvardir'] -else - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.sh' - vardir = default['puppetvardir'] + when 'AIX' + username = 'root' + groupname = 'system' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] + when 'Darwin' + username = 'root' + groupname = 'wheel' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] + when 'windows' + username = 'Administrator' + groupname = 'Administrators' + scriptname = 'concatfragments.rb' + result = on default, "echo #{default['puppetvardir']}" + vardir = result.raw_output.chomp + when 'Solaris' + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.rb' + vardir = default['puppetvardir'] + else + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] end describe 'basic concat test' do basedir = default.tmpdir('concat') - safe_basedir = basedir.gsub(/[\/:]/,'_') + safe_basedir = basedir.gsub(/[\/:]/, '_') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do @@ -46,7 +46,7 @@ describe 'basic concat test' do should be_mode 755 } end - describe file("#{vardir}/concat/bin") do + describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { @@ -128,8 +128,10 @@ describe 'basic concat test' do it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should match '1' + should match '2' + } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } @@ -177,7 +179,7 @@ describe 'basic concat test' do it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } - it { should contain '1' } + its(:content) { should match '1' } end end context 'works when set to absent with path set' do diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index dc2f234..11133ea 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' describe 'deprecation warnings' do basedir = default.tmpdir('concat') - shared_examples 'has_warning'do |pp, w| + shared_examples 'has_warning' do |pp, w| it 'applies the manifest twice with a stderr regex' do expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) @@ -43,8 +43,10 @@ describe 'deprecation warnings' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } - it { should contain 'bar' } + its(:content) { + should match '# This file is managed by Puppet. DO NOT EDIT.' + should match 'bar' + } end end end @@ -66,8 +68,10 @@ describe 'deprecation warnings' do describe file("#{basedir}/file") do it { should be_file } - it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } - it { should contain 'bar' } + its(:content) { + should_not match '# This file is managed by Puppet. DO NOT EDIT.' + should match 'bar' + } end end end @@ -100,7 +104,7 @@ describe 'deprecation warnings' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'file1 contents' } + its(:content) { should match 'file1 contents' } end describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do @@ -119,8 +123,10 @@ describe 'deprecation warnings' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new content' } - it { should_not contain 'file1 contents' } + its(:content) { + should match 'new content' + should_not match 'file1 contents' + } end end end # target file exists @@ -157,7 +163,7 @@ describe 'deprecation warnings' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new content' } + its(:content) { should match 'new content' } end end end # target file exists diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index dc57cb7..4ab6e1e 100644 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -17,7 +17,7 @@ describe 'concat force empty parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should_not contain '1\n2' } + its(:content) { should_not match /1\n2/ } end end end diff --git a/spec/acceptance/fragment_source_spec.rb b/spec/acceptance/fragment_source_spec.rb index f3bbfcc..a174e02 100644 --- a/spec/acceptance/fragment_source_spec.rb +++ b/spec/acceptance/fragment_source_spec.rb @@ -1,18 +1,18 @@ require 'spec_helper_acceptance' case fact('osfamily') -when 'AIX' - username = 'root' - groupname = 'system' -when 'Darwin' - username = 'root' - groupname = 'wheel' -when 'windows' - username = 'Administrator' - groupname = 'Administrators' -else - username = 'root' - groupname = 'root' + when 'AIX' + username = 'root' + groupname = 'system' + when 'Darwin' + username = 'root' + groupname = 'wheel' + when 'windows' + username = 'Administrator' + groupname = 'Administrators' + else + username = 'root' + groupname = 'root' end describe 'concat::fragment source' do @@ -50,9 +50,11 @@ describe 'concat::fragment source' do describe file("#{basedir}/foo") do it { should be_file } - it { should contain 'file1 contents' } - it { should contain 'string1 contents' } - it { should contain 'file2 contents' } + its(:content) { + should match 'file1 contents' + should match 'string1 contents' + should match 'file2 contents' + } end end # should read file fragments from local system @@ -106,18 +108,24 @@ describe 'concat::fragment source' do end describe file("#{basedir}/result_file1") do it { should be_file } - it { should contain 'file1 contents' } - it { should_not contain 'file2 contents' } + its(:content) { + should match 'file1 contents' + should_not match 'file2 contents' + } end describe file("#{basedir}/result_file2") do it { should be_file } - it { should contain 'file2 contents' } - it { should_not contain 'file1 contents' } + its(:content) { + should match 'file2 contents' + should_not match 'file1 contents' + } end describe file("#{basedir}/result_file3") do it { should be_file } - it { should contain 'file1 contents' } - it { should_not contain 'file2 contents' } + its(:content) { + should match 'file1 contents' + should_not match 'file2 contents' + } end end diff --git a/spec/acceptance/fragments_are_always_replaced_spec.rb b/spec/acceptance/fragments_are_always_replaced_spec.rb index ac714a9..70d7382 100644 --- a/spec/acceptance/fragments_are_always_replaced_spec.rb +++ b/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -39,8 +39,10 @@ describe 'concat::fragment replace' do describe file("#{basedir}/foo") do it { should be_file } - it { should_not contain 'caller has replace unset run 1' } - it { should contain 'caller has replace unset run 2' } + its(:content) { + should_not match 'caller has replace unset run 1' + should match 'caller has replace unset run 2' + } end end # should create fragment files @@ -82,8 +84,10 @@ describe 'concat::fragment replace' do describe file("#{basedir}/foo") do it { should be_file } - it { should_not contain 'caller has replace true set run 1' } - it { should contain 'caller has replace true set run 2' } + its(:content) { + should_not match 'caller has replace true set run 1' + should match 'caller has replace true set run 2' + } end end # should replace its own fragment files when caller has File(replace=>true) set @@ -125,8 +129,10 @@ describe 'concat::fragment replace' do describe file("#{basedir}/foo") do it { should be_file } - it { should_not contain 'caller has replace false set run 1' } - it { should contain 'caller has replace false set run 2' } + its(:content) { + should_not match 'caller has replace false set run 1' + should match 'caller has replace false set run 2' + } end end # should replace its own fragment files even when caller has File(replace=>false) set diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index d182f2a..c1fa16a 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -33,7 +33,7 @@ describe 'concat ensure_newline parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '12' } + its(:content) { should match '12' } end end @@ -54,13 +54,13 @@ describe 'concat ensure_newline parameter' do it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } - it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) { - should contain "1\n2\n" + its(:content) { + should match /1\n2\n/ } end end diff --git a/spec/acceptance/order_spec.rb b/spec/acceptance/order_spec.rb index fd7b05b..c158dd8 100644 --- a/spec/acceptance/order_spec.rb +++ b/spec/acceptance/order_spec.rb @@ -3,69 +3,45 @@ require 'spec_helper_acceptance' describe 'concat order' do basedir = default.tmpdir('concat') - context '=> alpha' do - pp = <<-EOS + context '=> ' do + shared_examples 'sortby' do |order_by, match_output| + pp = <<-EOS concat { '#{basedir}/foo': - order => 'alpha' + order => '#{order_by}' } concat::fragment { '1': target => '#{basedir}/foo', content => 'string1', + order => '1', } concat::fragment { '2': target => '#{basedir}/foo', content => 'string2', + order => '2', } concat::fragment { '10': target => '#{basedir}/foo', content => 'string10', } - EOS + EOS - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + 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}/foo") do + it { should be_file } + its(:content) { should match match_output } + end end - describe file("#{basedir}/foo") do - it { should be_file } - #XXX Solaris 10 doesn't support multi-line grep - it("should contain string10\nstring1\nsring2", :unless => (fact('osfamily') == 'Solaris')) { - should contain "string10\nstring1\nsring2" - } - end - end - - context '=> numeric' do - pp = <<-EOS - concat { '#{basedir}/foo': - order => 'numeric' - } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - } - concat::fragment { '10': - target => '#{basedir}/foo', - content => 'string10', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + describe 'alpha' do + it_behaves_like 'sortby', 'alpha', /string10string1string2/ end - describe file("#{basedir}/foo") do - it { should be_file } - #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring10", :unless => (fact('osfamily') == 'Solaris')) { - should contain "string1\nstring2\nsring10" - } + describe 'numeric' do + it_behaves_like 'sortby', 'numeric', /string1string2string10/ end end end # concat order @@ -74,8 +50,11 @@ describe 'concat::fragment order' do basedir = default.tmpdir('concat') context '=> reverse order' do - pp = <<-EOS - concat { '#{basedir}/foo': } + shared_examples 'order_by' do |order_by, match_output| + pp = <<-EOS + concat { '#{basedir}/foo': + order => '#{order_by}' + } concat::fragment { '1': target => '#{basedir}/foo', content => 'string1', @@ -91,19 +70,23 @@ describe 'concat::fragment order' do content => 'string3', order => '1', } - EOS + EOS - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + 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}/foo") do + it { should be_file } + its(:content) { should match match_output } + end end - - describe file("#{basedir}/foo") do - it { should be_file } - #XXX Solaris 10 doesn't support multi-line grep - it("should contain string3\nstring2\nsring1", :unless => (fact('osfamily') == 'Solaris')) { - should contain "string3\nstring2\nsring1" - } + describe 'alpha' do + it_should_behave_like 'order_by', 'alpha', /string2string1string3/ + end + describe 'numeric' do + it_should_behave_like 'order_by', 'numeric', /string3string2string1/ end end @@ -134,10 +117,7 @@ describe 'concat::fragment order' do describe file("#{basedir}/foo") do it { should be_file } - #XXX Solaris 10 doesn't support multi-line grep - it("should contain string1\nstring2\nsring3", :unless => (fact('osfamily') == 'Solaris')) { - should contain "string1\nstring2\nsring3" - } + its(:content) { should match /string1string2string3/ } end end end # concat::fragment order diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index 165c153..042425f 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -36,9 +36,7 @@ describe 'quoted paths' do describe file("#{basedir}/concat test/foo") do it { should be_file } - it("should contain string1\nstring2", :unless => (fact('osfamily') == 'Solaris')) { - should contain "string1\nstring2" - } + its(:content) { should match /string1string2/ } end end end diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index 6882345..bd597ed 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -38,9 +38,11 @@ describe 'replacement of' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'file exists' } - it { should_not contain '1' } - it { should_not contain '2' } + its(:content) { + should match 'file exists' + should_not match '1' + should_not match '2' + } end end @@ -79,9 +81,11 @@ describe 'replacement of' do describe file("#{basedir}/file") do it { should be_file } - it { should_not contain 'file exists' } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should_not match 'file exists' + should match '1' + should match '2' + } end end end # file @@ -177,8 +181,10 @@ describe 'replacement of' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should match '1' + should match '2' + } end end end # symlink @@ -249,7 +255,7 @@ describe 'replacement of' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '1' } + its(:content) { should match '1' } end end end # directory diff --git a/spec/acceptance/specinfra_stubs.rb b/spec/acceptance/specinfra_stubs.rb new file mode 100644 index 0000000..d42e1c0 --- /dev/null +++ b/spec/acceptance/specinfra_stubs.rb @@ -0,0 +1,18 @@ +class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Base + class << self + def check_is_owned_by(file, owner) + Backend::PowerShell::Command.new do + exec "((gci '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0" + end + end + end +end + + +class Specinfra::Command::Base::File < Specinfra::Command::Base + class << self + def get_content(file) + "cat '#{file}' 2> /dev/null || echo -n" + end + end +end diff --git a/spec/acceptance/symbolic_name_spec.rb b/spec/acceptance/symbolic_name_spec.rb index b0dceac..df8d54f 100644 --- a/spec/acceptance/symbolic_name_spec.rb +++ b/spec/acceptance/symbolic_name_spec.rb @@ -27,7 +27,9 @@ describe 'symbolic name' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should match '1' + should match '2' + } end end diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index 2fa529d..7101f61 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -28,9 +28,11 @@ describe 'concat warn =>' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should match '# This file is managed by Puppet. DO NOT EDIT.' + should match '1' + should match '2' + } end end context 'false should not enable default warning message' do @@ -90,9 +92,11 @@ describe 'concat warn =>' do describe file("#{basedir}/file") do it { should be_file } - it { should contain '# foo' } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should match '# foo' + should match '1' + should match '2' + } end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index aef9f39..da994f8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,5 +1,6 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' +require 'acceptance/specinfra_stubs' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' # This will install the latest available package on el and deb based @@ -18,16 +19,16 @@ unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' get_stdlib = <<-EOS package{'wget':} exec{'download': - command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz --no-check-certificate", + command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz --no-check-certificate", path => ['/opt/csw/bin/','/usr/bin/'] } EOS apply_manifest_on(host, get_stdlib) # have to use force otherwise it checks ssl cert even though it is a local file - on host, puppet('module install /root/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} + on host, puppet('module install /root/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} elsif host['platform'] =~ /windows/i - on host, shell('curl -k -o c:/puppetlabs-stdlib-4.3.2.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.3.2.tar.gz') - on host, puppet('module install c:/puppetlabs-stdlib-4.3.2.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} + on host, shell('curl -k -o c:/puppetlabs-stdlib-4.5.1.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz') + on host, puppet('module install c:/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} else on host, puppet('module install puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} end @@ -57,3 +58,4 @@ RSpec.configure do |c| c.treat_symbols_as_metadata_keys_with_true_values = true end + From b9b13d28068b25968a88fa308664540fe73df08f Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 10 Feb 2015 15:49:41 -0800 Subject: [PATCH 196/202] Currently sorting by numeric and the ruby file is not supported, this fixes that --- files/concatfragments.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/files/concatfragments.rb b/files/concatfragments.rb index 904f824..b16f3e1 100644 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -40,13 +40,13 @@ require 'optparse' require 'fileutils' settings = { - :outfile => "", - :workdir => "", - :test => false, - :force => false, - :warn => "", - :sortarg => "", - :newline => false + :outfile => "", + :workdir => "", + :test => false, + :force => false, + :warn => "", + :sortarg => "", + :newline => false } OptionParser.new do |opts| @@ -116,15 +116,18 @@ end Dir.chdir(settings[:workdir]) if settings[:warn].empty? - File.open("fragments.concat", 'w') {|f| f.write("") } + File.open("fragments.concat", 'w') { |f| f.write("") } else - File.open("fragments.concat", 'w') {|f| f.write("#{settings[:warn]}\n") } + File.open("fragments.concat", 'w') { |f| f.write("#{settings[:warn]}\n") } end # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir open('fragments.concat', 'a') do |f| - Dir.entries("fragments").sort.each{ |entry| - + fragments = Dir.entries("fragments").sort + if settings[:sortarg] == '-n' + fragments = fragments.sort_by { |v| v.split('_').map(&:to_i) } + end + fragments.each { |entry| if File.file?(File.join("fragments", entry)) f << File.read(File.join("fragments", entry)) From 520287fd0546f96d58722c014c44bfa42d853e6a Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 10 Feb 2015 22:36:14 -0800 Subject: [PATCH 197/202] Fix Solaris 10 errors in tests and more issues with Windows checks of owner --- spec/acceptance/backup_spec.rb | 8 ++++---- spec/acceptance/specinfra_stubs.rb | 3 ++- spec/acceptance/warn_spec.rb | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/spec/acceptance/backup_spec.rb b/spec/acceptance/backup_spec.rb index 1989f44..1d3a5df 100644 --- a/spec/acceptance/backup_spec.rb +++ b/spec/acceptance/backup_spec.rb @@ -33,7 +33,7 @@ describe 'concat backup parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new contents' } + its(:content) { should match /new contents/ } end end @@ -68,11 +68,11 @@ describe 'concat backup parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new contents' } + its(:content) { should match /new contents/ } end describe file("#{basedir}/file.backup") do it { should be_file } - it { should contain 'old contents' } + its(:content) { should match /old contents/ } end end @@ -109,7 +109,7 @@ describe 'concat backup parameter' do describe file("#{basedir}/file") do it { should be_file } - it { should contain 'new contents' } + its(:content) { should match /new contents/ } end end end diff --git a/spec/acceptance/specinfra_stubs.rb b/spec/acceptance/specinfra_stubs.rb index d42e1c0..bae85ef 100644 --- a/spec/acceptance/specinfra_stubs.rb +++ b/spec/acceptance/specinfra_stubs.rb @@ -2,7 +2,8 @@ class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Bas class << self def check_is_owned_by(file, owner) Backend::PowerShell::Command.new do - exec "((gci '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0" + exec "if((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}' + -or ((Get-Item '#{file}').GetAccessControl().Owner -match '#{owner}').Length -gt 0){ exit 0 } else { exit 1 }" end end end diff --git a/spec/acceptance/warn_spec.rb b/spec/acceptance/warn_spec.rb index 7101f61..2788607 100644 --- a/spec/acceptance/warn_spec.rb +++ b/spec/acceptance/warn_spec.rb @@ -29,9 +29,9 @@ describe 'concat warn =>' do describe file("#{basedir}/file") do it { should be_file } its(:content) { - should match '# This file is managed by Puppet. DO NOT EDIT.' - should match '1' - should match '2' + should match /# This file is managed by Puppet\. DO NOT EDIT\./ + should match /1/ + should match /2/ } end end @@ -61,9 +61,11 @@ describe 'concat warn =>' do describe file("#{basedir}/file") do it { should be_file } - it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } - it { should contain '1' } - it { should contain '2' } + its(:content) { + should_not match /# This file is managed by Puppet\. DO NOT EDIT\./ + should match /1/ + should match /2/ + } end end context '# foo should overide default warning message' do @@ -93,9 +95,9 @@ describe 'concat warn =>' do describe file("#{basedir}/file") do it { should be_file } its(:content) { - should match '# foo' - should match '1' - should match '2' + should match /# foo/ + should match /1/ + should match /2/ } end end From a198e5db14c8f36a919b2f6b7bd7dc3ce2891dbe Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 11 Feb 2015 22:03:00 -0800 Subject: [PATCH 198/202] Fix validate_cmd file resource parameter The validate_cmd parameter is only valid on newer versions of puppet. This module is supporting all 3.x versions of puppet. This commit only applies the validate_cmd parameter to the file resource if it is defined and adds documentation noting that it will not work on older versons of puppet. --- README.md | 1 + manifests/init.pp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3e2860..8225b05 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,7 @@ Ensure there's a newline at the end of the fragments. #####`validate_cmd` Ensure the destination file passes the following validation command. +Only supported on Puppet >= 3.5.0. ######Example - validate_cmd => '/usr/sbin/apache2 -t -f %' diff --git a/manifests/init.pp b/manifests/init.pp index 9ac3fe5..1727bec 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -185,10 +185,16 @@ define concat( path => $path, alias => "concat_${name}", source => "${fragdir}/${concat_name}", - validate_cmd => $validate_cmd, backup => $backup, } + # Only newer versions of puppet 3.x support the validate_cmd parameter + if $validate_cmd { + File[$name] { + validate_cmd => $validate_cmd, + } + } + # remove extra whitespace from string interpolation to make testing easier $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) From 36ff0ea613371262551b09a9236a7e30d3d21e41 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 12 Feb 2015 16:05:33 -0800 Subject: [PATCH 199/202] The validation acceptance test is very Linux specific --- spec/acceptance/validation_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/validation_spec.rb b/spec/acceptance/validation_spec.rb index 08241d6..c35871b 100644 --- a/spec/acceptance/validation_spec.rb +++ b/spec/acceptance/validation_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'concat validate_cmd parameter' do +describe 'concat validate_cmd parameter', :unless => (fact('kernel') != 'Linux') do basedir = default.tmpdir('concat') context '=> "/usr/bin/test -e %"' do before(:all) do From 7eb14b776838039ac923e8ff8e56871a3b35df1a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 13 Feb 2015 13:13:16 -0800 Subject: [PATCH 200/202] Remove shell script The ruby script works just as well and works on all supported platforms. No need to maintain both. --- files/concatfragments.sh | 140 ------------------------- manifests/init.pp | 4 +- manifests/setup.pp | 10 +- spec/acceptance/concat_spec.rb | 6 +- spec/unit/classes/concat_setup_spec.rb | 4 +- spec/unit/defines/concat_spec.rb | 2 +- 6 files changed, 9 insertions(+), 157 deletions(-) delete mode 100755 files/concatfragments.sh diff --git a/files/concatfragments.sh b/files/concatfragments.sh deleted file mode 100755 index 7e6b0f5..0000000 --- a/files/concatfragments.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh - -# Script to concat files to a config file. -# -# Given a directory like this: -# /path/to/conf.d -# |-- fragments -# | |-- 00_named.conf -# | |-- 10_domain.net -# | `-- zz_footer -# -# The script supports a test option that will build the concat file to a temp location and -# use /usr/bin/cmp to verify if it should be run or not. This would result in the concat happening -# twice on each run but gives you the option to have an unless option in your execs to inhibit rebuilds. -# -# Without the test option and the unless combo your services that depend on the final file would end up -# restarting on each run, or in other manifest models some changes might get missed. -# -# OPTIONS: -# -o The file to create from the sources -# -d The directory where the fragments are kept -# -t Test to find out if a build is needed, basically concats the files to a temp -# location and compare with what's in the final location, return codes are designed -# for use with unless on an exec resource -# -w Add a shell style comment at the top of the created file to warn users that it -# is generated by puppet -# -f Enables the creation of empty output files when no fragments are found -# -n Sort the output numerically rather than the default alpha sort -# -# the command: -# -# concatfragments.sh -o /path/to/conffile.cfg -d /path/to/conf.d -# -# creates /path/to/conf.d/fragments.concat and copies the resulting -# file to /path/to/conffile.cfg. The files will be sorted alphabetically -# pass the -n switch to sort numerically. -# -# The script does error checking on the various dirs and files to make -# sure things don't fail. - -OUTFILE="" -WORKDIR="" -TEST="" -FORCE="" -WARN="" -SORTARG="" -ENSURE_NEWLINE="" - -PATH=/sbin:/usr/sbin:/bin:/usr/bin - -## Well, if there's ever a bad way to do things, Nexenta has it. -## http://nexenta.org/projects/site/wiki/Personalities -unset SUN_PERSONALITY - -while getopts "o:s:d:tnw:fl" options; do - case $options in - o ) OUTFILE=$OPTARG;; - d ) WORKDIR=$OPTARG;; - n ) SORTARG="-n";; - w ) WARNMSG="$OPTARG";; - f ) FORCE="true";; - t ) TEST="true";; - l ) ENSURE_NEWLINE="true";; - * ) echo "Specify output file with -o and fragments directory with -d" - exit 1;; - esac -done - -# do we have -o? -if [ "x${OUTFILE}" = "x" ]; then - echo "Please specify an output file with -o" - exit 1 -fi - -# do we have -d? -if [ "x${WORKDIR}" = "x" ]; then - echo "Please fragments directory with -d" - exit 1 -fi - -# can we write to -o? -if [ -f "${OUTFILE}" ]; then - if [ ! -w "${OUTFILE}" ]; then - echo "Cannot write to ${OUTFILE}" - exit 1 - fi -else - if [ ! -w `dirname "${OUTFILE}"` ]; then - echo "Cannot write to `dirname \"${OUTFILE}\"` to create ${OUTFILE}" - exit 1 - fi -fi - -# do we have a fragments subdir inside the work dir? -if [ ! -d "${WORKDIR}/fragments" ] && [ ! -x "${WORKDIR}/fragments" ]; then - echo "Cannot access the fragments directory" - exit 1 -fi - -# are there actually any fragments? -if [ ! "$(ls -A """${WORKDIR}/fragments""")" ]; then - if [ "x${FORCE}" = "x" ]; then - echo "The fragments directory is empty, cowardly refusing to make empty config files" - exit 1 - fi -fi - -cd "${WORKDIR}" - -if [ "x${WARNMSG}" = "x" ]; then - : > "fragments.concat" -else - printf '%s\n' "$WARNMSG" > "fragments.concat" -fi - -# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir -IFS_BACKUP=$IFS -IFS=' -' -for fragfile in `find fragments/ -type f -follow -print0 | xargs -0 -n1 basename | LC_ALL=C sort ${SORTARG}` -do - cat "fragments/$fragfile" >> "fragments.concat" - # Handle newlines. - if [ "x${ENSURE_NEWLINE}" != "x" ]; then - echo >> "fragments.concat" - fi -done -IFS=$IFS_BACKUP - -if [ "x${TEST}" = "x" ]; then - # This is a real run, copy the file to outfile - cp fragments.concat "${OUTFILE}" - RETVAL=$? -else - # Just compare the result to outfile to help the exec decide - cmp "${OUTFILE}" fragments.concat - RETVAL=$? -fi - -exit $RETVAL diff --git a/manifests/init.pp b/manifests/init.pp index 1727bec..78c4081 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,7 +34,7 @@ # # === Actions: # * Creates fragment directories if it didn't exist already -# * Executes the concatfragments.sh script to build the final file, this +# * Executes the concatfragments.rb script to build the final file, this # script will create directory/fragments.concat. Execution happens only # when: # * The directory changes @@ -210,7 +210,7 @@ define concat( } # if puppet is running as root, this exec should also run as root to allow - # the concatfragments.sh script to potentially be installed in path that + # the concatfragments.rb script to potentially be installed in path that # may not be accessible by a target non-root owner. exec { "concat_${name}": alias => "concat_${fragdir}", diff --git a/manifests/setup.pp b/manifests/setup.pp index f04f2d7..a2da1ed 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -25,15 +25,7 @@ class concat::setup { $fragment_owner = $::osfamily ? { 'windows' => undef, default => $::id } $fragment_mode = $::osfamily ? { 'windows' => undef, default => '0640' } - # PR #174 introduced changes to the concatfragments.sh script that are - # incompatible with Solaris 10 but reportedly OK on Solaris 11. As a work - # around we are enable the .rb concat script on all Solaris versions. If - # this goes smoothly, we should move towards completely eliminating the .sh - # version. - $script_name = $::osfamily? { - /(?i:(Windows|Solaris|AIX))/ => 'concatfragments.rb', - default => 'concatfragments.sh' - } + $script_name = 'concatfragments.rb' $script_path = "${concatdir}/bin/${script_name}" diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 7a6d95c..c5c9727 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -4,12 +4,12 @@ case fact('osfamily') when 'AIX' username = 'root' groupname = 'system' - scriptname = 'concatfragments.sh' + scriptname = 'concatfragments.rb' vardir = default['puppetvardir'] when 'Darwin' username = 'root' groupname = 'wheel' - scriptname = 'concatfragments.sh' + scriptname = 'concatfragments.rb' vardir = default['puppetvardir'] when 'windows' username = 'Administrator' @@ -25,7 +25,7 @@ case fact('osfamily') else username = 'root' groupname = 'root' - scriptname = 'concatfragments.sh' + scriptname = 'concatfragments.rb' vardir = default['puppetvardir'] end diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 2aac763..e97a29c 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -16,9 +16,9 @@ describe 'concat::setup', :type => :class do end it do - should contain_file("#{concatdir}/bin/concatfragments.sh").with({ + should contain_file("#{concatdir}/bin/concatfragments.rb").with({ :mode => '0755', - :source => 'puppet:///modules/concat/concatfragments.sh', + :source => 'puppet:///modules/concat/concatfragments.rb', :backup => false, }) end diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index de12ab9..a748f96 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -91,7 +91,7 @@ describe 'concat', :type => :define do })) end - cmd = "#{concatdir}/bin/concatfragments.sh " + + cmd = "#{concatdir}/bin/concatfragments.rb " + "-o \"#{concatdir}/#{safe_name}/fragments.concat.out\" " + "-d \"#{concatdir}/#{safe_name}\"" From 3173e966979a9ccf0f20ca905e55731f3a5e71f7 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 17 Feb 2015 11:23:22 -0800 Subject: [PATCH 201/202] 1.2.0 prep --- CHANGELOG.md | 21 +++++++++++++++------ metadata.json | 7 ++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec4652b..2043b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ -##2014-10-28 - Supported Release 1.1.2 +##2015-02-17 - Supported Release 1.2.0 +###Summary +This release includes a number of bugfixes and adds support for running a validation command when using puppet >= 3.5.0. + +####Features +- Support running a validation command for Puppet >= 3.5.0 + +####Bugfixes +- Reset poisoned defaults from Exec +- Use concatfragments.rb on AIX since it doesn't support print0 +- Make sure ruby is in the path for PE (MODULES-1456) +- Fix missing method for check_is_owned_by for windows (MODULES-1764) +- Fix sort by numeric + +##2014-10-28 - Supported Release 1.1.2 ###Summary This release includes bugfixes and test improvements. The module was tested against SLES10 and SLES12 and found to work against those platforms with no module improvements. Metadata was updated to include those as supported platforms. @@ -12,7 +26,6 @@ This release includes bugfixes and test improvements. The module was tested agai - Fix typo in CHANGELOG.md ##2014-09-10 - Supported Release 1.1.1 - ###Summary This is a bugfix release, and the first supported release of the 1.1.x series. @@ -32,7 +45,6 @@ This is a bugfix release, and the first supported release of the 1.1.x series. - Synchronized files for more consistency across modules via modulesync ##2014-05-14 - Release 1.1.0 - ###Summary This release is primarily a bugfix release since 1.1.0-rc1. @@ -47,7 +59,6 @@ This release is primarily a bugfix release since 1.1.0-rc1. - Fix newlines ##2014-01-03 - Release 1.1.0-rc1 - ###Summary This release of concat was 90% written by Joshua Hoblitt, and the module team @@ -137,7 +148,6 @@ This is a supported release. No functional changes were made from 1.0.1. ##2014-02-12 - 1.0.1 - ###Summary Minor bugfixes for sorting of fragments and ordering of resources. @@ -150,7 +160,6 @@ fragments. ##2013-08-09 - 1.0.0 - ###Summary Many new features and bugfixes in this release, and if you're a heavy concat diff --git a/metadata.json b/metadata.json index 07c8f12..9d7a46d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-concat", - "version": "1.1.2", + "version": "1.2.0", "author": "Puppet Labs", "summary": "Construct files from multiple fragments.", "license": "Apache-2.0", @@ -105,9 +105,6 @@ } ], "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 3.2.0 < 5.0.0" - } + {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"} ] } From 0e0dc74662f3373e12ef4b1557276250df596812 Mon Sep 17 00:00:00 2001 From: Spencer Krum Date: Thu, 19 Feb 2015 14:01:05 -0800 Subject: [PATCH 202/202] Removing travis badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 8225b05..b1cb66b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ #Concat -[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-concat.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-concat) - ####Table of Contents 1. [Overview](#overview)