Ask Your Question

how to use hiera_hash in rspec-puppet

asked 2015-08-17 06:19:11 -0600

Chutki gravatar image


I have below manifests

class test::filesystem {

  $tempx = hiera_hash('test::test_fs')
  create_resources('lvm::lvm_fs', $tempx)    #passing test_fs values to lvm module define

below is my rspec file

let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' }
  hiera ={ :config => 'spec/fixtures/hiera/hiera.yaml' })

  abc = hiera.lookup('test::test_fs',nil,nil)

  let(:hiera_data) {{
    :'test::test_fs'=> abc

but I don't know how to add this "lvm::lvm_fs" since its referring different module manifests

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-17 15:16:02 -0600

cbarbour gravatar image

updated 2015-08-17 15:20:08 -0600

The 4th parameter to hiera.lookup specifies the lookup type.

abc = hiera.lookup('test::test_fs',nil,nil,:hash) will do what you want.

With that said, the hiera lookup usually belongs in your profiles, rather than in your modules. Consider moving the lookup logic to your roles/profiles, and testing using a simple resource parameter. If that isn't an option, move the hiera lookup call to your module parameters, but be cautious; automatic parameter lookups use priority mode lookups and win over default values.

edit flag offensive delete link more


I can't move hiera lookup to my own module parameters in this case because I written filesystem manifests under "lvm::lvm_fs" module so I am calling this in "test::filesystem" manifests. Also not getting "abc = lookup('test::test_fs',nil,nil,:hash" do you know any url for this to understand better.

Chutki gravatar imageChutki ( 2015-08-18 07:21:15 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-17 06:19:11 -0600

Seen: 361 times

Last updated: Aug 17 '15