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 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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. On Aug 3, 12:22 pm, Patrick Mohr <kc7...@gmail.com> wrote:> 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.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>> > 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. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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). On Aug 3, 9:20 pm, Jon Wilson <jon-goo...@phuq.co.uk> wrote:> 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. > > On Aug 3, 12:22 pm, Patrick Mohr <kc7...@gmail.com> wrote: > > > 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.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Tue, Aug 3, 2010 at 7:38 PM, Jon Wilson <jon-google@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.> > 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). > > On Aug 3, 9:20 pm, Jon Wilson <jon-goo...@phuq.co.uk> wrote: >> 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. >> >> On Aug 3, 12:22 pm, Patrick Mohr <kc7...@gmail.com> wrote: >> >> > 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. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >-- nigel -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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 On Tue, Aug 3, 2010 at 8:50 AM, Jon Wilson <jon-google@phuq.co.uk> 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. > > 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 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.