|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
| 3 | +shared_examples 'agent examples' do |
| 4 | + it { should contain_class('puppet::package') } |
| 5 | + it { should contain_class('puppet::agent') } |
| 6 | + it { should compile.with_all_deps } |
| 7 | + it { should contain_ini_setting('report_server').with_value('puppet_reports.example.com') } |
| 8 | + it { should contain_ini_setting('server').with_value('puppet.example.com') } |
| 9 | + it { should contain_ini_setting('pluginsync').with_value(true) } |
| 10 | + it { should contain_package('puppet') } |
| 11 | +end |
| 12 | + |
3 | 13 | describe 'puppet::agent' do |
4 | 14 | describe "sample agent configuration from documentation" do |
5 | 15 | let(:params) {{ |
|
19 | 29 | :lsbdistid => operatingsystem, |
20 | 30 | :lsbdistcodename => 'lolwut' |
21 | 31 | }} |
22 | | - |
23 | | - it { should contain_class('puppet::package') } |
24 | | - it { should contain_class('puppet::agent') } |
25 | | - |
26 | | - it { should compile.with_all_deps } |
27 | | - it { should contain_ini_setting('report_server').with_value('puppet_reports.example.com') } |
28 | | - it { should contain_ini_setting('server').with_value('puppet.example.com') } |
29 | | - it { should contain_ini_setting('pluginsync').with_value(true) } |
30 | | - |
31 | | - it { should contain_package('puppet') } |
32 | | - it do |
33 | | - should contain_service('puppet_agent').with({ |
34 | | - :ensure => "running" |
35 | | - }) |
| 32 | + context 'running as service' do |
| 33 | + let(:params) {{ |
| 34 | + :server => 'puppet.example.com', |
| 35 | + :report_server => 'puppet_reports.example.com', |
| 36 | + :method => 'service', |
| 37 | + }} |
| 38 | + it_behaves_like "agent examples" |
| 39 | + it do |
| 40 | + should contain_service('puppet_agent').with({ |
| 41 | + :ensure => "running" |
| 42 | + }) |
| 43 | + should contain_cron('puppet agent') |
| 44 | + end |
36 | 45 | end |
| 46 | + context 'method => "only_service"' do |
| 47 | + let(:params) {{ |
| 48 | + :server => 'puppet.example.com', |
| 49 | + :report_server => 'puppet_reports.example.com', |
| 50 | + :method => 'only_service', |
| 51 | + }} |
| 52 | + it_behaves_like "agent examples" |
| 53 | + it do |
| 54 | + should contain_service('puppet_agent').with({ |
| 55 | + :ensure => "running" |
| 56 | + }) |
| 57 | + should_not contain_cron('puppet agent') |
| 58 | + end |
| 59 | + end |
| 60 | + context 'method => "none"' do |
| 61 | + let(:params) {{ |
| 62 | + :server => 'puppet.example.com', |
| 63 | + :report_server => 'puppet_reports.example.com', |
| 64 | + :method => 'only_service', |
| 65 | + }} |
| 66 | + it_behaves_like "agent examples" |
| 67 | + it do |
| 68 | + should contain_service('puppet_agent').with({ |
| 69 | + :ensure => "running" |
| 70 | + }) |
| 71 | + should_not contain_cron('puppet agent') |
| 72 | + end |
| 73 | + end |
| 74 | + context 'method => "cron"' do |
| 75 | + let(:params) {{ |
| 76 | + :server => 'puppet.example.com', |
| 77 | + :report_server => 'puppet_reports.example.com', |
| 78 | + :method => 'cron', |
| 79 | + }} |
| 80 | + it_behaves_like "agent examples" |
| 81 | + it do |
| 82 | + should_not contain_service('puppet_agent').with({ |
| 83 | + :ensure => "running" |
| 84 | + }) |
| 85 | + should contain_cron('puppet agent').with_command(/puppet agent/) |
| 86 | + end |
| 87 | + end |
| 88 | + context 'manage_repos => false' do |
| 89 | + let(:params) {{ |
| 90 | + :server => 'puppet.example.com', |
| 91 | + :report_server => 'puppet_reports.example.com', |
| 92 | + :manage_repos => false, |
| 93 | + }} |
| 94 | + it_behaves_like "agent examples" |
| 95 | + it do |
| 96 | + should contain_service('puppet_agent') |
| 97 | + should contain_cron('puppet agent').with_command(/puppet agent/) |
| 98 | + should_not contain_yumrepo('puppetlabs-products') |
| 99 | + should_not contain_apt__source('puppetlabs') |
| 100 | + end |
| 101 | + end |
| 102 | + |
37 | 103 | end |
38 | 104 | end |
39 | 105 | end |
|
0 commit comments