Puppetfiler
Gem for miscellaneous actions based on Puppetfiles.
Installation
gem install puppetfiler
gem 'puppetfiler'
Usage
A puppetfile can be specified via -p path/to/pf
or --puppetfile path/to/pf
,
a metadata file via -m path/to/metadata.json
or --metadata
path/to/metadata.json
.
If neither are specified puppetfiler
will check for a file named
Puppetfile
in the current working directory first, then for a file
named metadata.json
.
check
Check puppet forge for newer versions of used forge modules. For Puppetfiles the currently set version on newest on the forge are compared. For metadata.json puppetfiler checks that the newest version on the forge is covered by the range constraint.
$ puppetfiler check
module current newest
puppetlabs/stdlib 4.13.1 4.15.0
puppetlabs/firewall 1.8.1 1.8.2
Be aware that the check command may take a while, since each module has to be queried from the forge.
fixture
Create puppetlabs_spec_helper compatible .fixtures.yml
.
$ puppetfiler fixture
$ cat .fixtures.yml
---
fixtures:
forge_modules:
stdlib:
repo: puppetlabs/stdlib
ref: 4.13.1
firewall:
repo: puppetlabs/firewall
ref: 1.8.1
Gerating .fixture.yml when executing rake tasks
Without modifying the result:
require 'puppetfiler/rake_tasks'
Which adds the task fixture
, which is equivalent to runnning
puppetfiler fixture
.
With modifying the result:
require 'puppetfiler'
desc 'Generate .fixtures.yml'
task :fixture do
modifier = {
'forge_modules' => {
/.*/ => {
'flags' => '--module_repository https://inhouse.forge.lan/',
},
},
}
Puppetfiler.fixture(modifier)
end
task :spec => [:fixtures]
task :test do
[:metadata_lint, :lint, :validate, :spec].each do |test|
Rake::Task[test].invoke
end
end
Allowed keys in the passed modifiers are 'forge_modules' and 'repositories', which are hashes with strings or regular expressions as keys and hashes or strings as values.
Also see the rspec test takes a hash with pattern matches and returns
fixtures as a hash
in spec/puppetfiler/puppetfile_spec.rb
.