voxpupuli / puppet-zabbix

Puppet module for creating and maintaining zabbix components with puppet.
https://forge.puppet.com/puppet/zabbix
Apache License 2.0
80 stars 227 forks source link

LogType parameter being set in conf for zabbix <3.0 #294

Open shaunrampersad opened 7 years ago

shaunrampersad commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

include ::zabbix::agent

Hiera for this node contains

zabbix::zabbix_version: '2.4'

What are you seeing

I've deleted the zabbix_agentd.conf so that puppet creates a new one.

Error: Could not start Service[zabbix-agent]: Execution of '/sbin/service zabbix-agent start' returned 1: Starting Zabbix Agent: zabbix_agentd [828]: unknown parameter [LogType] in config file [/etc/zabbix/zabbix_agentd.conf], line 19
[FAILED]
Error: /Stage[main]/Zabbix::Agent/Service[zabbix-agent]/ensure: change from stopped to running failed: Could not start Service[zabbix-agent]: Execution of '/sbin/service zabbix-agent start' returned 1: Starting Zabbix Agent: zabbix_agentd [828]: unknown parameter [LogType] in config file [/etc/zabbix/zabbix_agentd.conf], line 19
[FAILED]

What behaviour did you expect instead

The Agent would startup

Output log

Config file contains

### Option: LogType
#       Specifies where log messages are written to:
#               system  - syslog
#               file    - file specified with LogFile parameter
#               console - standard output
#
LogType=file

Any additional information you'd like to impart

The test cases for the agent does not specifically test for agents <3.0. There needs to be a test case for to pick up this issue.

Offending code is in the template zabbix_agentd.conf.erb lines 13-33.

<% if @zabbix_version.to_f >= 3.0 -%>
### Option: LogType
#   Specifies where log messages are written to:
#       system  - syslog
#       file    - file specified with LogFile parameter
#       console - standard output
#
<% if @logtype %>LogType=<%= @logtype %><% end %>

### Option: LogFile
#   Log file name for LogType 'file' parameter.
#
LogFile=<%= @logfile %>

<% else %>
### Option: LogFile
#   Name of log file.
#   If not set, syslog is used.
#
LogFile=<%= @logfile %>
<% end %>

I dont think if @zabbix_version.to_f >= 3.0 is being evaluated correctly?

shaunrampersad commented 7 years ago

Update:

I've tested on another setup running Puppet 4.5.0, and the module works as expected by adding LogType for zabbox >=3.0 and removing it for zabbix <3.0.