Version information
Start using this module
Add this module to your Puppetfile:
mod 'anselm-concatfile', '0.0.4'
Learn more about managing modules with a PuppetfileDocumentation
puppet-concatfile
Description
A very simple Puppet module that concatenates multiple text parts together to one file. The single parts can be file sources, string content or existing files on the target system.
Dependencies
- Core utilities: find, sort, xargs
- dirname function, e.g. as provided by http://github.com/puzzle/puppet-common
- Tested on Puppet 0.25.4
Usage
First, define the file that should be concatenated from the parts:
The dir parameter specifies in which folder the parts are collected.
Then, define some parts:
The directory in the resource name of each part must match the dir parameter used in the concatfile resource, that is how Puppet knows they are connected. The files will later be sorted numerically and concatenated in that order.
The result is that the file /etc/sysctl.conf is concatenated from the 3 files in /etc/sysctl.conf.d/. Their content comes from 3 different possible sources: a Puppet files resource, a string and a symlink to a local file.
Details
Behavior
Each part is deployed as file in the specified folder. A simple exec command in the form of find ... | sort ... | cat ... > target_file is then used to concatenate all parts together. Apart from the basic update behavior from Puppet when any file is removed/modified, or any definition in the code is added/modified/removed, an update should also be triggered when a alien file is placed in the folder where the parts are stored, and the file gets removed.
Parameters
Possible parameters to concatfile are:
- dir (required)
- owner
- group
- mode
Possible parameters to concatfile::part are:
- source
- content
- file
- owner
- group
- mode
Only one of source, content or file makes sense and is allowed.
Extending
The defines can easily be wrapped to save some typing or e.g. introduce an order parameter:
Todo
- Triggering the update when the concatenated file is modified was not tested (did not have a puppet master around, and remembering checksums does not work completely with Puppet in standalone mode).
Written By
Anselm Strauss http://github.com/amsibamsi
Dependencies
- DavidSchmitt/common (1.0.0)