voxpupuli / puppet-zabbix

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

Missing scope in zabbix-{agent,server}-systemd.init.erb #455

Open i1tech opened 7 years ago

i1tech commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Use the module to setup server or client on a CentOS 7.x system (most likely any system that uses systemd, but only have CentOS 7.x in our environmen).

What are you seeing

The service file is created with appropriate paths for PIDFile= and the configuration file option.

What behaviour did you expect instead

The appropriate values to be in the service file.

Output log

Any additional information you'd like to impart

The problem is lack of scope for the variables. Templates are put in place by the zabbix::startup define, which has no knowledge of the variables available to zabbix::agent or zabbix::server classes.

Variables are defined as <%= @agent_configfile_path %> and <%= @pidfile %> respectively, which are not defined within the scope of the define. Variables should be defined as <%= scope.lookupvar('zabbix::agent::agent_configfile_path') %> or <%= scope.lookupvar('zabbix::server::server_configfile_path') %> for the agent and server templates resepctively. Of course the pidfile would be defined with <%= scope.lookupvar('zabbix::agent::pidfile') %> or <%= scope.lookupvar('zabbix::server::pidfile') %>

I did not dig further to see if there were other instances where this would also be the case, as this is the only scenario that affects my install.

Regards,

John

bastelfreak commented 7 years ago

Hi @i1tech, thanks for rising this issue. I am not sure if I 100% understand it. The zabbix::agent class passes all params to the defined resource, so the variables are known to the defined resource: https://github.com/voxpupuli/puppet-zabbix/blob/master/manifests/agent.pp#L347

Do you run in any error message?

davidius81 commented 6 years ago

I have the same issue, @bastelfreak here is the error message I got:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Zabbix::Startup[zabbix-agent]:
  parameter 'agent_configfile_path' expects a Resource value, got String
  parameter 'pidfile' expects a Resource value, got String at /etc/puppetlabs/code/environments/prd/modules/zabbix/manifests/agent.pp:348 on node node1

My feeling is there is an incompatibility with sdtlib. I try to upgrade to stdlib v2.24 but still the same issue, basically, I got this error with all the defined variables type: Optional[Stdlib::Absolutepath]

David

bastelfreak commented 6 years ago

@davidius81 thanks for the bug report. Can you paste the code you used to call this module? On which operatingsystem/puppet version are you? Which version of the module? Have you tried our master branch as well?