Ask Your Question

Using external variable in rspec-puppet test

asked 2015-06-20 05:05:21 -0600

andrey gravatar image

Have some stuck with using variable in rspec. Here is my params.pp

case $::osfamily{
        Debian: {
                $ssh_daemon = "ssh"
        Redhat: {
                $ssh_daemon = "sshd"

In rspec test i need to use variable $ssh_daemon, like this

it { should contain_service("${ssh_daemon}").with(
                :ensure => 'running',
                :enable => 'true',

Here is my ssh.pp file

service { "${ssh_daemon}":
                ensure => running,
                enable => true,

How i can write this varible (ssh_daemon) to get this test work ? My output for now :

ssh should contain Service[${ssh_daemon}] with ensure => "running" and enable => "true"
edit retag flag offensive close merge delete


I don't think you can add external variable in your rspec-puppet. you will have to maually evaluate your ruby.

Chutki gravatar imageChutki ( 2015-06-22 09:29:22 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-24 00:45:04 -0600

GregLarkin gravatar image

I wonder if this mailing list posting would give you some ideas about how to do what you're asking:!msg/puppet-users/N23qzboEK0U/EXJmZ2g9ErsJ

edit flag offensive delete link more

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-06-20 05:05:21 -0600

Seen: 757 times

Last updated: Jun 24 '15