| 1 |
require 'spec_helper_acceptance' |
| 2 |
|
| 3 |
describe 'basic libvirtd_config resource' do |
| 4 |
|
| 5 |
context 'default parameters' do |
| 6 |
|
| 7 |
it 'should work with no errors' do |
| 8 |
pp= <<-EOS |
| 9 |
Exec { logoutput => 'on_failure' } |
| 10 |
|
| 11 |
File <||> -> Libvirtd_config <||> |
| 12 |
File <||> -> Virtlogd_config <||> |
| 13 |
File <||> -> Virtlockd_config <||> |
| 14 |
File <||> -> Virtnodedevd_config <||> |
| 15 |
File <||> -> Virtproxyd_config <||> |
| 16 |
File <||> -> Virtqemud_config <||> |
| 17 |
File <||> -> Virtsecretd_config <||> |
| 18 |
File <||> -> Virtstoraged_config <||> |
| 19 |
File <||> -> Qemu_config <||> |
| 20 |
|
| 21 |
file { '/etc/libvirt' : |
| 22 |
ensure => directory, |
| 23 |
} |
| 24 |
|
| 25 |
[ |
| 26 |
'libvirtd', 'virtlogd', 'virtlockd', 'virtnodedevd', 'virtproxyd', |
| 27 |
'virtqemud', 'virtsecretd', 'virtstoraged', 'qemu' |
| 28 |
].each | String $daemon | { |
| 29 |
|
| 30 |
file { "/etc/libvirt/${daemon}.conf" : |
| 31 |
ensure => file, |
| 32 |
} |
| 33 |
|
| 34 |
create_resources("${daemon}_config", { |
| 35 |
'thisshouldexist' => { |
| 36 |
'value' => 1, |
| 37 |
}, |
| 38 |
'thisshouldnotexist' => { |
| 39 |
'value' => '<SERVICE DEFAULT>' |
| 40 |
}, |
| 41 |
'thisshouldexist2' => { |
| 42 |
'value' => '<SERVICE DEFAULT>', |
| 43 |
'ensure_absent_val' => 'toto', |
| 44 |
'quote' => true |
| 45 |
}, |
| 46 |
'thisshouldnotexist2' => { |
| 47 |
'value' => 'toto', |
| 48 |
'ensure_absent_val' => 'toto' |
| 49 |
}, |
| 50 |
'thisshouldexist3' => { |
| 51 |
'value' => 'foo', |
| 52 |
'quote' => true |
| 53 |
}, |
| 54 |
'thisshouldnotexist3' => { |
| 55 |
'value' => '<SERVICE DEFAULT>', |
| 56 |
'quote' => true |
| 57 |
}, |
| 58 |
}) |
| 59 |
} |
| 60 |
EOS |
| 61 |
|
| 62 |
# Run it twice and test for idempotency |
| 63 |
apply_manifest(pp, :catch_failures => true) |
| 64 |
apply_manifest(pp, :catch_changes => true) |
| 65 |
end |
| 66 |
|
| 67 |
[ |
| 68 |
'libvirtd', 'virtlogd', 'virtlockd', 'virtnodedevd', 'virtproxyd', |
| 69 |
'virtqemud', 'virtsecretd', 'virtstoraged', 'qemu' |
| 70 |
].each do | daemon | |
| 71 |
describe file("/etc/libvirt/#{daemon}.conf") do |
| 72 |
it { is_expected.to exist } |
| 73 |
it { is_expected.to contain('thisshouldexist=1') } |
| 74 |
it { is_expected.to contain('thisshouldexist2="<SERVICE DEFAULT>"') } |
| 75 |
it { is_expected.to contain('thisshouldexist3="foo"') } |
| 76 |
|
| 77 |
describe '#content' do |
| 78 |
subject { super().content } |
| 79 |
it { is_expected.to_not match /thisshouldnotexist/ } |
| 80 |
end |
| 81 |
end |
| 82 |
end |
| 83 |
end |
| 84 |
end |