ruby - Using external variable in rspec-puppet test -
have stuck using variable in rspec. here params.pp
case $::osfamily{ debian: { $ssh_daemon = "ssh" } redhat: { $ssh_daemon = "sshd" }
in rspec test need use variable $ssh_daemon this:
it { should contain_service("${ssh_daemon}").with( :ensure => 'running', :enable => 'true', )}
here ssh.pp file
service { "${ssh_daemon}": ensure => running, enable => true, }
how can write variable ($ssh_daemon) test work?
you can mocking facter output.
something like:
context 'service on debian' let(:facts) { { :osfamily => 'debian' } } { should contain_service("ssh") } end context 'service on redhat' let(:facts) { { :osfamily => 'redhat' } } { should contain_service("sshd") } end
Comments
Post a Comment