Permalink
Browse files

A couple of scripts to test modules.

Untried, so far.
  • Loading branch information...
1 parent 0555548 commit 0df062178a517f590630fb7a3009ee51978273f0 Jeffrey S. Haemer committed Mar 27, 2012
Showing with 44 additions and 0 deletions.
  1. +25 −0 puppet-lint-check
  2. +19 −0 testrun
View
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+####### from http://vstone.eu/puppet-modules-in-jenkins
+#
+for file in $(find . -iname '*.pp'); do
+ puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
+done;
+
+####### and this
+find . -iname *.pp -exec puppet-lint --log-format "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" {} \;
+
+####### and this
+
+## Cleanup old docs.
+[ -d doc/ ] && rm -rf doc/
+## Dummy manifests folder.
+! [ -d manifests/ ] && mkdir manifests/
+## Generate docs
+puppet doc --mode rdoc --manifestdir manifests/ --modulepath ./modules/ --outputdir doc
+
+## Fix docs to how I want them, I don't like that the complete workspace is included in all file paths.
+if [ -d ${WORKSPACE}/doc/files/${WORKSPACE}/modules ]; then
+ mv -v "${WORKSPACE}/doc/files/${WORKSPACE}/modules" "${WORKSPACE}/doc/files/modules"
+fi;
+grep -l -R ${WORKSPACE} * | while read fname; do sed -i "s@${WORKSPACE}/@/@g" $fname; done;
View
@@ -0,0 +1,19 @@
+#!/bin/bash -eu
+# How to test?
+
+die() { echo $* >&2; exit 1; }
+
+usage="$(basename $0) <puppetfile>.pp"
+[ $* = 1 ] || die $usage
+
+puppetrepo=/git/puppet
+[ $(git config --get remote.origin.url) = "$puppetrepo" ] ||
+ die "not in the standard puppet repo"
+
+if [ ${PWD##*/} = "modules" ]; then
+ modulepath=$PWD
+else
+ die "$PWD not a modules directory"
+fi
+
+puppet apply --modulepath=$modulepath -v --debug --test --noop $1

0 comments on commit 0df0621

Please sign in to comment.