|
2 | 2 |
|
3 | 3 | require 'spec_helper_acceptance' |
4 | 4 |
|
5 | | -describe 'Rsyslog actions' do |
6 | | - before(:context) do |
7 | | - cleanup_helper |
8 | | - end |
9 | | - |
10 | | - context 'basic action' do |
11 | | - it 'applies with action' do |
12 | | - pp = <<-MANIFEST |
13 | | - if $facts['os']['name'] == 'Fedora' { |
14 | | - package { 'rsyslog-elasticsearch': ensure => installed } |
15 | | - } |
16 | | -
|
17 | | - class { 'rsyslog::config': |
18 | | - actions => { |
19 | | - 'omfile_all_logs' => { |
20 | | - 'type' => 'omfile', |
21 | | - 'config' => { |
22 | | - 'queue.type' => 'LinkedList', |
23 | | - 'queue.spoolDirectory' => '/var/log/rsyslog/queue', |
24 | | - 'file' => '/tmp/log', |
25 | | - } |
26 | | - }, |
27 | | - 'myaction' => { |
28 | | - 'type' => 'omelasticsearch', |
29 | | - 'config' => { |
30 | | - 'host' => ["127.0.0.1", "192.168.0.1"], |
31 | | - 'queue.type' => 'linkedlist', |
32 | | - 'queue.spoolDirectory' => '/var/log/rsyslog/queue' |
| 5 | +describe 'rsyslog::config::actions' do |
| 6 | + it_behaves_like 'an idempotent resource' do |
| 7 | + let(:manifest) do |
| 8 | + <<-PUPPET |
| 9 | + class { 'rsyslog::config': |
| 10 | + actions => { |
| 11 | + 'omfile_all_logs' => { |
| 12 | + 'type' => 'omfile', |
| 13 | + 'config' => { |
| 14 | + 'queue.type' => 'LinkedList', |
| 15 | + 'queue.spoolDirectory' => '/var/log/rsyslog/queue', |
| 16 | + 'file' => '/tmp/log', |
| 17 | + } |
| 18 | + }, |
| 19 | + 'myaction' => { |
| 20 | + 'type' => 'omfwd', |
| 21 | + 'config' => { |
| 22 | + 'target' => "127.0.0.123", |
| 23 | + 'queue.type' => 'linkedlist', |
| 24 | + 'queue.spoolDirectory' => '/var/log/rsyslog/queue' |
| 25 | + } |
33 | 26 | } |
34 | 27 | } |
35 | 28 | } |
36 | | - } |
37 | | - MANIFEST |
38 | | - |
39 | | - apply_manifest(pp, catch_failures: true) |
40 | | - apply_manifest(pp, catch_changes: true) |
| 29 | + PUPPET |
41 | 30 | end |
| 31 | + end |
42 | 32 |
|
43 | | - describe file('/etc/rsyslog.d/50_rsyslog.conf') do |
44 | | - its(:content) do |
45 | | - is_expected.to match(%r{# omfile_all_logs\naction\(type="omfile"\n.*name="omfile_all_logs"\n.*queue.type="LinkedList"\n.*queue.spoolDirectory="/var/log/rsyslog/queue"\n.*file="/tmp/log"\n.*\)}) |
46 | | - is_expected.to match(%r{# myaction\naction\(type="omelasticsearch"\n.*name="myaction"\n.*host=\["127.0.0.1", "192.168.0.1"\]\n.*queue.type="linkedlist"\n.*queue.spoolDirectory="/var/log/rsyslog/queue"\n.*\)}) |
47 | | - end |
48 | | - end |
49 | | - |
50 | | - # rm the rsyslog-elasticsearch package as it will block the uninstall of |
51 | | - # the rsyslog package in other acceptance tests |
52 | | - if fact('os.name') == 'Fedora' |
53 | | - it 'applies with action' do |
54 | | - pp = <<-MANIFEST |
55 | | - if $facts['os']['name'] == 'Fedora' { |
56 | | - package { 'rsyslog-elasticsearch': ensure => absent } |
57 | | - } |
58 | | - MANIFEST |
59 | | - |
60 | | - apply_manifest(pp, catch_failures: true) |
61 | | - apply_manifest(pp, catch_changes: true) |
62 | | - end |
| 33 | + describe file('/etc/rsyslog.d/50_rsyslog.conf') do |
| 34 | + its(:content) do |
| 35 | + is_expected.to match(%r{# omfile_all_logs\naction\(type="omfile"\n.*name="omfile_all_logs"\n.*queue.type="LinkedList"\n.*queue.spoolDirectory="/var/log/rsyslog/queue"\n.*file="/tmp/log"\n.*\)}) |
| 36 | + is_expected.to match(%r{# myaction\naction\(type="omfwd"\n.*name="myaction"\n.*target="127.0.0.123"\n.*queue.type="linkedlist"\n.*queue.spoolDirectory="/var/log/rsyslog/queue"\n.*\)}) |
63 | 37 | end |
64 | 38 | end |
65 | 39 | end |
0 commit comments