This commit is contained in:
Steffen Zieger 2016-08-05 14:21:51 +02:00
Родитель 4efbaeceab
Коммит 4d57e441e2
6 изменённых файлов: 581 добавлений и 653 удалений

Просмотреть файл

@ -4,43 +4,27 @@
#
Facter.add(:rsyslog_version) do
setcode do
osfamily = Facter.value('osfamily')
case osfamily
when "Debian"
command='/usr/bin/dpkg-query -f \'${Status};${Version};\' -W rsyslog 2>/dev/null'
version = Facter::Util::Resolution.exec(command)
if version =~ /.*[install|hold] ok installed;([^;]+);.*/
$1
else
nil
end
when "RedHat", "Suse"
command='rpm -qa --qf "%{VERSION}" "rsyslog"'
version = Facter::Util::Resolution.exec(command)
if version =~ /^(.+)$/
$1
else
nil
end
when "FreeBSD"
command='pkg query %v rsyslog8'
version = Facter::Util::Resolution.exec(command)
if version =~ /^(.+)$/
$1
else
nil
end
when "Gentoo"
command='equery -q -C list -F \'$version\' rsyslog'
version = Facter::Util::Resolution.exec(command)
if version =~ /^(.+)$/
$1
else
nil
end
else
nil
end
setcode do
osfamily = Facter.value('osfamily')
case osfamily
when 'Debian'
command = '/usr/bin/dpkg-query -f \'${Status};${Version};\' -W rsyslog 2>/dev/null'
version = Facter::Util::Resolution.exec(command)
if version =~ %r{.*[install|hold] ok installed;([^;]+);.*}
Regexp.last_match(1)
end
when 'RedHat', 'Suse'
command = 'rpm -qa --qf "%{VERSION}" "rsyslog"'
version = Facter::Util::Resolution.exec(command)
Regexp.last_match(1) if version =~ %r{^(.+)$}
when 'FreeBSD'
command = 'pkg query %v rsyslog8'
version = Facter::Util::Resolution.exec(command)
Regexp.last_match(1) if version =~ %r{^(.+)$}
when 'Gentoo'
command = 'equery -q -C list -F \'$version\' rsyslog'
version = Facter::Util::Resolution.exec(command)
Regexp.last_match(1) if version =~ %r{^(.+)$}
end
end
end

Просмотреть файл

@ -1,24 +1,23 @@
require 'spec_helper'
describe 'rsyslog::client', :type => :class do
context "Rsyslog version >= 8" do
describe 'rsyslog::client', type: :class do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => '8.1.2'
rsyslog_version: '8.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -26,9 +25,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/etc/rsyslog.d/client.conf')
@ -49,7 +48,7 @@ describe 'rsyslog::client', :type => :class do
context 'log_filters (osfamily = RedHat)' do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
@ -57,15 +56,15 @@ describe 'rsyslog::client', :type => :class do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -73,9 +72,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/etc/rsyslog.d/client.conf')
@ -96,88 +95,87 @@ describe 'rsyslog::client', :type => :class do
context 'log_filters (osfamily = RedHat)' do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
end
end
context "auth_mode (osfamily = Debian)" do
context 'auth_mode (osfamily = Debian)' do
let(:title) { 'rsyslog-client-auth_mode' }
context "without SSL" do
let(:params) { { :ssl_auth_mode => 'x509/name' } }
context 'without SSL' do
let(:params) { { ssl_auth_mode: 'x509/name' } }
it 'fails' do
expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, /You need to enable SSL in order to use ssl_auth_mode./)
expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, %r{You need to enable SSL in order to use ssl_auth_mode.})
end
end
context "with SSL" do
context 'with SSL' do
let :pre_condition do
"class { 'rsyslog': ssl => true }"
end
ssl_params = { :ssl_ca => '/tmp/cert.pem' }
ssl_params = { ssl_ca: '/tmp/cert.pem' }
context "with default auth_mode" do
context 'with default auth_mode' do
let(:params) { ssl_params }
it 'compiles' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode anon/).without_content(/\$ActionSendStreamDriverPermittedPeer/)
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{\$ActionSendStreamDriverAuthMode anon}).without_content(%r{\$ActionSendStreamDriverPermittedPeer})
end
end
context "without permitted peer" do
context 'without permitted peer' do
let(:params) do
ssl_params.merge({
:ssl_auth_mode => 'x509/name',
})
ssl_params.merge(
ssl_auth_mode: 'x509/name'
)
end
it 'contains ActionSendStreamDriverAuthMode' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode x509\/name/).without_content(/\$ActionSendStreamDriverPermittedPeer/)
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{\$ActionSendStreamDriverAuthMode x509\/name}).without_content(%r{\$ActionSendStreamDriverPermittedPeer})
end
end
context "permitted peer with anon auth_mode" do
context 'permitted peer with anon auth_mode' do
let(:params) do
ssl_params.merge({
:ssl_permitted_peer => 'logs.example.com'
})
ssl_params.merge(
ssl_permitted_peer: 'logs.example.com'
)
end
it 'fails' do
expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, /You need to set auth_mode to 'x509\/name' in order to use ssl_permitted_peer./)
expect { should contain_class('rsyslog::client') }.to raise_error(Puppet::Error, %r{You need to set auth_mode to 'x509\/name' in order to use ssl_permitted_peer.})
end
end
context "with permitted peer" do
context 'with permitted peer' do
let(:params) do
ssl_params.merge({
:ssl_auth_mode => 'x509/name',
:ssl_permitted_peer => 'logs.example.com'
})
ssl_params.merge(
ssl_auth_mode: 'x509/name',
ssl_permitted_peer: 'logs.example.com'
)
end
it 'contains ActionSendStreamDriverPermittedPeer' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(/\$ActionSendStreamDriverAuthMode x509\/name/).with_content(/\$ActionSendStreamDriverPermittedPeer logs.example.com/)
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{\$ActionSendStreamDriverAuthMode x509\/name}).with_content(%r{\$ActionSendStreamDriverPermittedPeer logs.example.com})
end
end
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -185,9 +183,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/usr/local/etc/rsyslog.d/client.conf')
@ -208,23 +206,23 @@ describe 'rsyslog::client', :type => :class do
end
end
context "Rsyslog version =< 8" do
context 'Rsyslog version =< 8' do
let(:default_facts) do
{
:rsyslog_version => '7.1.2'
rsyslog_version: '7.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -232,9 +230,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/etc/rsyslog.d/client.conf')
@ -255,7 +253,7 @@ describe 'rsyslog::client', :type => :class do
context 'log_filters (osfamily = RedHat)' do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
@ -263,15 +261,15 @@ describe 'rsyslog::client', :type => :class do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -279,9 +277,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/etc/rsyslog.d/client.conf')
@ -302,7 +300,7 @@ describe 'rsyslog::client', :type => :class do
context 'log_filters (osfamily = RedHat)' do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/client.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
@ -310,15 +308,15 @@ describe 'rsyslog::client', :type => :class do
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -326,9 +324,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/usr/local/etc/rsyslog.d/client.conf')
@ -349,23 +347,23 @@ describe 'rsyslog::client', :type => :class do
end
end
context "Rsyslog version = nil" do
context 'Rsyslog version = nil' do
let(:default_facts) do
{
:rsyslog_version => nil
rsyslog_version: nil
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-client-basic' }
it 'compiles' do
@ -373,9 +371,9 @@ describe 'rsyslog::client', :type => :class do
end
end
context "split_config => true" do
context 'split_config => true' do
let(:title) { 'rsyslog-client-basic' }
let(:params) {{ :split_config => true }}
let(:params) { { split_config: true } }
it 'does not manage client.conf' do
should_not contain_file('/etc/rsyslog.d/client.conf')

Просмотреть файл

@ -1,35 +1,34 @@
require 'spec_helper'
describe 'rsyslog::database', :type => :class do
context "Rsyslog version >= 8" do
describe 'rsyslog::database', type: :class do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => '8.1.2'
rsyslog_version: '8.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage mysql (osfamily = RedHat)" do
context 'default usage mysql (osfamily = RedHat)' do
let(:title) { 'rsyslog-database-mysql' }
let (:params) {
let(:params) do
{
'backend' => 'mysql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-mysql')
@ -37,18 +36,18 @@ describe 'rsyslog::database', :type => :class do
end
end
context "default usage pgsql (osfamily = RedHat)" do
context 'default usage pgsql (osfamily = RedHat)' do
let(:title) { 'rsyslog-database-pgsql' }
let (:params) {
let(:params) do
{
'backend' => 'pgsql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-pgsql')
@ -57,28 +56,26 @@ describe 'rsyslog::database', :type => :class do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage mysql (osfamily = Debian)" do
context 'default usage mysql (osfamily = Debian)' do
let(:title) { 'rsyslog-database-mysql' }
let (:params) {
let(:params) do
{
'backend' => 'mysql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-mysql')
@ -86,18 +83,18 @@ describe 'rsyslog::database', :type => :class do
end
end
context "default usage pgsql (osfamily = Debian)" do
context 'default usage pgsql (osfamily = Debian)' do
let(:title) { 'rsyslog-database-pgsql' }
let (:params) {
let(:params) do
{
'backend' => 'pgsql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-pgsql')
@ -107,34 +104,34 @@ describe 'rsyslog::database', :type => :class do
end
end
context "Rsyslog version =< 8" do
context 'Rsyslog version =< 8' do
let(:default_facts) do
{
:rsyslog_version => '7.1.2'
rsyslog_version: '7.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage mysql (osfamily = RedHat)" do
context 'default usage mysql (osfamily = RedHat)' do
let(:title) { 'rsyslog-database-mysql' }
let (:params) {
let(:params) do
{
'backend' => 'mysql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-mysql')
@ -142,18 +139,18 @@ describe 'rsyslog::database', :type => :class do
end
end
context "default usage pgsql (osfamily = RedHat)" do
context 'default usage pgsql (osfamily = RedHat)' do
let(:title) { 'rsyslog-database-pgsql' }
let (:params) {
let(:params) do
{
'backend' => 'pgsql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-pgsql')
@ -162,28 +159,26 @@ describe 'rsyslog::database', :type => :class do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage mysql (osfamily = Debian)" do
context 'default usage mysql (osfamily = Debian)' do
let(:title) { 'rsyslog-database-mysql' }
let (:params) {
let(:params) do
{
'backend' => 'mysql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-mysql')
@ -191,18 +186,18 @@ describe 'rsyslog::database', :type => :class do
end
end
context "default usage pgsql (osfamily = Debian)" do
context 'default usage pgsql (osfamily = Debian)' do
let(:title) { 'rsyslog-database-pgsql' }
let (:params) {
let(:params) do
{
'backend' => 'pgsql',
'server' => 'localhost',
'database' => 'rsyslog',
'username' => 'us3rname',
'password' => 'passw0rd',
'password' => 'passw0rd'
}
}
end
it 'compiles' do
should contain_package('rsyslog-pgsql')

Просмотреть файл

@ -1,56 +1,55 @@
require 'spec_helper'
describe 'rsyslog::server', :type => :class do
context "Rsyslog version >= 8" do
describe 'rsyslog::server', type: :class do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => '8.1.2'
rsyslog_version: '8.1.2'
}
end
['RedHat', 'Debian'].each do |osfamily|
%w(RedHat Debian).each do |osfamily|
context "osfamily = #{osfamily}" do
let :facts do
default_facts.merge!({
:osfamily => osfamily,
:operatingsystem => osfamily,
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: osfamily,
operatingsystem: osfamily,
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
context "log_filters (osfamily = #{osfamily})" do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
@ -59,97 +58,95 @@ describe 'rsyslog::server', :type => :class do
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = FreeBSD)" do
context 'enable_onefile (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = FreeBSD)" do
context 'hostname_template (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
end
end
context "Rsyslog version =< 8" do
context 'Rsyslog version =< 8' do
let(:default_facts) do
{
:rsyslog_version => '7.1.2'
rsyslog_version: '7.1.2'
}
end
['RedHat', 'Debian'].each do |osfamily|
%w(RedHat Debian).each do |osfamily|
context "osfamily = #{osfamily}" do
let :facts do
default_facts.merge!({
:osfamily => osfamily,
:operatingsystem => osfamily,
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: osfamily,
operatingsystem: osfamily,
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
context "log_filters (osfamily = #{osfamily})" do
let(:title) { 'log_filters_check' }
let(:params) { {'log_filters' => [{'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log'}] } }
let(:params) { { 'log_filters' => [{ 'expression' => '$msg contains \'error0\'', 'action' => '/var/log/err.log' }] } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{if \$msg contains 'error0' then /var/log/err.log})
end
@ -157,136 +154,129 @@ describe 'rsyslog::server', :type => :class do
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = FreeBSD)" do
context 'enable_onefile (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = FreeBSD)" do
context 'hostname_template (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
end
end
context "Rsyslog version = nil" do
context 'Rsyslog version = nil' do
let(:default_facts) do
{
:rsyslog_version => nil
rsyslog_version: nil
}
end
['RedHat', 'Debian'].each do |osfamily|
%w(RedHat Debian).each do |osfamily|
context "osfamily = #{osfamily}" do
let :facts do
default_facts.merge!({
:osfamily => osfamily,
:operatingsystem => osfamily,
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: osfamily,
operatingsystem: osfamily,
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = #{osfamily})" do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-basic' }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "enable_onefile (osfamily = FreeBSD)" do
context 'enable_onefile (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'enable_onefile' => 'true'} }
let(:params) { { 'enable_onefile' => 'true' } }
it 'compiles' do
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
should_not contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{\(\[A-Za-z-\]\*\)--end%\/messages})
end
end
context "hostname_template (osfamily = FreeBSD)" do
context 'hostname_template (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-server-onefile' }
let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
let(:params) { { 'custom_config' => 'rsyslog/server-hostname.conf.erb' } }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/)
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/auth.log})
should contain_file('/usr/local/etc/rsyslog.d/server.conf').with_content(%r{%hostname%\/messages})
end
end
end
end
end # describe 'rsyslog::server'

Просмотреть файл

@ -1,26 +1,25 @@
require 'spec_helper'
describe 'rsyslog', :type => :class do
context "Rsyslog version >= 8" do
describe 'rsyslog', type: :class do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => '8.1.2'
rsyslog_version: '8.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -28,18 +27,18 @@ describe 'rsyslog', :type => :class do
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -47,36 +46,36 @@ describe 'rsyslog', :type => :class do
end
end
context "local host name (osfamily = Debian)" do
context 'local host name (osfamily = Debian)' do
let(:title) { 'rsyslog-local-hostname' }
context "with defaults" do
context 'with defaults' do
it 'is not set' do
should contain_file('/etc/rsyslog.conf').without_content(/\$LocalHostName/)
should contain_file('/etc/rsyslog.conf').without_content(%r{\$LocalHostName})
end
end
context "when set" do
let(:params) { { :local_host_name => 'example.dev' } }
context 'when set' do
let(:params) { { local_host_name: 'example.dev' } }
it 'compiles' do
should contain_file('/etc/rsyslog.conf').with_content(/\$LocalHostName example.dev/)
should contain_file('/etc/rsyslog.conf').with_content(%r{\$LocalHostName example.dev})
end
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -84,162 +83,162 @@ describe 'rsyslog', :type => :class do
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.conf')
should contain_file('/etc/rsyslog.d/')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.conf')
should contain_file('/etc/rsyslog.d/')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.conf')
should contain_file('/usr/local/etc/rsyslog.d/')
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('rsyslog')
should contain_package('rsyslog-relp')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('rsyslog')
should contain_package('rsyslog-relp')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('sysutils/rsyslog8')
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslog')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslog')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslogd')
end
@ -247,25 +246,25 @@ describe 'rsyslog', :type => :class do
end
end
context "Rsyslog version =< 8" do
context 'Rsyslog version =< 8' do
let(:default_facts) do
{
:rsyslog_version => '7.1.2'
rsyslog_version: '7.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -273,18 +272,18 @@ describe 'rsyslog', :type => :class do
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -292,18 +291,18 @@ describe 'rsyslog', :type => :class do
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_class('rsyslog::install')
should contain_class('rsyslog::config')
@ -311,162 +310,162 @@ describe 'rsyslog', :type => :class do
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.conf')
should contain_file('/etc/rsyslog.d/')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/etc/rsyslog.conf')
should contain_file('/etc/rsyslog.d/')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-basic' }
it 'compiles' do
should contain_file('/usr/local/etc/rsyslog.conf')
should contain_file('/usr/local/etc/rsyslog.d/')
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('rsyslog')
should contain_package('rsyslog-relp')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('rsyslog')
should contain_package('rsyslog-relp')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-install-basic' }
it 'compiles' do
should contain_package('sysutils/rsyslog8')
end
end
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslog')
end
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslog')
end
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-service-basic' }
it 'compiles' do
should contain_service('rsyslogd')
end
@ -474,23 +473,23 @@ describe 'rsyslog', :type => :class do
end
end
context "Rsyslog version >= 8" do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => nil
rsyslog_version: nil
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
it 'compiles' do
should contain_file('/etc/rsyslog.conf')
should contain_file('/etc/rsyslog.d/')

Просмотреть файл

@ -1,32 +1,25 @@
require 'spec_helper'
describe 'rsyslog::imfile', :type => :define do
context "Rsyslog version >= 8" do
describe 'rsyslog::imfile', type: :define do
context 'Rsyslog version >= 8' do
let(:default_facts) do
{
:rsyslog_version => '8.1.2'
rsyslog_version: '8.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -35,23 +28,17 @@ describe 'rsyslog::imfile', :type => :define do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -60,23 +47,17 @@ describe 'rsyslog::imfile', :type => :define do
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -86,31 +67,25 @@ describe 'rsyslog::imfile', :type => :define do
end
end
context "Rsyslog version =< 8" do
context 'Rsyslog version =< 8' do
let(:default_facts) do
{
:rsyslog_version => '7.1.2'
rsyslog_version: '7.1.2'
}
end
context "osfamily = RedHat" do
context 'osfamily = RedHat' do
let :facts do
default_facts.merge!({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6',
})
default_facts.merge!(
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemmajrelease: '6'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = RedHat)" do
context 'default usage (osfamily = RedHat)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -119,23 +94,17 @@ describe 'rsyslog::imfile', :type => :define do
end
end
context "osfamily = Debian" do
context 'osfamily = Debian' do
let :facts do
default_facts.merge!({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
})
default_facts.merge!(
osfamily: 'Debian',
operatingsystem: 'Debian'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = Debian)" do
context 'default usage (osfamily = Debian)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -144,23 +113,17 @@ describe 'rsyslog::imfile', :type => :define do
end
end
context "osfamily = FreeBSD" do
context 'osfamily = FreeBSD' do
let :facts do
default_facts.merge!({
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
})
default_facts.merge!(
osfamily: 'FreeBSD',
operatingsystem: 'FreeBSD'
)
end
let (:params) {
{
'file_name' => 'mylogfile',
'file_tag' => 'mytag',
'file_facility' => 'myfacility',
}
}
let(:params) { { file_name: 'mylogfile', file_tag: 'mytag', file_facility: 'myfacility' } }
context "default usage (osfamily = FreeBSD)" do
context 'default usage (osfamily = FreeBSD)' do
let(:title) { 'rsyslog-imfile-basic' }
it 'compiles' do
@ -169,5 +132,4 @@ describe 'rsyslog::imfile', :type => :define do
end
end
end
end