forge "http://forge.puppetlabs.com"
#mod 'puppetlabs/stdlib', '4.5.1'
-#mod 'puppetlabs/concat', '1.2.0'
#mod 'puppetlabs/rabbitmq', '5.1.0'
#mod 'puppetlabs/xinetd', '1.5.0'
#mod 'puppetlabs/stunnel', '0.1.0'
+mod 'puppetlabs/concat', '2.0.0'
mod 'elasticsearch/elasticsearch', '0.9.5'
--- /dev/null
+=======
+##2015-05-12 - Supported Release 2.0.0
+###Summary
+
+This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments.
+
+####Features
+- Re-implementation of concat to use native Type and Providers.
+
+####Bugfixes
+- Fixes a bug in alpha ordering of fragments.
+
+
+##2015-05-12 - Supported Release 1.2.2
+###Summary
+
+This release includes a bugfix.
+
+####Bugfixes
+- Fixes a bug introduced by MODULES-1700, in handling default retrieval of fragment backup parameter.
+
+##2015-04-14 - Supported Release 1.2.1
+###Summary
+
+This release includes bugfixes, test improvements, and a rewritten README.
+
+####Bugfixes
+
+- Verifies existence of $is_pe before using it.
+- Adds validation for $order param to not allow restricted characters.
+- Sets the group id on Fragments for versions of Facter that contain the $gid fact.
+- Sets the script group to 0 if the script is owned by root.
+- Explicitly sets script and concat directories to the same owner and group.
+- Re-adds support for fragment backup, so that static compiler can work with filebucket (MODULES-1700).
+
+##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.
+
+####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
+
+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 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
+- 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
+- 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 - Release 1.1.0-rc1
+###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.
+
+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.
+- 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.
+
+##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
+
+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
+- 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
+ - make the location of sort configurable
+ - add the ability to add shell comment based warnings to
+ top of files
+ - add the ablity to create empty files
+- 2010/04/05 - fix parsing of WARN and change code style to match rest
+ of the code
+ - Better and safer boolean handling for warn and force
+ - Don't use hard coded paths in the shell script, set PATH
+ top of the script
+ - Use file{} to copy the result and make all fragments owned
+ by root. This means we can chnage the ownership/group of the
+ resulting file at any time.
+ - You can specify ensure => "/some/other/file" in concat::fragment
+ to include the contents of a symlink into the final file.
+- 2010/04/16 - Add more cleaning of the fragment name - removing / from the $name
+- 2010/05/22 - Improve documentation and show the use of ensure =>
+- 2010/07/14 - Add support for setting the filebucket behavior of files
+- 2010/10/04 - Make the warning message configurable
+- 2010/12/03 - Add flags to make concat work better on Solaris - thanks Jonathan Boyett
+- 2011/02/03 - Make the shell script more portable and add a config option for root group
+- 2011/06/21 - Make base dir root readable only for security
+- 2011/06/23 - Set base directory using a fact instead of hardcoding it
+- 2011/06/23 - Support operating as non privileged user
+- 2011/06/23 - Support dash instead of bash or sh
+- 2011/07/11 - Better solaris support
+- 2011/12/05 - Use fully qualified variables
+- 2011/12/13 - Improve Nexenta support
+- 2012/04/11 - Do not use any GNU specific extensions in the shell script
+- 2012/03/24 - Comply to community style guides
+- 2012/05/23 - Better errors when basedir isnt set
+- 2012/05/31 - Add spec tests
+- 2012/07/11 - Include concat::setup in concat improving UX
+- 2012/08/14 - Puppet Lint improvements
+- 2012/08/30 - The target path can be different from the $name
+- 2012/08/30 - More Puppet Lint cleanup
+- 2012/09/04 - RELEASE 0.2.0
+- 2012/12/12 - Added (file) $replace parameter to concat
--- /dev/null
+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:
+
+ - Make sure you have a [GitHub account](https://github.com/join)
+
+ - [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:
+
+ - 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. 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.
+
+
+ 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
+ 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://puppetlabs.com/community/get-help)
+
+* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests)
+
+* [Patchwork](https://patchwork.puppetlabs.com)
+
+* [General GitHub documentation](http://help.github.com/)
+
+* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
+
--- /dev/null
+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 'rspec-core', '3.1.7', :require => false
+ gem 'rspec-puppet', '~> 2.0', :require => false
+ gem 'puppetlabs_spec_helper', :require => false
+ gem 'simplecov', :require => false
+ gem 'puppet_facts', :require => false
+ gem 'json', :require => false
+ gem 'pry'
+end
+
+group :system_tests do
+ if beaker_version = ENV['BEAKER_VERSION']
+ gem 'beaker', *location_for(beaker_version)
+ end
+ if beaker_rspec_version = ENV['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
+else
+ gem 'facter', :require => false
+end
+
+if puppetversion = ENV['PUPPET_GEM_VERSION']
+ gem 'puppet', puppetversion, :require => false
+else
+ gem 'puppet', :require => false
+end
+
+# vim:ft=ruby
--- /dev/null
+ Copyright 2012 R.I.Pienaar
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+#concat
+
+####Table of Contents
+
+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)
+ * [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)
+ * [Defines](#defines)
+ * [Parameters](#parameters)
+ * [Removed functionality](#removed-functionality)
+6. [Limitations - OS compatibility, etc.](#limitations)
+7. [Development - Guide for contributing to the module](#development)
+
+##Overview
+
+The concat module lets you construct files from multiple ordered fragments of text.
+
+##Module Description
+
+The concat module lets you gather `concat::fragment` resources from your other modules and order them into a coherent file through a single `concat` resource.
+
+###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:
+
+~~~
+concat { '/tmp/file':
+ ensure => present,
+}
+
+concat::fragment { 'tmpfile':
+ target => '/tmp/file',
+ content => 'test contents',
+ order => '01'
+}
+~~~
+
+##Usage
+
+###Maintain a list of the major modules on a node
+
+To maintain an motd file that lists the modules on one of your nodes, first create a class to frame up the file:
+
+~~~
+class motd {
+ $motd = '/etc/motd'
+
+ concat { $motd:
+ owner => 'root',
+ group => 'root',
+ mode => '0644'
+ }
+
+ concat::fragment{ 'motd_header':
+ target => $motd,
+ content => "\nPuppet modules on this server:\n\n",
+ order => '01'
+ }
+
+ # let local users add to the motd by creating a file called
+ # /etc/motd.local
+ concat::fragment{ 'motd_local':
+ target => $motd,
+ source => '/etc/motd.local',
+ order => '15'
+ }
+}
+
+# let other modules register themselves in the motd
+define motd::register($content="", $order='10') {
+ if $content == "" {
+ $body = $name
+ } else {
+ $body = $content
+ }
+
+ concat::fragment{ "motd_fragment_$name":
+ target => '/etc/motd',
+ order => $order,
+ content => " -- $body\n"
+ }
+}
+~~~
+
+Then, in the declarations for each module on the node, add `motd::register{ 'Apache': }` to register the module in the motd.
+
+~~~
+class apache {
+ include apache::install, apache::config, apache::service
+
+ motd::register{ 'Apache': }
+}
+~~~
+
+These two steps populate the /etc/motd file with a list of the installed and registered modules, which stays updated even if you just remove the registered modules' `include` lines. System administrators can append text to the list by writing to /etc/motd.local.
+
+When you're finished, the motd file will look something like this:
+
+~~~
+ Puppet modules on this server:
+
+ -- Apache
+ -- MySQL
+
+ <contents of /etc/motd.local>
+~~~
+
+##Reference
+
+###Defines
+* `concat`: Manages a file, compiled from one or more text fragments.
+* `concat::fragment`: Manages a fragment of text to be compiled into a file.
+
+###Types
+* `concat_file`: Generates a file with content from fragments sharing a common unique tag.
+* `concat_fragment`: Manages the fragment.
+
+###Parameters
+
+####Define: `concat`
+
+All the parameters listed below are optional.
+
+#####`backup`
+
+Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'.
+
+#####`ensure`
+
+Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'.
+
+#####`ensure_newline`
+
+Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: 'true' and 'false'. Default value: 'false'.
+
+#####`force`
+
+Deprecated as of concat v2.0.0. Has no effect.
+
+#####`group`
+
+Specifies a permissions group for the destination file. Valid options: a string containing a group name. Default value: undefined.
+
+#####`mode`
+
+Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. Default value: '0644'.
+
+#####`order`
+
+Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). Default value: 'alpha'.
+
+You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations.
+
+#####`owner`
+
+Specifies the owner of the destination file. Valid options: a string containing a username. Default value: undefined.
+
+#####`path`
+
+Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the title of your declared resource.
+
+#####`replace`
+
+Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'.
+
+#####`validate_cmd`
+
+Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined.
+
+#####`warn`
+
+Specifies whether to add a header message at the top of the destination file. Valid options: the booleans 'true' and 'false', or a string to serve as the header. Default value: 'false'.
+
+If you set 'warn' to 'true', `concat` adds the following message:
+
+~~~
+# This file is managed by Puppet. DO NOT EDIT.
+~~~
+
+####Define: `concat::fragment`
+
+Except where noted, all the below parameters are optional.
+
+#####`content`
+
+Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. Default value: undef.
+
+#####`ensure`
+
+Deprecated as of concat v2.0.0. Has no effect.
+
+#####`order`
+
+Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. Default value: '10'.
+
+#####`source`
+
+Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. Default value: undefined.
+
+#####`target`
+
+*Required.* Specifies the destination file of the fragment. Valid options: a string containing an absolute path.
+
+
+####Type: `concat_file`
+
+#####`backup`
+
+Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'.
+
+#####`ensure`
+
+Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'.
+
+#####`ensure_newline`
+
+Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: 'true' and 'false'. Default value: 'false'.
+
+#####`group`
+
+Specifies a permissions group for the destination file. Valid options: a string containing a group name. Default value: undefined.
+
+#####`mode`
+
+Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. Default value: '0644'.
+
+#####`order`
+
+Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). Default value: 'numeric'.
+
+You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations.
+
+#####`owner`
+
+Specifies the owner of the destination file. Valid options: a string containing a username. Default value: undefined.
+
+#####`path`
+
+Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the title of your declared resource.
+
+#####`replace`
+
+Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'.
+
+####`tag`
+
+*Required.* Specifies a unique tag reference to collect all concat_fragments with the same tag.
+
+#####`validate_cmd`
+
+Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined.
+
+####Type: `concat_fragment`
+
+#####`content`
+
+Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. Default value: undef.
+
+#####`order`
+
+Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. Default value: '10'.
+
+#####`source`
+
+Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. Default value: undefined.
+
+#####`tag`
+
+*Required.* Specifies a unique tag to be used by concat_file to reference and collect content.
+
+#####`target`
+
+*Required.* Specifies the destination file of the fragment. Valid options: a string containing an absolute path.
+
+###Removed functionality
+
+The following functionality existed in previous versions of the concat module, but was removed in version 2.0.0:
+
+Parameters removed from `concat::fragment`:
+* `gnu`
+* `backup`
+* `group`
+* `mode`
+* `owner`
+
+The `concat::setup` class has also been removed.
+
+Prior to concat version 2.0.0, if you set the `warn` parameter to a string value of 'true', 'false', 'yes', 'no', 'on', or 'off', the module translated the string to the corresponding boolean value. In concat version 2.0.0 and newer, the `warn_header` parameter treats those values the same as other strings and uses them as the content of your header message. To avoid that, pass the 'true' and 'false' values as booleans instead of strings.
+
+##Limitations
+
+This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified.
+
+##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.
+
+For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html)
+
+###Contributors
+
+Richard Pijnenburg ([@Richardp82](http://twitter.com/richardp82))
+
+Joshua Hoblitt ([@jhoblitt](http://twitter.com/jhoblitt))
+
+[More contributors.](https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors)
--- /dev/null
+require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+
+PuppetLint.configuration.fail_on_warnings = true
+PuppetLint.configuration.send('relative')
+PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.send('disable_class_inherits_from_params_class')
+PuppetLint.configuration.send('disable_documentation')
+PuppetLint.configuration.send('disable_single_quote_string_with_variables')
+PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
--- /dev/null
+{
+ "CHANGELOG.md": "c5810ae257f789f7fea08d9629144f7d",
+ "CONTRIBUTING.md": "e2b8e8e433fc76b3798b7fe435f49375",
+ "Gemfile": "78b3171b07a747a7353350504f144f64",
+ "LICENSE": "f5a76685d453424cd63dde1535811cf0",
+ "README.md": "6df5e549bec657669f9b65069becd6ff",
+ "Rakefile": "d953eb985f82600dc3b9ac6e1f2cfe64",
+ "lib/puppet/type/concat_file.rb": "7cc4e5b1f1cc8354bcbab4de386d8805",
+ "lib/puppet/type/concat_fragment.rb": "f661ea5a5143387513571e1892eeb74f",
+ "manifests/fragment.pp": "e758dfb57f0fe796abcaf64af10a9c57",
+ "manifests/init.pp": "8443e17ab8eaecb0db764701083b504c",
+ "metadata.json": "1fcd602ed1156173234655457518ef63",
+ "spec/acceptance/backup_spec.rb": "242ce4dce1efba5efb21850b9bb2a342",
+ "spec/acceptance/concat_spec.rb": "90da0deea2501ab1abc74fac31f02857",
+ "spec/acceptance/deprecation_warnings_spec.rb": "1b005f407eba3a6a3b93bed1d3e529dd",
+ "spec/acceptance/fragment_source_spec.rb": "3d0e708a392e4b75e8484f2f0b4d256f",
+ "spec/acceptance/fragments_are_always_replaced_spec.rb": "be39ed9ed30e7bb48aaccda2d7f730ac",
+ "spec/acceptance/newline_spec.rb": "5aaf65972c4f8ed4fd1592cd863583f5",
+ "spec/acceptance/nodesets/aix-71-vcloud.yml": "de6cc5bf18be2be8d50e62503652cb32",
+ "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151",
+ "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
+ "spec/acceptance/nodesets/centos-64-x64.yml": "9cde7b5d2ab6a42366d2344c264d6bdc",
+ "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af",
+ "spec/acceptance/nodesets/debian-607-x64.yml": "d566bf76f534e2af7c9a4605316d232c",
+ "spec/acceptance/nodesets/debian-70rc1-x64.yml": "31ccca73af7b74e1cc2fb0035c230b2c",
+ "spec/acceptance/nodesets/debian-73-x64.yml": "bd3ea8245ce691c2b234529d62d043eb",
+ "spec/acceptance/nodesets/default.yml": "3e5c36e6aa5a690229e720f4048bb8af",
+ "spec/acceptance/nodesets/fedora-18-x64.yml": "acc126fa764c39a3b1df36e9224a21d9",
+ "spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66",
+ "spec/acceptance/nodesets/sles-11sp1-x64.yml": "fa0046bd89c1ab4ba9521ad79db234cd",
+ "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297",
+ "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269",
+ "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0",
+ "spec/acceptance/order_spec.rb": "14e739dc02b4a4b48c5ed4d2c9bf1d17",
+ "spec/acceptance/quoted_paths_spec.rb": "a7810ac24a913bbc0d733f9b1d263748",
+ "spec/acceptance/replace_spec.rb": "f0c42c610e53fc9739581d99a3cd94b0",
+ "spec/acceptance/specinfra_stubs.rb": "27839261403d8bbccf506552f9d8ef38",
+ "spec/acceptance/symbolic_name_spec.rb": "b40452adbfebb0ea9d56547d9daee700",
+ "spec/acceptance/validation_spec.rb": "e54226b10f46cfa9e89e57398eddbbd2",
+ "spec/acceptance/warn_header_spec.rb": "269e9329646674ec6975c34e0c58e8c1",
+ "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
+ "spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc",
+ "spec/spec_helper_acceptance.rb": "8e54857655edc99e04917061bcd90eb2",
+ "spec/unit/defines/concat_fragment_spec.rb": "c348de6b52813bfdf1d5003f1234a164",
+ "spec/unit/defines/concat_spec.rb": "5ca746486a405dc226fc34cf35ac9e54",
+ "tests/fragment.pp": "9adc3d9ba61676066072e1b949a37dbb",
+ "tests/init.pp": "356477e6c25394550886bf1c1edb72a4"
+}
\ No newline at end of file
--- /dev/null
+require 'puppet/type/file/owner'
+require 'puppet/type/file/group'
+require 'puppet/type/file/mode'
+require 'puppet/util/checksums'
+
+Puppet::Type.newtype(:concat_file) do
+ @doc = "Gets all the file fragments and puts these into the target file.
+ This will mostly be used with exported resources.
+
+ example:
+ Concat_fragment <<| tag == 'unique_tag' |>>
+
+ concat_file { '/tmp/file':
+ tag => 'unique_tag', # Mandatory
+ path => '/tmp/file', # Optional. If given it overrides the resource name
+ owner => 'root', # Optional. Default to undef
+ group => 'root', # Optional. Default to undef
+ mode => '0644' # Optional. Default to undef
+ order => 'numeric' # Optional, Default to 'numeric'
+ ensure_newline => false # Optional, Defaults to false
+ }
+ "
+ ensurable do
+ defaultvalues
+
+ defaultto { :present }
+ end
+
+ def exists?
+ self[:ensure] == :present
+ end
+
+ newparam(:name, :namevar => true) do
+ desc "Resource name"
+ end
+
+ newparam(:tag) do
+ desc "Tag reference to collect all concat_fragment's with the same tag"
+ end
+
+ newparam(:path) do
+ desc "The output file"
+ defaultto do
+ resource.value(:name)
+ end
+ end
+
+ newparam(:owner, :parent => Puppet::Type::File::Owner) do
+ desc "Desired file owner."
+ end
+
+ newparam(:group, :parent => Puppet::Type::File::Group) do
+ desc "Desired file group."
+ end
+
+ newparam(:mode, :parent => Puppet::Type::File::Mode) do
+ desc "Desired file mode."
+ end
+
+ newparam(:order) do
+ desc "Controls the ordering of fragments. Can be set to alphabetical or numeric."
+ defaultto 'numeric'
+ end
+
+ newparam(:backup) do
+ desc "Controls the filebucketing behavior of the final file and see File type reference for its use."
+ defaultto 'puppet'
+ end
+
+ newparam(:replace) do
+ desc "Whether to replace a file that already exists on the local system."
+ defaultto true
+ end
+
+ newparam(:validate_cmd) do
+ desc "Validates file."
+ end
+
+ newparam(:ensure_newline) do
+ desc "Whether to ensure there is a newline after each fragment."
+ defaultto false
+ end
+
+ autorequire(:concat_fragment) do
+ catalog.resources.collect do |r|
+ if r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag]
+ r.name
+ end
+ end.compact
+ end
+
+ def should_content
+ return @generated_content if @generated_content
+ @generated_content = ""
+ content_fragments = []
+
+ resources = catalog.resources.select do |r|
+ r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag]
+ end
+
+ resources.each do |r|
+ content_fragments << ["#{r[:order]}___#{r[:name]}", fragment_content(r)]
+ end
+
+ if self[:order] == 'numeric'
+ sorted = content_fragments.sort do |a, b|
+ def decompound(d)
+ d.split('___').map { |v| v =~ /^\d+$/ ? v.to_i : v }
+ end
+
+ decompound(a[0]) <=> decompound(b[0])
+ end
+ else
+ sorted = content_fragments.sort do |a, b|
+ def decompound(d)
+ d.split('___').first
+ end
+
+ decompound(a[0]) <=> decompound(b[0])
+ end
+ end
+
+ @generated_content = sorted.map { |cf| cf[1] }.join
+
+ @generated_content
+ end
+
+ def fragment_content(r)
+ if r[:content].nil? == false
+ fragment_content = r[:content]
+ elsif r[:source].nil? == false
+ @source = nil
+ Array(r[:source]).each do |source|
+ if Puppet::FileServing::Metadata.indirection.find(source)
+ @source = source
+ break
+ end
+ end
+ self.fail "Could not retrieve source(s) #{r[:source].join(", ")}" unless @source
+ tmp = Puppet::FileServing::Content.indirection.find(@source, :environment => catalog.environment)
+ fragment_content = tmp.content unless tmp.nil?
+ end
+
+ if self[:ensure_newline]
+ fragment_content<<"\n" unless fragment_content =~ /\n$/
+ end
+
+ fragment_content
+ end
+
+ def eval_generate
+ file_opts = {
+ :ensure => self[:ensure] == :absent ? :absent : :file,
+ :content => self.should_content,
+ }
+
+ [:path, :owner, :group, :mode, :replace, :backup].each do |param|
+ unless self[param].nil?
+ file_opts[param] = self[param]
+ end
+ end
+
+ [Puppet::Type.type(:file).new(file_opts)]
+ end
+end
--- /dev/null
+Puppet::Type.newtype(:concat_fragment) do
+ @doc = "Create a concat fragment to be used by concat.
+ the `concat_fragment` type creates a file fragment to be collected by concat based on the tag.
+ The example is based on exported resources.
+
+ Example:
+ @@concat_fragment { \"uniqe_name_${::fqdn}\":
+ tag => 'unique_name',
+ order => 10, # Optional. Default to 10
+ content => 'some content' # OR
+ content => template('template.erb') # OR
+ source => 'puppet:///path/to/file'
+ }
+ "
+
+ newparam(:name, :namevar => true) do
+ desc "Unique name"
+ end
+
+ newparam(:content) do
+ desc "Content"
+ end
+
+ newparam(:source) do
+ desc "Source"
+ end
+
+ newparam(:order) do
+ desc "Order"
+ defaultto '10'
+ validate do |val|
+ fail Puppet::ParseError, '$order is not a string or integer.' if !(val.is_a? String or val.is_a? Integer)
+ fail Puppet::ParseError, "Order cannot contain '/', ':', or '\n'." if val.to_s =~ /[:\n\/]/
+ end
+ end
+
+ newparam(:tag) do
+ desc "Tag name to be used by concat to collect all concat_fragments by tag name"
+ end
+
+ validate do
+ # Check if either source or content is set. raise error if none is set
+ fail Puppet::ParseError, "Set either 'source' or 'content'" if self[:source].nil? && self[:content].nil?
+
+ # Check if both are set, if so rais error
+ fail Puppet::ParseError, "Can't use 'source' and 'content' at the same time" if !self[:source].nil? && !self[:content].nil?
+ end
+end
--- /dev/null
+# == Define: concat::fragment
+#
+# Creates a concat_fragment in the catalogue
+#
+# === 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
+#
+define concat::fragment(
+ $target,
+ $ensure = undef,
+ $content = undef,
+ $source = undef,
+ $order = '10',
+) {
+ validate_string($target)
+
+ if $ensure != undef {
+ warning('The $ensure parameter to concat::fragment is deprecated and has no effect.')
+ }
+
+ validate_string($content)
+ if !(is_string($source) or is_array($source)) {
+ fail('$source is not a string or an Array.')
+ }
+
+ if !(is_string($order) or is_integer($order)) {
+ fail('$order is not a string or integer.')
+ } elsif (is_string($order) and $order =~ /[:\n\/]/) {
+ fail("Order cannot contain '/', ':', or '\n'.")
+ }
+
+ if ! ($content or $source) {
+ crit('No content, source or symlink specified')
+ } elsif ($content and $source) {
+ fail("Can't use 'source' and 'content' at the same time")
+ }
+
+ $safe_target_name = regsubst($target, '[/:\n\s]', '_', 'GM')
+
+ concat_fragment { $name:
+ tag => $safe_target_name,
+ order => $order,
+ content => $content,
+ source => $source,
+ }
+}
--- /dev/null
+# == Define: concat
+#
+# Sets up so that you can use fragments to build a final config file,
+#
+# === 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
+# provided in the target of your fragments.
+# [*owner*]
+# Who will own the file
+# [*group*]
+# Who will own the file
+# [*mode*]
+# The mode of the final file
+# [*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
+# [*order*]
+# Select whether to order associated fragments by 'alpha' or 'numeric'.
+# Defaults to 'alpha'.
+# [*ensure_newline*]
+# Specifies whether to ensure there's a new line at the end of each fragment.
+# Valid options: 'true' and 'false'. Default value: 'false'.
+# [*validate_cmd*]
+# Specifies a validation command to apply to the destination file.
+# Requires Puppet version 3.5 or newer. Valid options: a string to be passed
+# to a file resource. Default value: undefined.
+#
+
+define concat(
+ $ensure = 'present',
+ $path = $name,
+ $owner = undef,
+ $group = undef,
+ $mode = '0644',
+ $warn = false,
+ $force = undef,
+ $backup = 'puppet',
+ $replace = true,
+ $order = 'alpha',
+ $ensure_newline = false,
+ $validate_cmd = undef,
+) {
+ validate_re($ensure, '^present$|^absent$')
+ validate_absolute_path($path)
+ validate_string($owner)
+ validate_string($group)
+ validate_string($mode)
+ if ! (is_string($warn) or $warn == true or $warn == false) {
+ fail('$warn is not a string or boolean')
+ }
+ 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)
+
+ if $validate_cmd and ! is_string($validate_cmd) {
+ fail('$validate_cmd must be a string')
+ }
+
+ if $force != undef {
+ warning('The $force parameter to concat is deprecated and has no effect.')
+ }
+
+ $safe_name = regsubst($name, '[/:\n\s]', '_', 'G')
+ $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"
+
+ case $warn {
+ true: {
+ $warn_message = $default_warn_message
+ $_append_header = true
+ }
+ false: {
+ $warn_message = ''
+ $_append_header = false
+ }
+ default: {
+ $warn_message = $warn
+ $_append_header = true
+ }
+ }
+
+ if $ensure == 'present' {
+ concat_file { $name:
+ tag => $safe_name,
+ path => $path,
+ owner => $owner,
+ group => $group,
+ mode => $mode,
+ replace => $replace,
+ backup => $backup,
+ order => $order,
+ ensure_newline => $ensure_newline,
+ validate_cmd => $validate_cmd,
+ }
+
+ if $_append_header {
+ concat_fragment { "${name}_header":
+ tag => $safe_name,
+ content => $warn_message,
+ order => '0',
+ }
+ }
+ } else {
+ concat_file { $name:
+ ensure => $ensure,
+ tag => $safe_name,
+ path => $path,
+ backup => $backup,
+ }
+ }
+}
+
--- /dev/null
+{
+ "name": "puppetlabs-concat",
+ "version": "2.0.0",
+ "author": "Puppet Labs",
+ "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",
+ "issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
+ "dependencies": [
+ {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0 < 5.0.0"}
+ ],
+ "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": [
+ "10 SP4",
+ "11 SP1",
+ "12"
+ ]
+ },
+ {
+ "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.7.0 < 4.0.0"
+ },
+ {
+ "name": "puppet",
+ "version_requirement": "3.x"
+ }
+ ]
+}
--- /dev/null
+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
+ concat { '#{basedir}/file':
+ backup => 'puppet',
+ }
+ concat::fragment { 'new file':
+ target => '#{basedir}/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.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/)
+ end
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) { should match /new contents/ }
+ end
+ 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
+ concat { '#{basedir}/file':
+ backup => '.backup',
+ }
+ concat::fragment { 'new file':
+ target => '#{basedir}/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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) { should match /new contents/ }
+ end
+ describe file("#{basedir}/file.backup") do
+ it { should be_file }
+ its(:content) { should match /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
+ pp = <<-EOS
+ file { '#{basedir}':
+ ensure => directory,
+ }
+ file { '#{basedir}/file':
+ content => "old contents\n",
+ }
+ EOS
+ apply_manifest(pp)
+ end
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ backup => '.backup',
+ }
+ concat::fragment { 'new file':
+ target => '#{basedir}/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.stdout).to_not match(/Filebucketed/)
+ end
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) { should match /new contents/ }
+ end
+ end
+end
--- /dev/null
+require 'spec_helper_acceptance'
+
+case fact('osfamily')
+ when 'AIX'
+ username = 'root'
+ groupname = 'system'
+ scriptname = 'concatfragments.rb'
+ vardir = default['puppetvardir']
+ when 'Darwin'
+ username = 'root'
+ groupname = 'wheel'
+ scriptname = 'concatfragments.rb'
+ 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.rb'
+ vardir = default['puppetvardir']
+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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+ 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}',
+ group => '#{groupname}',
+ mode => '0644',
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/file',
+ content => '1',
+ order => '01',
+ }
+
+ concat::fragment { '2':
+ target => '#{basedir}/file',
+ content => '2',
+ order => '02',
+ }
+ EOS
+
+ it_behaves_like 'successfully_applied', pp
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ it { should be_owned_by username }
+ 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
+ }
+ its(:content) {
+ should match '1'
+ should match '2'
+ }
+ end
+ end
+
+ 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,
+ path => '#{basedir}/file',
+ mode => '0644',
+ }
+ concat::fragment { '1':
+ target => 'file',
+ content => '1',
+ order => '01',
+ }
+ "
+
+ it_behaves_like 'successfully_applied', pp
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
+ should be_mode 644
+ }
+ its(:content) { should match '1' }
+ 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,
+ path => '#{basedir}/file',
+ mode => '0644',
+ }
+ concat::fragment { '1':
+ target => 'file',
+ content => '1',
+ order => '01',
+ }
+ "
+
+ 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_not be_file }
+ end
+ end
+ end
+end
--- /dev/null
+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
+ 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
+
+ context 'concat force parameter' do
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ force => false,
+ }
+ concat::fragment { 'foo':
+ target => '#{basedir}/file',
+ content => 'bar',
+ }
+ EOS
+ w = 'The $force parameter to concat is deprecated and has no effect.'
+
+ it_behaves_like 'has_warning', pp, w
+ end
+
+ context 'concat::fragment ensure parameter' do
+ context 'target file exists' do
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ }
+ concat::fragment { 'foo':
+ target => '#{basedir}/file',
+ ensure => false,
+ content => 'bar',
+ }
+ EOS
+ w = 'The $ensure parameter to concat::fragment is deprecated and has no effect.'
+
+ it_behaves_like 'has_warning', pp, w
+ end
+ end
+end
--- /dev/null
+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'
+end
+
+describe 'concat::fragment source' do
+ basedir = default.tmpdir('concat')
+ context 'should read file fragments from local system' do
+ pp = <<-EOS
+ file { '#{basedir}/file1':
+ content => "file1 contents\n"
+ }
+ file { '#{basedir}/file2':
+ content => "file2 contents\n"
+ }
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ source => '#{basedir}/file1',
+ require => File['#{basedir}/file1'],
+ }
+ concat::fragment { '2':
+ target => '#{basedir}/foo',
+ content => 'string1 contents',
+ }
+ concat::fragment { '3':
+ target => '#{basedir}/foo',
+ source => '#{basedir}/file2',
+ require => File['#{basedir}/file2'],
+ }
+ 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}/foo") do
+ it { should be_file }
+ its(:content) {
+ should match 'file1 contents'
+ should match 'string1 contents'
+ should match 'file2 contents'
+ }
+ end
+ end # should read file fragments from local system
+
+ context 'should create files containing first match only.' do
+ pp = <<-EOS
+ 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 { '#{basedir}/result_file2':
+ owner => '#{username}',
+ group => '#{groupname}',
+ mode => '0644',
+ }
+ concat { '#{basedir}/result_file3':
+ owner => '#{username}',
+ group => '#{groupname}',
+ mode => '0644',
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/result_file1',
+ source => [ '#{basedir}/file1', '#{basedir}/file2' ],
+ require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
+ order => '01',
+ }
+ concat::fragment { '2':
+ target => '#{basedir}/result_file2',
+ source => [ '#{basedir}/file2', '#{basedir}/file1' ],
+ require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
+ order => '01',
+ }
+ concat::fragment { '3':
+ target => '#{basedir}/result_file3',
+ source => [ '#{basedir}/file1', '#{basedir}/file2' ],
+ require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
+ order => '01',
+ }
+ 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}/result_file1") do
+ it { should be_file }
+ its(:content) {
+ should match 'file1 contents'
+ should_not match 'file2 contents'
+ }
+ end
+ describe file("#{basedir}/result_file2") do
+ it { should be_file }
+ its(:content) {
+ should match 'file2 contents'
+ should_not match 'file1 contents'
+ }
+ end
+ describe file("#{basedir}/result_file3") do
+ it { should be_file }
+ its(:content) {
+ should match 'file1 contents'
+ should_not match 'file2 contents'
+ }
+ end
+ end
+
+ context 'should fail if no match on source.' do
+ pp = <<-EOS
+ concat { '#{basedir}/fail_no_source':
+ owner => '#{username}',
+ group => '#{groupname}',
+ mode => '0644',
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/fail_no_source',
+ source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ],
+ order => '01',
+ }
+ EOS
+
+ it 'applies the manifest with resource failures' do
+ expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/Failed to generate additional resources using 'eval_generate'/)
+ end
+ 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 }
+ end
+ end
+end
+
--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'concat::fragment replace' do
+ basedir = default.tmpdir('concat')
+
+ context 'should create fragment files' do
+ before(:all) do
+ pp = <<-EOS
+ file { '#{basedir}':
+ ensure => directory,
+ }
+ EOS
+ apply_manifest(pp)
+ end
+
+ pp1 = <<-EOS
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace unset run 1',
+ }
+ EOS
+ pp2 = <<-EOS
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace unset run 2',
+ }
+ EOS
+
+ it 'applies the manifest twice with no stderr' do
+ 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("#{basedir}/foo") do
+ it { should be_file }
+ 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
+
+ context 'should replace its own fragment files when caller has File { replace=>true } set' do
+ before(:all) do
+ pp = <<-EOS
+ file { '#{basedir}':
+ ensure => directory,
+ }
+ EOS
+ apply_manifest(pp)
+ end
+
+ pp1 = <<-EOS
+ File { replace=>true }
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace true set run 1',
+ }
+ EOS
+ pp2 = <<-EOS
+ File { replace=>true }
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace true set run 2',
+ }
+ EOS
+
+ it 'applies the manifest twice with no stderr' do
+ 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("#{basedir}/foo") do
+ it { should be_file }
+ 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
+
+ context 'should replace its own fragment files even when caller has File { replace=>false } set' do
+ before(:all) do
+ pp = <<-EOS
+ file { '#{basedir}':
+ ensure => directory,
+ }
+ EOS
+ apply_manifest(pp)
+ end
+
+ pp1 = <<-EOS
+ File { replace=>false }
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace false set run 1',
+ }
+ EOS
+ pp2 = <<-EOS
+ File { replace=>false }
+ concat { '#{basedir}/foo': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'caller has replace false set run 2',
+ }
+ EOS
+
+ it 'applies the manifest twice with no stderr' do
+ 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("#{basedir}/foo") do
+ it { should be_file }
+ 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
+
+end
--- /dev/null
+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
+ concat { '#{basedir}/file':
+ ensure_newline => false,
+ }
+ 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) { should match '12' }
+ end
+ end
+
+ context '=> true' do
+ pp = <<-EOS
+ 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) {
+ should match /1\n2\n/
+ }
+ end
+ end
+end
--- /dev/null
+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/
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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: foss
--- /dev/null
+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: foss
--- /dev/null
+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
--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'concat order' do
+ basedir = default.tmpdir('concat')
+
+ context '=> ' do
+ shared_examples 'sortby' do |order_by, match_output|
+ pp = <<-EOS
+ concat { '#{basedir}/foo':
+ 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
+
+ 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 'alpha' do
+ it_behaves_like 'sortby', 'alpha', /string1string10string2/
+ end
+
+ describe 'numeric' do
+ it_behaves_like 'sortby', 'numeric', /string1string2string10/
+ end
+ end
+end # concat order
+
+describe 'concat::fragment order' do
+ basedir = default.tmpdir('concat')
+
+ context '=> reverse order' do
+ 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',
+ order => '15',
+ }
+ concat::fragment { '2':
+ target => '#{basedir}/foo',
+ content => 'string2',
+ # default order 10
+ }
+ concat::fragment { '3':
+ target => '#{basedir}/foo',
+ content => 'string3',
+ order => '1',
+ }
+ 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}/foo") do
+ it { should be_file }
+ its(:content) { should match match_output }
+ end
+ end
+ describe 'alpha' do
+ it_should_behave_like 'order_by', 'alpha', /string3string2string1/
+ end
+ describe 'numeric' do
+ it_should_behave_like 'order_by', 'numeric', /string3string2string1/
+ end
+ end
+
+ context '=> normal order' do
+ pp = <<-EOS
+ concat { '#{basedir}/foo': }
+ concat::fragment { '1':
+ target => '#{basedir}/foo',
+ content => 'string1',
+ order => '01',
+ }
+ concat::fragment { '2':
+ target => '#{basedir}/foo',
+ content => 'string2',
+ order => '02'
+ }
+ concat::fragment { '3':
+ target => '#{basedir}/foo',
+ content => 'string3',
+ order => '03',
+ }
+ 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}/foo") do
+ it { should be_file }
+ its(:content) { should match /string1string2string3/ }
+ end
+ end
+end # concat::fragment order
--- /dev/null
+require 'spec_helper_acceptance'\r
+\r
+describe 'quoted paths' do\r
+ basedir = default.tmpdir('concat')\r
+\r
+ before(:all) do\r
+ pp = <<-EOS\r
+ file { '#{basedir}':\r
+ ensure => directory,\r
+ }\r
+ file { '#{basedir}/concat test':\r
+ ensure => directory,\r
+ }\r
+ EOS\r
+ apply_manifest(pp)\r
+ end\r
+\r
+ context 'path with blanks' do\r
+ pp = <<-EOS\r
+ concat { '#{basedir}/concat test/foo':\r
+ }\r
+ concat::fragment { '1':\r
+ target => '#{basedir}/concat test/foo',\r
+ content => 'string1',\r
+ }\r
+ concat::fragment { '2':\r
+ target => '#{basedir}/concat test/foo',\r
+ content => 'string2',\r
+ }\r
+ EOS\r
+\r
+ it 'applies the manifest twice with no stderr' do\r
+ apply_manifest(pp, :catch_failures => true)\r
+ apply_manifest(pp, :catch_changes => true)\r
+ end\r
+\r
+ describe file("#{basedir}/concat test/foo") do\r
+ it { should be_file }\r
+ its(:content) { should match /string1string2/ }\r
+ end\r
+ end\r
+end\r
--- /dev/null
+require 'spec_helper_acceptance'
+
+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
+ concat { '#{basedir}/file':
+ replace => false,
+ }
+
+ 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) {
+ should match 'file exists'
+ should_not match '1'
+ should_not match '2'
+ }
+ end
+ 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
+ concat { '#{basedir}/file':
+ replace => 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) {
+ should_not match 'file exists'
+ should match '1'
+ should match '2'
+ }
+ end
+ end
+ end # file
+
+ 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
+ # 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
+ concat { '#{basedir}/file':
+ replace => false,
+ }
+
+ 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ # XXX specinfra doesn't support be_linked_to on AIX
+ describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do
+ it { should be_linked_to "#{basedir}/dangling" }
+ end
+
+ describe file("#{basedir}/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
+ pp = <<-EOS
+ file { '#{basedir}':
+ ensure => directory,
+ }
+ file { '#{basedir}/file':
+ ensure => link,
+ target => '#{basedir}/dangling',
+ }
+ EOS
+ apply_manifest(pp)
+ end
+
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ replace => 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) {
+ should match '1'
+ should match '2'
+ }
+ end
+ end
+ end # symlink
+
+ 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': }
+
+ concat::fragment { '1':
+ target => '#{basedir}/file',
+ content => '1',
+ }
+
+ concat::fragment { '2':
+ target => '#{basedir}/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("#{basedir}/file") do
+ it { should be_directory }
+ end
+ end
+
+ # XXX
+ # 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
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ }
+
+ 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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) { should match '1' }
+ end
+ end
+ end # directory
+end
--- /dev/null
+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 "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
+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
--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'symbolic name' do
+ basedir = default.tmpdir('concat')
+ pp = <<-EOS
+ concat { 'not_abs_path':
+ path => '#{basedir}/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
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ describe file("#{basedir}/file") do
+ it { should be_file }
+ its(:content) {
+ should match '1'
+ should match '2'
+ }
+ end
+end
--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'concat validate_cmd parameter', :unless => (fact('kernel') != 'Linux') 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
--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'concat warn =>' do
+ basedir = default.tmpdir('concat')
+ context 'true should enable default warning message' do
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ warn => true,
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/file',
+ content => '1',
+ order => '01',
+ }
+
+ concat::fragment { '2':
+ target => '#{basedir}/file',
+ content => '2',
+ order => '02',
+ }
+ 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 }
+ 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
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ warn => false,
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/file',
+ content => '1',
+ order => '01',
+ }
+
+ concat::fragment { '2':
+ target => '#{basedir}/file',
+ content => '2',
+ order => '02',
+ }
+ 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 }
+ 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
+ pp = <<-EOS
+ concat { '#{basedir}/file':
+ warn => "# foo\n",
+ }
+
+ concat::fragment { '1':
+ target => '#{basedir}/file',
+ content => '1',
+ order => '01',
+ }
+
+ concat::fragment { '2':
+ target => '#{basedir}/file',
+ content => '2',
+ order => '02',
+ }
+ 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 }
+ its(:content) {
+ should match /# foo/
+ should match /1/
+ should match /2/
+ }
+ end
+ end
+end
--- /dev/null
+--format
+s
+--colour
+--loadby
+mtime
+--backtrace
--- /dev/null
+require 'puppetlabs_spec_helper/module_spec_helper'
--- /dev/null
+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
+ # 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']}"
+ if host['platform'] =~ /sles-1/i || host['platform'] =~ /solaris-1/i
+ get_deps = <<-EOS
+ package{'wget':}
+ exec{'download-stdlib':
+ 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_deps)
+ # 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.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.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
+ 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
+ hosts.each do |host|
+ copy_module_to(host, :source => proj_root, :module_name => 'concat')
+ 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
+
--- /dev/null
+require 'spec_helper'
+
+describe 'concat::fragment', :type => :define do
+
+ shared_examples 'fragment' do |title, params|
+ params = {} if params.nil?
+
+ p = {
+ :content => nil,
+ :source => nil,
+ :order => 10,
+ }.merge(params)
+
+ id = 'root'
+ gid = 'root'
+
+ let(:title) { title }
+ let(:params) { params }
+ let(:pre_condition) do
+ "concat{ '#{p[:target]}': }"
+ end
+
+ it do
+ should contain_concat(p[:target])
+ should contain_concat_file(p[:target])
+ should contain_concat_fragment(title)
+ end
+ end
+
+ context 'title' do
+ ['0', '1', 'a', 'z'].each do |title|
+ it_behaves_like 'fragment', title, {
+ :target => '/etc/motd',
+ :content => "content for #{title}"
+ }
+ end
+ end # title
+
+ context 'target =>' do
+ ['./etc/motd', 'etc/motd', 'motd_header'].each do |target|
+ context target do
+ it_behaves_like 'fragment', target, {
+ :target => '/etc/motd',
+ :content => "content for #{target}"
+ }
+ end
+ end
+
+ context 'false' do
+ let(:title) { 'motd_header' }
+ let(:params) {{ :target => false }}
+
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
+ end
+ end
+ end # target =>
+
+ 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(:params) {{ :content => false, :target => '/etc/motd' }}
+
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
+ end
+ end
+ end # content =>
+
+ context 'source =>' do
+ ['', '/foo/bar', ['/foo/bar', '/foo/baz']].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(:params) {{ :source => false, :target => '/etc/motd' }}
+
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/)
+ end
+ end
+ end # source =>
+
+ context 'more than one content source' do
+ context 'source and content' do
+ let(:title) { 'motd_header' }
+ let(:params) do
+ {
+ :target => '/etc/motd',
+ :source => '/foo',
+ :content => 'bar',
+ }
+ end
+
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /Can't use 'source' and 'content' at the same time/)
+ end
+ end
+ end # more than one content source
+end
--- /dev/null
+require 'spec_helper'
+
+describe 'concat', :type => :define do
+
+ shared_examples 'concat' do |title, params, id|
+ params = {} if params.nil?
+ id = 'root' if id.nil?
+
+ # default param values
+ p = {
+ :ensure => 'present',
+ :path => title,
+ :owner => nil,
+ :group => nil,
+ :mode => '0644',
+ :warn => false,
+ :backup => 'puppet',
+ :replace => true,
+ }.merge(params)
+
+ safe_name = title.gsub('/', '_')
+ concat_name = 'fragments.concat.out'
+ default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"
+
+ file_defaults = {
+ :backup => p[:backup],
+ }
+
+ let(:title) { title }
+ let(:params) { params }
+ let(:facts) do
+ {
+ :id => id,
+ :osfamily => 'Debian',
+ :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ :kernel => 'Linux',
+ :is_pe => false,
+ }
+ end
+
+ if p[:ensure] == 'present'
+ it do
+ should contain_concat(title).with(file_defaults.merge({
+ :ensure => 'present',
+ :owner => p[:owner],
+ :group => p[:group],
+ :mode => p[:mode],
+ :path => p[:path],
+ :backup => p[:backup],
+ :replace => p[:replace],
+ }))
+ end
+ else
+ it do
+ should contain_concat(title).with(file_defaults.merge({
+ :ensure => 'absent',
+ :backup => p[:backup],
+ }))
+ end
+ end
+ end
+
+ 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
+
+ ['./foo', 'foo', 'foo/bar'].each do |title|
+ context title do
+ let(:title) { title }
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/)
+ end
+ end
+ end
+ end
+
+ 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 # 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
+ it_behaves_like 'concat', '/etc/foo.bar', { :ensure => ens }
+ end
+ end
+
+ context 'invalid' do
+ let(:title) { '/etc/foo.bar' }
+ let(:params) {{ :ensure => 'invalid' }}
+ it 'should fail' do
+ expect { catalogue }.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
+
+ ['./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 { catalogue }.to raise_error(Puppet::Error, /is not an absolute path/)
+ end
+ end
+ end
+ end # path =>
+
+ 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 { catalogue }.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 { catalogue }.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 { catalogue }.to raise_error(Puppet::Error, /is not a string/)
+ end
+ end
+ end # mode =>
+
+ context 'warn =>' do
+ [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
+ skip('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 { catalogue }.to raise_error(Puppet::Error, /is not a string or boolean/)
+ end
+ end
+ end # warn =>
+
+ context 'backup =>' do
+ context 'reverse' do
+ it_behaves_like 'concat', '/etc/foo.bar', { :backup => 'reverse' }
+ 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 => [] }}
+ it 'should fail' do
+ expect { catalogue }.to raise_error(Puppet::Error, /backup must be string or bool/)
+ 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 { catalogue }.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 { catalogue }.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 { catalogue }.to raise_error(Puppet::Error, /is not a boolean/)
+ end
+ 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 { catalogue }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/)
+ end
+ end
+ end
+ end # validate_cmd =>
+end
--- /dev/null
+concat { 'testconcat':
+ ensure => present,
+ path => '/tmp/concat',
+ owner => 'root',
+ group => 'root',
+ mode => '0664',
+}
+
+concat::fragment { '1':
+ target => 'testconcat',
+ content => '1',
+ order => '01',
+}
+
+concat::fragment { '2':
+ target => 'testconcat',
+ content => '2',
+ order => '02',
+}
--- /dev/null
+concat { '/tmp/concat':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+}
+++ /dev/null
-fixtures:
- symlinks:
- 'concat': '#{source_dir}'
+++ /dev/null
-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'
+++ /dev/null
-language: ruby
-rvm:
- - 1.8.7
-script:
- - "rake lint"
- - "rake spec"
-branches:
- only:
- - master
-env:
- - PUPPET_VERSION=2.7.11
-gemfile: .gemfile
+++ /dev/null
-CHANGELOG:
-- 2010/02/19 - initial release
-- 2010/03/12 - add support for 0.24.8 and newer
- - make the location of sort configurable
- - add the ability to add shell comment based warnings to
- top of files
- - add the ablity to create empty files
-- 2010/04/05 - fix parsing of WARN and change code style to match rest
- of the code
- - Better and safer boolean handling for warn and force
- - Don't use hard coded paths in the shell script, set PATH
- top of the script
- - Use file{} to copy the result and make all fragments owned
- by root. This means we can chnage the ownership/group of the
- resulting file at any time.
- - You can specify ensure => "/some/other/file" in concat::fragment
- to include the contents of a symlink into the final file.
-- 2010/04/16 - Add more cleaning of the fragment name - removing / from the $name
-- 2010/05/22 - Improve documentation and show the use of ensure =>
-- 2010/07/14 - Add support for setting the filebucket behavior of files
-- 2010/10/04 - Make the warning message configurable
-- 2010/12/03 - Add flags to make concat work better on Solaris - thanks Jonathan Boyett
-- 2011/02/03 - Make the shell script more portable and add a config option for root group
-- 2011/06/21 - Make base dir root readable only for security
-- 2011/06/23 - Set base directory using a fact instead of hardcoding it
-- 2011/06/23 - Support operating as non privileged user
-- 2011/06/23 - Support dash instead of bash or sh
-- 2011/07/11 - Better solaris support
-- 2011/12/05 - Use fully qualified variables
-- 2011/12/13 - Improve Nexenta support
-- 2012/04/11 - Do not use any GNU specific extensions in the shell script
-- 2012/03/24 - Comply to community style guides
-- 2012/05/23 - Better errors when basedir isnt set
-- 2012/05/31 - Add spec tests
-- 2012/07/11 - Include concat::setup in concat improving UX
-- 2012/08/14 - Puppet Lint improvements
-- 2012/08/30 - The target path can be different from the $name
-- 2012/08/30 - More Puppet Lint cleanup
-- 2012/09/04 - RELEASE 0.2.0
-- 2012/12/12 - Added (file) $replace parameter to concat
+++ /dev/null
- Copyright 2012 R.I.Pienaar
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+++ /dev/null
-name 'ripienaar-concat'
-version '0.2.0'
-source 'git://github.com/ripienaar/puppet-concat.git'
-author 'R.I.Pienaar'
-license 'Apache'
-summary 'Concat module'
-description 'Concat module'
-project_page 'http://github.com/ripienaar/puppet-concat'
+++ /dev/null
-What is it?
-===========
-
-A Puppet module that can construct files from fragments.
-
-Please see the comments in the various .pp files for details
-as well as posts on my blog at http://www.devco.net/
-
-Released under the Apache 2.0 licence
-
-Usage:
-------
-
-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
-use code like below, a sample /etc/motd would be:
-
-<pre>
-Puppet modules on this server:
-
- -- Apache
- -- MySQL
-</pre>
-
-Local sysadmins can also append to the file by just editing /etc/motd.local
-their changes will be incorporated into the puppet managed motd.
-
-<pre>
-# class to setup basic motd, include on all nodes
-class motd {
- $motd = "/etc/motd"
-
- concat{$motd:
- owner => root,
- group => root,
- mode => '0644',
- }
-
- 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,
- ensure => "/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
- }
-
- concat::fragment{"motd_fragment_$name":
- target => "/etc/motd",
- content => " -- $body\n"
- }
-}
-
-# a sample apache module
-class apache {
- include apache::install, apache::config, apache::service
-
- motd::register{"Apache": }
-}
-</pre>
-
-Detailed documentation of the class options can be found in the
-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
- 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".
-
-Contributors:
--------------
-**Paul Elliot**
-
- * Provided 0.24.8 support, shell warnings and empty file creation support.
-
-**Chad Netzer**
-
- * Various patches to improve safety of file operations
- * Symlink support
-
-**David Schmitt**
-
- * 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
-
-**Peter Meier**
-
- * Basedir as a fact
- * Unprivileged user support
-
-**Sharif Nassar**
-
- * Solaris/Nexenta support
- * Better error reporting
-
-**Christian G. Warden**
-
- * Style improvements
-
-**Reid Vandewiele**
-
- * Support non GNU systems by default
-
-**Erik Dalén**
-
- * Style improvements
-
-**Gildas Le Nadan**
-
- * Documentation improvements
-
-**Paul Belanger**
-
- * Testing improvements and Travis support
-
-**Branan Purvine-Riley**
-
- * Support Puppet Module Tool better
-
-**Dustin J. Mitchell**
-
- * Always include setup when using the concat define
-
-**Andreas Jaggi**
-
- * Puppet Lint support
-
-**Jan Vansteenkiste**
-
- * Configurable paths
-
-Contact:
---------
-R.I.Pienaar / rip@devco.net / @ripienaar / http://devco.net
+++ /dev/null
-require 'rubygems'
-require 'puppetlabs_spec_helper/rake_tasks'
+++ /dev/null
-#!/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=""
-
-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:f" options; do
- case $options in
- o ) OUTFILE=$OPTARG;;
- d ) WORKDIR=$OPTARG;;
- n ) SORTARG="-n";;
- w ) WARNMSG="$OPTARG";;
- f ) FORCE="true";;
- t ) TEST="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
-find fragments/ -type f -follow | sort ${SORTARG} | while read -r fragfile; do
- cat "$fragfile" >> "fragments.concat"
-done
-
-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
+++ /dev/null
-Facter.add("concat_basedir") do
- setcode do
- File.join(Puppet[:vardir],"concat")
- end
-end
+++ /dev/null
-# 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') {
- $safe_name = regsubst($name, '[/\n]', '_', 'GM')
- $safe_target_name = regsubst($target, '[/\n]', '_', 'GM')
- $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
- }
- }
-
- file{"${fragdir}/fragments/${order}_${safe_name}":
- ensure => $ensure,
- mode => $mode,
- owner => $owner,
- group => $group,
- source => $source,
- content => $content,
- backup => $backup,
- alias => "concat_fragment_${name}",
- notify => Exec["concat_${target}"]
- }
-}
+++ /dev/null
-# 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 => '<virtualhost *:80>',
-# order => 01,
-# }
-#
-# concat::fragment {'apache-vhost-myvhost-close':
-# target => 'apache-vhost-myvhost',
-# content => '</virtualhost>',
-# 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
-# <Puppet[:vardir]>/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 <Puppet[:vardir]>/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 <rip@devco.net>
-# 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
-#
-# 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"]
-define concat(
- $path = $name,
- $owner = $::id,
- $group = $concat::setup::root_group,
- $mode = '0644',
- $warn = false,
- $force = false,
- $backup = 'puppet',
- $replace = true,
- $gnu = undef,
- $order='alpha'
-) {
- 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'
- $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
-
- case $warn {
- 'true', true, yes, on: {
- $warnmsg = $default_warn_message
- }
- 'false', false, no, off: {
- $warnmsg = ''
- }
- default: {
- $warnmsg = $warn
- }
- }
-
- $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", '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}")
- }
- }
-
- case $order {
- numeric: {
- $orderflag = '-n'
- }
- alpha: {
- $orderflag = ''
- }
- default: {
- fail("Improper 'order' value given to concat: ${order}")
- }
- }
-
- File {
- owner => $::id,
- group => $group,
- mode => $mode,
- backup => $backup,
- 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,
- }
-
- file { "${fragdir}/fragments.concat":
- ensure => present,
- }
-
- file { "${fragdir}/${concat_name}":
- ensure => present,
- }
-
- file { $name:
- ensure => present,
- path => $path,
- alias => "concat_${name}",
- group => $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}",
- 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}",
- }
-
- if $::id == 'root' {
- Exec["concat_${name}"] {
- user => root,
- group => $group,
- }
- }
-}
-
-# vim:sw=2:ts=2:expandtab:textwidth=79
+++ /dev/null
-# 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.
-#
-# $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 ? {
- root => 0,
- default => $id
- }
-
- 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'.")
- }
-
- $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;
-
- [ $concatdir, "${concatdir}/bin" ]:
- ensure => directory,
- owner => $id,
- group => $root_group,
- mode => '0750';
-
- ## Old versions of this module used a different path.
- '/usr/local/bin/concatfragments.sh':
- ensure => absent;
- }
-}
+++ /dev/null
-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',
- } }
- let :pre_condition do
- 'include concat::setup'
- end
-
- directories = [
- "#{basedir}/_etc_foo.bar",
- "#{basedir}/_etc_foo.bar/fragments",
- ]
-
- directories.each do |dirs|
- it do
- should contain_file(dirs).with({
- 'ensure' => 'directory',
- 'backup' => 'puppet',
- 'group' => 0,
- 'mode' => '0644',
- 'owner' => 'root',
- })
- end
- end
-
- files = [
- "/etc/foo.bar",
- "#{basedir}/_etc_foo.bar/fragments.concat",
- ]
-
- files.each do |file|
- it do
- should contain_file(file).with({
- 'ensure' => 'present',
- 'backup' => 'puppet',
- 'group' => 0,
- 'mode' => '0644',
- 'owner' => 'root',
- })
- 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',
- } }
- let :pre_condition do
- 'include concat::setup'
- end
-
- 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',
- })
- end
- end
-
- 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',
- })
- 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
-
-
-end
-
-# vim:sw=2:ts=2:expandtab:textwidth=79
+++ /dev/null
-require 'puppetlabs_spec_helper/module_spec_helper'