Have some stuck with using variable in rspec. Here is my params.pp
case $::osfamily{
Debian: {
$ssh_daemon = "ssh"
}
Redhat: {
$ssh_daemon = "sshd"
}
In an rspec test I need to use the 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 can I write this variable ($ssh_daemon) to get this test to work?
You can do this by mocking Facter output.
Something like: