Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure correct logfile/logfilesize values when defaulting logtype to system #772

Merged
merged 1 commit into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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