diff --git a/manifests/params.pp b/manifests/params.pp index b05b131bd..bb9918b99 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' @@ -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' @@ -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' diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index f9e77da79..a015603a6 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -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' @@ -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' @@ -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' @@ -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 diff --git a/spec/classes/proxy_spec.rb b/spec/classes/proxy_spec.rb index c8bc60e78..542b51873 100644 --- a/spec/classes/proxy_spec.rb +++ b/spec/classes/proxy_spec.rb @@ -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' @@ -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' @@ -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 diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 4b6ac20fd..3de541afa 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -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' @@ -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' @@ -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