Ask Your Question
0

rspec-puppet Exec[] resource path setup

asked 2015-06-08 11:00:09 -0600

Felix Lam gravatar image

Hi,

I am trying to use rspec-puppet to perform some testing on the custom modules. However, I'm hitting a tough problem in managing the Path attribute in the Exec resources.

Whilst in real puppet run, I can define the Global Exec.Path attribute at site.pp file such that I can basically ignore all the path attribute at each Exec resource declaration, I found no way to simulate that global exec path when using rspec-puppet to unit-test my module.

rspec-puppet will throw error like error during compilation: Validation of Exec[xxxxx] failed: '<command to="" be="" executed="">' is not qualified and no path was specified

It's really frustrating.. is it a limitation of rspec-puppet ? how can I workaround that easily such that I can unit test my puppet class easily ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-06-10 15:04:51 -0600

cbarbour gravatar image

updated 2015-06-10 15:05:10 -0600

rspec puppet allows you to provide a manifest to use when testing your module. You should be able to specify your default parameters there. The feature isn't well documented, so here's an example:

https://github.com/puppetlabs/puppet/...

You could probably define a variable containing the manifest using a HERE document, and pass that variable to the let statement.

As an aside, I advise against using resource defaults the way you are. The approach of specifying a site-wide default path violates the separation of concerns. As you've seen, your module now depends on a default set well outside the scope of the module. This will create maintenance problems in the long run, with very little practical benefit in the short run.

edit flag offensive delete link more

Comments

Thanks CBarbour. However, I tried to add "let(:manifest) { "Exec { path => ['/'] }" }", but still hit the same error. Anything I've missed ?

Felix Lam gravatar imageFelix Lam ( 2015-06-11 00:51:37 -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

Stats

Asked: 2015-06-08 11:00:09 -0600

Seen: 555 times

Last updated: Jun 10 '15