Skip to content

Commit

Permalink
Merge pull request #772 from root-expert/log-fixes
Browse files Browse the repository at this point in the history
Ensure correct logfile/logfilesize values when defaulting logtype to system
  • Loading branch information
bastelfreak authored Jul 30, 2021
2 parents d8eca09 + ca7c6e6 commit c762181
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
26 changes: 11 additions & 15 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,14 @@
$server_listenport = '10051'
$server_loadmodule = undef
$server_loadmodulepath = '/usr/lib/modules'
# provided by camptocamp/systemd
# provided by puppet/systemd
if $facts['systemd'] {
$server_logtype = 'system'
$server_logfile = undef
$server_logfilesize = undef
$server_logtype = 'system'
} else {
$server_logtype = 'file'
$server_logfile = '/var/log/zabbix/zabbix_server.log'
$server_logfilesize = '10'
$server_logtype = 'file'
}
$server_logfile = '/var/log/zabbix/zabbix_server.log'
$server_logfilesize = '10'
$server_logslowqueries = '0'
$server_maxhousekeeperdelete = '500'
$server_pidfile = '/var/run/zabbix/zabbix_server.pid'
Expand Down Expand Up @@ -355,11 +353,11 @@
$agent_zbx_templates = ['Template OS Linux', 'Template App SSH Service']
$apache_status = false
$monitored_by_proxy = undef
# provided by camptocamp/systemd
# provided by puppet/systemd
if $facts['systemd'] {
$agent_logtype = 'system'
$agent_logfile = undef
$agent_logfilesize = undef
$agent_logfile = '/var/log/zabbix/zabbix_agentd.log'
$agent_logfilesize = '100'
}
elsif $facts['kernel'] == 'windows' {
$agent_logtype = 'file'
Expand Down Expand Up @@ -402,16 +400,14 @@
$proxy_loadmodule = undef
$proxy_loadmodulepath = '/usr/lib/modules'
$proxy_localbuffer = '0'
# provided by camptocamp/systemd
# provided by puppet/systemd
if $facts['systemd'] {
$proxy_logtype = 'system'
$proxy_logfile = undef
$proxy_logfilesize = undef
} else {
$proxy_logtype = 'file'
$proxy_logfile = '/var/log/zabbix/zabbix_proxy.log'
$proxy_logfilesize = '10'
}
$proxy_logfile = '/var/log/zabbix/zabbix_proxy.log'
$proxy_logfilesize = '10'
$proxy_logremotecommands = 0
$proxy_logslowqueries = '0'
$proxy_mode = '0'
Expand Down
25 changes: 22 additions & 3 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
else
'/etc/zabbix/zabbix_agentd.conf'
end

log_path = case facts[:operatingsystem]
when 'windows'
'C:/ProgramData/zabbix/zabbix_agentd.log'
else
'/var/log/zabbix/zabbix_agentd.log'
end
include_dir = case facts[:operatingsystem]
when 'windows'
'C:/ProgramData/zabbix/zabbix_agentd.d'
Expand Down Expand Up @@ -365,8 +372,8 @@
end
end

context 'with zabbix_agentd.conf and logtype is declared' do
context 'declare logtype as system' do
context 'with zabbix_agentd.conf and logtype declared' do
describe 'as system' do
let :params do
{
logtype: 'system'
Expand All @@ -378,7 +385,7 @@
it { is_expected.to contain_file(config_path).without_content %r{^LogFileSize=} }
end

context 'declare logtype as console' do
describe 'as console' do
let :params do
{
logtype: 'console'
Expand All @@ -389,6 +396,18 @@
it { is_expected.to contain_file(config_path).without_content %r{^LogFile=} }
it { is_expected.to contain_file(config_path).without_content %r{^LogFileSize=} }
end

describe 'as file' do
let :params do
{
logtype: 'file'
}
end

it { is_expected.to contain_file(config_path).with_content %r{^LogType=file$} }
it { is_expected.to contain_file(config_path).with_content %r{^LogFile=#{log_path}$} }
it { is_expected.to contain_file(config_path).with_content %r{^LogFileSize=100$} }
end
end
end
end
Expand Down
18 changes: 15 additions & 3 deletions spec/classes/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SocketDir=/var/run/zabbix} }
end

context 'with zabbix_proxy.conf and logtype' do
context 'declared as system' do
context 'with zabbix_proxy.conf and logtype declared' do
describe 'as system' do
let :params do
{
logtype: 'system'
Expand All @@ -410,7 +410,7 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} }
end

context 'declared as console' do
describe 'as console' do
let :params do
{
logtype: 'console'
Expand All @@ -421,6 +421,18 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFile=} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} }
end

describe 'as file' do
let :params do
{
logtype: 'file'
}
end

it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=file$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_proxy.log$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=10$} }
end
end
end
end
Expand Down
18 changes: 15 additions & 3 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SocketDir=/var/run/zabbix} }
end

context 'with zabbix_server.conf and logtype' do
context 'declared as system' do
context 'with zabbix_server.conf and logtype declared' do
describe 'as system' do
let :params do
{
logtype: 'system'
Expand All @@ -373,7 +373,7 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').without_content %r{^LogFileSize=} }
end

context 'declared as console' do
describe 'as console' do
let :params do
{
logtype: 'console'
Expand All @@ -384,6 +384,18 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').without_content %r{^LogFile=} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').without_content %r{^LogFileSize=} }
end

describe 'as file' do
let :params do
{
logtype: 'file'
}
end

it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogType=file$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_server.log$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFileSize=10$} }
end
end
end
end
Expand Down

0 comments on commit c762181

Please sign in to comment.