Testing with rspec-puppet and ripienaar/module_data

187 views
Skip to first unread message

Matthew Haughton

unread,
Aug 26, 2014, 1:49:35 PM8/26/14
to puppet...@googlegroups.com
Hi all,

I have a module I'm trying to convert from params.pp to ripienaar/module_data. I've got to the point where I can run Puppet with:

    puppet apply --debug --noop --hiera_config spec/fixtures/hiera/hiera.yaml --modulepath spec/fixtures/modules -e 'include ...'

and can see from the hiera debug messages that module_data is active and is pulling info from the data directory based on the hierarchy specified in data/hiera.yaml. However, in rspec-puppet parameters from module_data aren't getting passed through and I've run out of ideas as to why. Here's the setup that I had hoped would get things going:

spec/fixtures/hiera/hiera.yaml:
---
:backends:
  - module_data


spec/spec_helper.rb:
require 'puppetlabs_spec_helper/module_spec_helper'

RSpec.configure do |c|
  c.hiera_config = File.join('spec', 'fixtures', 'hiera', 'hiera.yaml')
end


.fixtures.yaml:
fixtures:
  symlinks:
    module_name: "#{source_dir}"
  forge_modules:
    module_data: "ripienaar/module_data"


Does anyone have an idea as to why this isn't working? Is this even expected to work like this with rspec-puppet right now? I'm using rspec-puppet 1.0.1, puppetlabs_spec_helper 0.8.1 and Puppet 3.6.2.

Thanks in advance for any help!

Matthew Haughton

unread,
Aug 27, 2014, 4:53:39 PM8/27/14
to puppet...@googlegroups.com

I worked it out - here's the solution for anyone who might stumble across this:

In spec/spec_helper.rb:

require 'fixtures/modules/module_data/lib/hiera/backend/module_data_backend.rb'
RSpec.configure do |c|
  c.hiera_config = File.join('spec', 'fixtures', 'hiera', 'hiera.yaml')
end


In spec/fixtures/hiera/hiera.yaml:

---
:backends:
  - module_data

And make sure the module is installed to the path fixtures/modules/module_data, or if not then adjust accordingly.

Felix Frank

unread,
Aug 28, 2014, 4:17:39 AM8/28/14
to puppet...@googlegroups.com
On 08/27/2014 10:53 PM, Matthew Haughton wrote:
> I worked it out - here's the solution for anyone who might stumble
> across this:
>
> In |spec/spec_helper.rb|:
>
> require 'fixtures/modules/module_data/lib/hiera/backend/module_data_backend.rb'
> RSpec.configure do |c|
> c.hiera_config = File.join('spec', 'fixtures', 'hiera', 'hiera.yaml')
> end
>
>
> In |spec/fixtures/hiera/hiera.yaml|:
>
> ---
> :backends:
> - module_data

That's really useful advice. Thanks for sharing!

Cheers,
Felix
Reply all
Reply to author
Forward
0 new messages