summaryrefslogtreecommitdiff
path: root/puppet/modules/rsyslog/spec
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
committerMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
commit34a381efa8f6295080c843f86bfa07d4e41056af (patch)
tree9282cf5d4c876688602705a7fa0002bc4a810bde /puppet/modules/rsyslog/spec
parent0a72bc6fd292bf9367b314fcb0347c4d35042f16 (diff)
parent5821964ff7e16ca7aa9141bd09a77d355db492a9 (diff)
Merge branch 'develop'
Diffstat (limited to 'puppet/modules/rsyslog/spec')
m---------puppet/modules/rsyslog0
-rw-r--r--puppet/modules/rsyslog/spec/classes/rsyslog_client_spec.rb146
-rw-r--r--puppet/modules/rsyslog/spec/classes/rsyslog_database_spec.rb308
-rw-r--r--puppet/modules/rsyslog/spec/classes/rsyslog_server_spec.rb182
-rw-r--r--puppet/modules/rsyslog/spec/classes/rsyslog_spec.rb469
-rw-r--r--puppet/modules/rsyslog/spec/defines/rsyslog_imfile_spec.rb169
-rw-r--r--puppet/modules/rsyslog/spec/defines/rsyslog_snippet_spec.rb157
-rw-r--r--puppet/modules/rsyslog/spec/spec.opts6
-rw-r--r--puppet/modules/rsyslog/spec/spec_helper.rb28
9 files changed, 1465 insertions, 0 deletions
diff --git a/puppet/modules/rsyslog b/puppet/modules/rsyslog
deleted file mode 160000
-Subproject b8ef11c23949d12732ad5cdaebb3023ff39a297
diff --git a/puppet/modules/rsyslog/spec/classes/rsyslog_client_spec.rb b/puppet/modules/rsyslog/spec/classes/rsyslog_client_spec.rb
new file mode 100644
index 00000000..82865db9
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/classes/rsyslog_client_spec.rb
@@ -0,0 +1,146 @@
+require 'spec_helper'
+
+describe 'rsyslog::client', :type => :class do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/client.conf')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/client.conf')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/client.conf')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/client.conf')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/client.conf')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/client.conf')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version = nil" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => nil
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-client-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/client.conf')
+ end
+ end
+ end
+ end
+end
diff --git a/puppet/modules/rsyslog/spec/classes/rsyslog_database_spec.rb b/puppet/modules/rsyslog/spec/classes/rsyslog_database_spec.rb
new file mode 100644
index 00000000..0421135a
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/classes/rsyslog_database_spec.rb
@@ -0,0 +1,308 @@
+require 'spec_helper'
+
+describe 'rsyslog::database', :type => :class do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage mysql (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-mysql')
+ should contain_file('/etc/rsyslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-pgsql')
+ should contain_file('/etc/rsyslog.d/pgsql.conf')
+ end
+ end
+ end
+
+
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage mysql (osfamily = Debian)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-mysql')
+ should contain_file('/etc/rsyslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = Debian)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-pgsql')
+ should contain_file('/etc/rsyslog.d/pgsql.conf')
+ end
+ end
+ end
+
+
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage mysql (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5-mysql')
+ should contain_file('/etc/syslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5-pgsql')
+ should contain_file('/etc/syslog.d/pgsql.conf')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage mysql (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-mysql')
+ should contain_file('/etc/rsyslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-pgsql')
+ should contain_file('/etc/rsyslog.d/pgsql.conf')
+ end
+ end
+ end
+
+
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage mysql (osfamily = Debian)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-mysql')
+ should contain_file('/etc/rsyslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = Debian)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('rsyslog-pgsql')
+ should contain_file('/etc/rsyslog.d/pgsql.conf')
+ end
+ end
+ end
+
+
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage mysql (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-database-mysql' }
+
+ let (:params) {
+ {
+ 'backend' => 'mysql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5-mysql')
+ should contain_file('/etc/syslog.d/mysql.conf')
+ end
+ end
+
+ context "default usage pgsql (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-database-pgsql' }
+
+ let (:params) {
+ {
+ 'backend' => 'pgsql',
+ 'server' => 'localhost',
+ 'database' => 'rsyslog',
+ 'username' => 'us3rname',
+ 'password' => 'passw0rd',
+ }
+ }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5-pgsql')
+ should contain_file('/etc/syslog.d/pgsql.conf')
+ end
+ end
+ end
+ end
+end
diff --git a/puppet/modules/rsyslog/spec/classes/rsyslog_server_spec.rb b/puppet/modules/rsyslog/spec/classes/rsyslog_server_spec.rb
new file mode 100644
index 00000000..8f57656b
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/classes/rsyslog_server_spec.rb
@@ -0,0 +1,182 @@
+require 'spec_helper'
+
+describe 'rsyslog::server', :type => :class do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ ['RedHat', 'Debian'].each do |osfamily|
+ context "osfamily = #{osfamily}" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => osfamily,
+ :operatingsystem => osfamily,
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-basic' }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ context "enable_onefile (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'enable_onefile' => 'true'} }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ context "hostname_template (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ end
+ end
+
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
+ end
+ end
+
+ context "enable_onefile (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'enable_onefile' => 'true'} }
+
+ it 'should compile' do
+ should_not contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
+ end
+ end
+
+ context "hostname_template (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/messages/)
+ end
+ end
+
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ ['RedHat', 'Debian'].each do |osfamily|
+ context "osfamily = #{osfamily}" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => osfamily,
+ :operatingsystem => osfamily,
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-basic' }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ context "enable_onefile (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'enable_onefile' => 'true'} }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ context "hostname_template (osfamily = #{osfamily})" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
+
+ it 'should compile' 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/)
+ end
+ end
+
+ end
+ end
+
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
+ end
+ end
+
+ context "enable_onefile (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'enable_onefile' => 'true'} }
+
+ it 'should compile' do
+ should_not contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/)
+ end
+ end
+
+ context "hostname_template (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-server-onefile' }
+ let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/auth.log/)
+ should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/messages/)
+ end
+ end
+
+ end
+ end
+end # describe 'rsyslog::server'
diff --git a/puppet/modules/rsyslog/spec/classes/rsyslog_spec.rb b/puppet/modules/rsyslog/spec/classes/rsyslog_spec.rb
new file mode 100644
index 00000000..344d7174
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/classes/rsyslog_spec.rb
@@ -0,0 +1,469 @@
+require 'spec_helper'
+
+describe 'rsyslog', :type => :class do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.conf')
+ should contain_file('/etc/rsyslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.conf')
+ should contain_file('/etc/rsyslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.conf')
+ should contain_file('/etc/syslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('rsyslog')
+ should contain_package('rsyslog-relp')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('rsyslog')
+ should contain_package('rsyslog-relp')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5')
+ should contain_package('sysutils/rsyslog5-relp')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('rsyslog')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('rsyslog')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('syslogd')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = FreeBSD)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_class('rsyslog::install')
+ should contain_class('rsyslog::config')
+ should contain_class('rsyslog::service')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.conf')
+ should contain_file('/etc/rsyslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.conf')
+ should contain_file('/etc/rsyslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.conf')
+ should contain_file('/etc/syslog.d/')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('rsyslog')
+ should contain_package('rsyslog-relp')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('rsyslog')
+ should contain_package('rsyslog-relp')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-install-basic' }
+
+ it 'should compile' do
+ should contain_package('sysutils/rsyslog5')
+ should contain_package('sysutils/rsyslog5-relp')
+ end
+ end
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('rsyslog')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('rsyslog')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-service-basic' }
+
+ it 'should compile' do
+ should contain_service('syslogd')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => nil
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ context "default usage (osfamily = RedHat)" do
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.conf')
+ should contain_file('/etc/rsyslog.d/')
+ end
+ end
+ end
+ end
+end
diff --git a/puppet/modules/rsyslog/spec/defines/rsyslog_imfile_spec.rb b/puppet/modules/rsyslog/spec/defines/rsyslog_imfile_spec.rb
new file mode 100644
index 00000000..1c505eb7
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/defines/rsyslog_imfile_spec.rb
@@ -0,0 +1,169 @@
+require 'spec_helper'
+
+describe 'rsyslog::imfile', :type => :define do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ let (:params) {
+ {
+ 'file_name' => 'mylogfile',
+ 'file_tag' => 'mytag',
+ 'file_facility' => 'myfacility',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-imfile-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/rsyslog-imfile-basic.conf')
+ end
+ end
+ end
+ end
+
+end
diff --git a/puppet/modules/rsyslog/spec/defines/rsyslog_snippet_spec.rb b/puppet/modules/rsyslog/spec/defines/rsyslog_snippet_spec.rb
new file mode 100644
index 00000000..6cc68839
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/defines/rsyslog_snippet_spec.rb
@@ -0,0 +1,157 @@
+require 'spec_helper'
+
+describe 'rsyslog::snippet', :type => :define do
+
+ context "Rsyslog version >= 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '8.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'Redhat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+ end
+
+ context "Rsyslog version =< 8" do
+ let(:default_facts) do
+ {
+ :rsyslog_version => '7.1.2'
+ }
+ end
+
+ context "osfamily = RedHat" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'RedHat',
+ :operatingsystem => 'Redhat',
+ :operatingsystemmajrelease => 6,
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = RedHat)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+
+ context "osfamily = Debian" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'Debian',
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/rsyslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+
+ context "osfamily = FreeBSD" do
+ let :facts do
+ default_facts.merge!({
+ :osfamily => 'freebsd',
+ })
+ end
+
+ let (:params) {
+ {
+ 'content' => 'Random Content',
+ }
+ }
+
+ context "default usage (osfamily = Debian)" do
+ let(:title) { 'rsyslog-snippet-basic' }
+
+ it 'should compile' do
+ should contain_file('/etc/syslog.d/rsyslog-snippet-basic.conf').with_content("# This file is managed by Puppet, changes may be overwritten\nRandom Content\n")
+ end
+ end
+ end
+ end
+
+end
diff --git a/puppet/modules/rsyslog/spec/spec.opts b/puppet/modules/rsyslog/spec/spec.opts
new file mode 100644
index 00000000..91cd6427
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/spec.opts
@@ -0,0 +1,6 @@
+--format
+s
+--colour
+--loadby
+mtime
+--backtrace
diff --git a/puppet/modules/rsyslog/spec/spec_helper.rb b/puppet/modules/rsyslog/spec/spec_helper.rb
new file mode 100644
index 00000000..12bb0b7f
--- /dev/null
+++ b/puppet/modules/rsyslog/spec/spec_helper.rb
@@ -0,0 +1,28 @@
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+RSpec.configure do |c|
+ c.mock_with :rspec do |mock|
+ mock.syntax = [:expect, :should]
+ end
+ c.include PuppetlabsSpec::Files
+
+ c.before :each do
+ # Ensure that we don't accidentally cache facts and environment
+ # between test cases.
+ Facter::Util::Loader.any_instance.stubs(:load_all)
+ Facter.clear
+ Facter.clear_messages
+
+ # Store any environment variables away to be restored later
+ @old_env = {}
+ ENV.each_key {|k| @old_env[k] = ENV[k]}
+
+ if Gem::Version.new(`puppet --version`) >= Gem::Version.new('3.5')
+ Puppet.settings[:strict_variables]=true
+ end
+ end
+
+ c.after :each do
+ PuppetlabsSpec::Files.cleanup
+ end
+end