russell.fulton
2010-Nov-22 23:21 UTC
[Puppet Users] best way to test snippets of puppet config
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 :) hmmm... setting up a node called ''test'' and invoking puppetd --test -- fqdn test ??? I have also often wanted to "drop in some diagnostic writes" to find out what the value of variables are without having to use erb and peer at the generated files. Anyone have tips on this stuff? Thanks Russell PS. yes, I know puppet is a configuration management system *not* a programming language :) -- 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.
R.I.Pienaar
2010-Nov-22 23:26 UTC
Re: [Puppet Users] best way to test snippets of puppet config
hello, ----- 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 -- 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.
Craig Miskell
2010-Nov-22 23:45 UTC
Re: [Puppet Users] best way to test snippets of puppet config
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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----- -- 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.
donavan
2010-Nov-23 08:26 UTC
[Puppet Users] Re: best way to test snippets of puppet config
On Nov 22, 3:21 pm, "russell.fulton" <russell.ful...@gmail.com> 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 suggest taking a look at ''cucumber-puppet''[1]. I''m primarily using it to test catalog compilation, but you can inspect individual resources as well. RI also has some great tools to testing and comparing[2] catalogs. You can compare changes before you actually apply to ''new'' catalog to the clients. [1] http://projects.puppetlabs.com/projects/cucumber-puppet [2] https://github.com/ripienaar/puppet-catalog-diff -- 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 Kersten
2010-Nov-23 16:08 UTC
Re: [Puppet Users] Re: best way to test snippets of puppet config
On Tue, Nov 23, 2010 at 12:26 AM, donavan <donavan@desinc.net> wrote:> On Nov 22, 3:21 pm, "russell.fulton" <russell.ful...@gmail.com> 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 suggest taking a look at ''cucumber-puppet''[1]. I''m primarily using > it to test catalog compilation, but you can inspect individual > resources as well. > RI also has some great tools to testing and comparing[2] catalogs. You > can compare changes before you actually apply to ''new'' catalog to the > clients.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. -- 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.