As I discussed on Thursday, I am looking to re-architect the layout of my controlrepo’s rspec tests. Of course, there were yaks to shave, first. To that end, I’ve released version 0.10.0 of generate-puppetfile
(rubygem, github project) with the added ability to run generate-puppetfile --create-fixtures
at the top of your controlrepo and generate a .fixtures.yml
that will set up symlinks for all of the modules contained in your controlrepo. This functionality is based off the existence of the file environment.conf
in the current directory and it containing a modulepath
stanza. All the paths in the modulepath
are explored and symlink-type fixtures created for each module found. Previous functionality when run inside a module directory is still preserved, of course.
Because the project has not reached version 1.0.0 yet, I have renamed the option --fixtures
to --create-fixtures
. This is in preparation for a feature request for an --only-fixtures
feature request.
Let’s look at how to use this new feature. Before we start, we must be at the top level of the controlrepo. Next, we need environment.conf
to have a modulepath
stanza. In my controlrepo, the file looks like this:
$ cat environment.conf modulepath = dist:modules:$basemodulepath $ tree -L 1 dist dist ├── profile └── role 2 directories, 0 files $ tree -L 1 modules modules [error opening dir] 0 directories, 0 files
We can now run generate-puppetfile
to update the Puppetfile
and fixtures file:
$ be generate-puppetfile -p Puppetfile -c --create-fixtures Installing modules. This may take a few minutes. Your Puppetfile has been generated. Copy and paste between the markers: ======================================================================= ... <Puppetfile content> ... ======================================================================= Generating .fixtures.yml using module name profile Generating .fixtures.yml for a controlrepo.
(Yes, there’s a little output cleanup to be done in the next version!) When complete, we can see the top of the fixtures file has symlinks for the role and profile modules:
$ head -5 .fixtures.yml fixtures: symlinks: role: "#{source_dir}/dist/role" profile: "#{source_dir}/dist/profile" forge_modules:
If we run rake spec_prep
we can be sure that the modules are “installed” properly in the spec environment:
$ be rake spec_prep ... <tons of output from forge module installations> ... $ puppet module list --modulepath spec/fixtures/modules | egrep "(role|profile)" ├── rnelson0-profile (v0.1.0) ├── rnelson0-role (v0.1.0)
With this feature in place, you can now use generate-puppetfile
in conjunction with spec tests at the top of your controlrepo instead of in the module directories. Enjoy!
One thought on “Release 0.10.0 of generate-puppetfile”