rspec-puppet require syntax

243 views
Skip to first unread message

Guy Knights

unread,
Sep 17, 2013, 1:05:26 PM9/17/13
to puppet...@googlegroups.com
Can someone tell me the correct way to specify the following require statement in an rspec-puppet test?

require => [Class['ssl'],Class['pcre3'],Staging::Extract["nginx-${version}.tar.gz"]]

I tried this: 'require' => "[Class['ssl'],Class['pcre3'],Staging::Extract['nginx-1.4.1.tar.gz']]" but got the following error:

Failure/Error: )
expected that the catalogue would contain Exec[install_nginx] with require set to `"[Class['ssl'],Class['pcre3'],Staging::Extract['nginx-1.4.1.tar.gz']]"` but it is set to `[Class[Ssl]{:name=>"Ssl"}, Class[Pcre3]{:name=>"Pcre3"}, Staging::Extract[nginx-1.4.1.tar.gz]{:name=>"nginx-1.4.1.tar.gz"}]` in the catalogue

I've tried every combination of different quotes, removing the inner quotes, capitalising the resource titles, and even just copying and pasting what the error above says the catalogue is reporting, but it just doesn't work. I thought I had the syntax for requires figured out, but apparently not.

Thanks,
Guy

Guy Knights

unread,
Sep 19, 2013, 1:40:09 PM9/19/13
to puppet...@googlegroups.com
Does anyone have any feedback on this? I found at least one example (eg. https://genuxation.com/wiki/index.php/RSpec_tests_for_puppet_modules#Specifying_parameters_used_within_the_class) but it didn't work for me.

Thanks,
Guy

Corey Osman

unread,
Sep 20, 2013, 12:11:24 AM9/20/13
to puppet...@googlegroups.com
Have you tried:

"Class[ssl],Class[pcre3],Staging::Extract[nginx-1.4.1.tar.gz]"

or

"Class[ssl],Class[pcre3],Staging__Extract[nginx-1.4.1.tar.gz]"


Corey

Dan Bode

unread,
Sep 20, 2013, 1:12:34 AM9/20/13
to public puppet users
I'm pretty sure the error is b/c the class names need to be capitalized.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Guy Knights

unread,
Sep 20, 2013, 7:52:34 PM9/20/13
to puppet...@googlegroups.com
No such luck. I all the above suggestions (capitalising class names, removing inner quotes) with another require:

  file { 'set_nginx_dir_permissions':
    ensure  => directory,
    path    => "/opt/nginx-${version}",
    owner   => nginx,
    group   => nginx,
    mode    => '0644',
    require => [User['nginx'],Exec['install_nginx']],
  }

 but it says the catalogue is set to [User[nginx]{:name=>"nginx"}, Exec[install_nginx]{:command=>"install_nginx"}], which is what I was getting with the other require.

Johan De Wit

unread,
Oct 2, 2013, 7:45:01 AM10/2/13
to puppet...@googlegroups.com
When 'require' multiple resources, you should copy what the catalog contains :

  'require' => '[User[nginx]{:name=>"nginx"}, Exec[install_nginx]{:command=>"install_nginx"}]',

in the rspec file.  Thats the only way i could make it pass the test.

Grts

jo

Mikhail Simin

unread,
Dec 18, 2013, 7:45:11 PM12/18/13
to puppet...@googlegroups.com
This syntax works for me:

  'require' => [
    'User[nginx]',
    'Exec[install_nginx]']

Gavin Williams

unread,
Dec 19, 2013, 4:44:12 AM12/19/13
to puppet...@googlegroups.com
Yeh, the quoting of the resource is key I found... Need to quote the entire resource, rather than the resource title...

Gav
Reply all
Reply to author
Forward
0 new messages