generating catalog files

378 views
Skip to first unread message

Jon Wilson

unread,
Aug 2, 2010, 8:50:11 PM8/2/10
to Puppet Users
Hiya,

Is there a way I can easily generate the catalog for a particular
puppet client, without actually running Puppet on that client?

I'd like to write some unit tests for my Puppet master, which generate
catalogs for a set of clients, and check their content. This will
syntax & sanity check my manifests, without getting stuck in
certificate hell.

My current issues:

1) I can't see any obvious command line options that will do this for
me
2) The facter output from the client will not be available, and may
need to be faked or simulated somehow

My environment is Centos 5 Linux, Puppet 0.25.4, Facter 1.5.7, Ruby
1.8.5.

Thanks,

Jon

Patrick Mohr

unread,
Aug 2, 2010, 10:22:46 PM8/2/10
to puppet...@googlegroups.com

On Aug 2, 2010, at 5:50 PM, Jon Wilson wrote:

Hiya,

Is there a way I can easily generate the catalog for a particular
puppet client, without actually running Puppet on that client?

I'd like to write some unit tests for my Puppet master, which generate
catalogs for a set of clients, and check their content. This will
syntax & sanity check my manifests, without getting stuck in
certificate hell.

Here's a command to get you started:
puppetmasterd --compile clients.fqdn

I'm not sure how, but some magic is being done to get the client's facts.  I'm assuming the facts are cached from an earlier run, but this is pure speculation.

If you run it with --verbose, it will send that information to stderr.

To make the tests much shorter on failure, you probably want to test the erb using "erb -x -P -T '-' $1 | ruby -c " and test the config using --parseonly.


Warning: when the catalog is compiled, everything* that would normally be done with storeconfigs will be done.  This means running tests like this can affect your existing configuration.

*I'm not actually sure it does everything, but it does most of the storeconfigs stuff.

Jon Wilson

unread,
Aug 3, 2010, 7:20:11 AM8/3/10
to Puppet Users
Thanks Patrick, I'll give that a try.

I'm not too worried about breaking existing configuration, or cached
facts. Everything will be running in a sandbox, which will be clean
prior to every test run.

Richard Crowley

unread,
Aug 3, 2010, 11:24:17 AM8/3/10
to puppet...@googlegroups.com
>> > Is there a way I can easily generate the catalog for a particular
>> > puppet client, without actually running Puppet on that client?

`puppet agent --noop` might be just the ticket. You'll run that
command on the client, so this may be non-starter, but it won't
actually do anything.

Jon Wilson

unread,
Aug 3, 2010, 10:38:49 PM8/3/10
to Puppet Users
OK, some success. I get some unformatted output, PSON I think. I'm
pretty sure it just takes the node definition as input (cached if
available) and merely compiles my classes. I don't think facts get
involved, because that's part of the instantiation phase (see
http://projects.puppetlabs.com/projects/1/wiki/Puppet_Internals).

That will be sufficient for unit tests that catch compile-time
manifest errors. I'll have to work a little harder to get more usable
output (Yaml?), or to write any tests that use facts (real, cached or
faked).

Nigel Kersten

unread,
Aug 3, 2010, 10:47:45 PM8/3/10
to puppet...@googlegroups.com
On Tue, Aug 3, 2010 at 7:38 PM, Jon Wilson <jon-g...@phuq.co.uk> wrote:
> OK, some success. I get some unformatted output, PSON I think. I'm
> pretty sure it just takes the node definition as input (cached if
> available) and merely compiles my classes. I don't think facts get
> involved, because that's part of the instantiation phase (see
> http://projects.puppetlabs.com/projects/1/wiki/Puppet_Internals).

Facts are required to compile the manifests into a catalog.

> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>

--
nigel

Ohad Levy

unread,
Aug 4, 2010, 1:51:41 PM8/4/10
to puppet...@googlegroups.com
a while ago I wrote manitest - http://github.com/ohadlevy/manitest

another option is to use Brice puppet-load tool (didnt try it myself).

Ohad

Reply all
Reply to author
Forward
0 new messages