Permalink
Browse files

RVM + Concat from external sources

  • Loading branch information...
1 parent 236bb58 commit 84d2c3daf170b4347730b1980e8549406cbfb7c2 @alvagante alvagante committed Jul 24, 2012
View
@@ -142,3 +142,9 @@
[submodule "rsync"]
path = rsync
url = https://github.com/example42/puppet-rsync
+[submodule "rvm"]
+ path = rvm
+ url = https://github.com/example42/puppet-rvm
+[submodule "concat"]
+ path = concat
+ url = https://github.com/example42/puppet-concat
1 concat
Submodule concat added at 753ba8
View
@@ -1,28 +0,0 @@
-KNOWN ISSUES:
-- In 0.24.8 you will see inintended notifies, if you build a file
- in a run, the next run will also see it as changed. This is due
- to how 0.24.8 does the purging of unhandled files, this is improved
- in 0.25.x and we cannot work around it in our code.
-
-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
View
@@ -1,103 +0,0 @@
-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 {
- include concat::setup
- $motd = "/etc/motd"
-
- concat{$motd,
- owner => root,
- group => root,
- mode => 644
- }
-
- 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>
-
-Known Issues:
--------------
-* In 0.24.8 you will see inintended notifies, if you build a file
- in a run, the next run will also see it as changed. This is due
- to how 0.24.8 does the purging of unhandled files, this is improved
- in 0.25.x and we cannot work around it in our code.
-
-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
-
-Contact:
---------
-You can contact me on rip@devco.net or follow my blog at http://www.devco.net I am also on twitter as ripienaar
@@ -1,130 +0,0 @@
-#!/bin/bash
-
-# 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
-# -g Do NOT use the GNU entensions to find, xargs and sort; might cause problems on suitably funky filenames
-#
-# 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=""
-SORT1="-z"
-SORT2=""
-FINDARG="-print0"
-XARGSARG="-0"
-
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-
-while getopts "o:s:d:tnw:fg" options; do
- case $options in
- o ) OUTFILE=$OPTARG;;
- d ) WORKDIR=$OPTARG;;
- n ) SORT2="-n";;
- w ) WARNMSG="$OPTARG";;
- f ) FORCE="true";;
- t ) TEST="true";;
- g ) FINDARG="" ; XARGSARG="" ; SORT1="" ;;
- * ) echo "Specify output file with -o and fragments directory with -d"
- exit 1;;
- esac
-done
-
-SORTARG="$SORT1 $SORT2"
-
-# 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 [ -a ${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
- echo -e "$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 $FINDARG |sort ${SORTARG}|xargs $XARGSARG cat >>"fragments.concat"
-
-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
No changes.
@@ -1,51 +0,0 @@
-# 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='', $source='', $order=10, $ensure = "present", $mode = 0644, $owner = root, $group = root, $backup = "puppet") {
- $safe_name = regsubst($name, '/', '_', 'G')
- $safe_target_name = regsubst($target, '/', '_', 'G')
- $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 $content {
- "": {
- case $source {
- "": {
- case $ensure {
- "", "absent", "present", "file", "directory": {
- crit("No content, source or symlink specified")
- }
- }
- }
- default: { File{ source => $source } }
- }
- }
- default: { File{ content => $content } }
- }
-
- file{"${fragdir}/fragments/${order}_${safe_name}":
- mode => $mode,
- owner => $owner,
- group => $group,
- ensure => $ensure,
- backup => $backup,
- alias => "concat_fragment_${name}",
- notify => Exec["concat_${target}"]
- }
-}
-
-# vi:tabstop=4:expandtab:ai
Oops, something went wrong.

0 comments on commit 84d2c3d

Please sign in to comment.