James, As you have discovered, the setup you want is not quite documented the way or in the locations you would expect, but it is documented in many places, such as https://puppet.com/blog/unit-testing-rspec-puppet-for-beginners and https://puppet.com/blog/use-onceover-start-testing-rspec-puppet.
IMO, what you really want to do is integrate tests with your version-controlled code, in-place, rather than replicating it somewhere else. You can do this by using ruby's bundler and a Gemfile to get started, then add a spec/spec_helper.rb and spec/classes/*_spec.rb files for unit tests and so on and so forth. But, you don't actually need puppet installed, as that can come from a gem in the bundler setup. There's a lot to do and many ways to do it, so there's no single solution to choose. I've written a lot about my explorations with rspec on my blog ( https://rnelson0.com/?s=rspec) but here's how I would start. Use puppet-module-skeleton (https://github.com/garethr/puppet-module-skeleton) which creates a new module with rspec tests. It is designed for a module rather than a controlrepo, so will take a little re-working to align it properly for that ( https://rnelson0.com/2015/11/24/modern-rspec-puppet-practices/ and optionally https://rnelson0.com/2016/11/06/puppet-tech-debt-moving-rspec-tests/), but is pretty good for both. Once you get it all working, you commit the changes to your module/controlrepo and then it's bundled with your puppet code, and thus always available for testing. It does mean the tests are deployed on your master, but aside from a little extra disk space, it will have no impact on agents connecting and should not be a concern. It's also portable for when you get a vagrant or docker setup going. With the bundler/rspec framework in place, your workflow becomes: * Clone your controlrepo * Checkout a feature branch for changes * Run `bundle install` with appropriate args (I use `bundle install --path vendor --without system_tests development` most of the time) * Run `bundle exec rake test` to run all the tests (the target `spec`, or the pair `spec_prep` and `spec_clean` will JUST run your unit tests), everything should pass * Make all the edits you need * Run `bundle exec rake test` and ensure the tests continue to pass. If not, repeat the previous step until tests do pass. * Commit your code, push to upstream There are plenty of examples of control repos out there but not all have a working test setup included. Check out these two that show the example: * https://github.com/example42/psick * https://github.com/puppetinabox/controlrepo I hope this helps! Rob Nelson [email protected] On Tue, Jul 18, 2017 at 7:51 PM, James Perry <[email protected]> wrote: > Years ago there were a lot of docs about how to setup Puppet to allow > someone to build modules outside having to have a master/client setup using > puppet apply. > > I am trying to figure out the very cryptic world of spec/rspec, as it > seems to not be documented very well anywhere for anyone other than someone > that already knows it, In doing so I don't want to be able to develop in my > home directory in a server versus having to develop modules and test with > rspec against a full puppet server configuration. > > So far I have found little bits and pieces around, but nothing definitive > or documented well for building something of this nature. The best I found > so far were pre-built Ubuntu Docker containers or Vagrant builds. I don't > have access to either presently or the time to build out a server to handle > hosting either. > > Does anyone have a guide to setting up a stand-alone puppet client for > development. There used to be a rspec-puppet.com/setup page and that is > what is linked from inside the documentation, but the page is gone. > > What I have so far is: > > 1. .Install puppet-agent to the host as root. > 2. Setup paths to use the Ruby configuration from the puppet-agent so that > the any gem add-ons are compatible with the version of the puppet-agent > RPM. > 3. Install puppetlabs-stdlib, rspec-puppet and any dependencies they > require. > > When I have done a puppet module generate <name> and a rspec-puppet-init, > I create a basic test to ensure the module compiles, as noted on the > rspec-puppet Github page https://github.com/rodjek/rspec-puppet, That > fails saying it can find compile. > > describe 'mymodule' do > it { is_expected.to compile } > end > > Any other tests that "should" work don't. either. > > So in modules/test/manifests/init.pp I have: > class test { > package { 'somepackage': > ensure => present, > } > } > > And my modules/test/spec/class/init_spec.rb has > > require 'spec_helper' > > describe 'test' do > it { is_expected.to contain('somepackage').with_ensure('present') > end > > So since this seems to be non-functional in my puppet development > environment, which is a copy of my prod, I want to set it up fresh. When I > tried in my home directory all i got were errors. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/puppet-dev/23805142-d49e-4612-9590-472ab581dade%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-dev/23805142-d49e-4612-9590-472ab581dade%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CAC76iT_HvrpB_H%3DYB-4_nbzLQw4deZ3Sw%2BtS%3DSHjOx9t1jPBQw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
