----- Original Message -----
> Over the last few weeks I have several times felt the need to test out
> some small snippets of puppet code without having to have them in my
> live system.
I've blogged a number of techniques at http://www.devco.net/archives/2009/08/19/tips_and_tricks_for_puppet_debugging.php
russell.fulton wrote:
> Over the last few weeks I have several times felt the need to test out
> some small snippets of puppet code without having to have them in my
> live system.
>
> At the moment I am doing all my testing by fiddling with file on the
> puppet master and then invoking puppet on one of the clients. There
> must be a better way :)
I've got a test compile script which runs over all our hosts and ensures that
the manifests compile for each. I run this before committing to version control
(will eventually run this as a pre-commit hook). The command for a single host
looks something like:
/usr/sbin/puppetmasterd --vardir=./vartmp/ --confdir=. --ssldir=./vartmp/ssl
- --config=./puppet-testconfigs.conf --compile $hostname
Note that I have to have a local "vartmp" directory to be able to write to as a
non-root user. You can either check the output (redirect it?) or check the exit
code. If the latter is not 0, then the compile failed.
The good thing is, with this, you can run it as a non-root user (safe), and it's
not actually being applied anywhere (excellent if you make some mistakes).
- --
Craig Miskell
Senior Systems Administrator
Opus International Consultants
Phone: +64 4 471 7209
Computer games don't affect kids. I mean, if Pac Man had affected us as
kids, now we'd all be running around in darkened rooms, bumping into
people, munching pills and listening to repetitive electronic music.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkzrAJsACgkQmDveRtxWqnZmugCaAmR4egKZFfC5WqIQCi5hhjB5
eBkAnjSqQDnJYMztF6C/tOFkmCOS9Eeg
=q7OS
-----END PGP SIGNATURE-----
I've always found it immensely useful to just use standalone puppet
manifests (in modules or otherwise) with the ability to set variables
by using FACTER_* environment variables.
FACTER_somevariable="somevalue" puppet apply -v /tmp/test.pp
You can get an awful lot of testing done really quickly like this.
FACTER_somevariable gets exposed as $somevariable in the manifests.
I'm pretty sure RI has covered this in his posts, but it's how I
generally do the first stage of testing, the "does this actually work
like this?" stage.