Hi Folks,
I've started writing a module for zabbix monitoring (current version here: https://github.com/kemra102/puppet-zabbix).
I have a basic set-up to install the zabbix client using the module.
There are some values I need to change for our environment so that the config works, in my case I'm trying to set the $zabbix::client_server variable via Hiera so it can be populated via template for the zabbix client.
Currently I have this in common.yaml:
zabbix::client_server: '10.0.0.1'
As far as I know this should work fine and matches the Puppetlabs NTP module way of doing it (in this module we define our own NTP servers in Hiera to override the defaults just fine).
However it doesn't seem to be getting set as one of the error checks I have in place is being triggered due to this value being missing.
| class zabbix::client::service inherits zabbix::params { |
|
|
| if ($client_startagents != '0' and $client_server == '') { |
| fail("Your StartAgents cannot be greater than 0 or null when Server is also null. Set StartAgents to 0 or set Server.") |
| } |
| if ($client_server == '' and $client_serveractive == '') { |
| fail("You must set either passvie or active (or both) checks via the Server or ServerActive options.") |
| } |
Any ideas where the issue might lie? This is my first big piece of work doing a Puppet module in the more correct way so I may have missed something.
On Wednesday, September 24, 2014 5:57:45 AM UTC-5, Danny Roberts wrote:Hi Folks,
I've started writing a module for zabbix monitoring (current version here: https://github.com/kemra102/puppet-zabbix).
I have a basic set-up to install the zabbix client using the module.
There are some values I need to change for our environment so that the config works, in my case I'm trying to set the $zabbix::client_server variable via Hiera so it can be populated via template for the zabbix client.
Currently I have this in common.yaml:
zabbix::client_server: '10.0.0.1'
As far as I know this should work fine and matches the Puppetlabs NTP module way of doing it (in this module we define our own NTP servers in Hiera to override the defaults just fine).
However it doesn't seem to be getting set as one of the error checks I have in place is being triggered due to this value being missing.
Are you talking about these checks:
class zabbix::client::service inherits zabbix::params { if ($client_startagents != '0' and $client_server == '') { fail("Your StartAgents cannot be greater than 0 or null when Server is also null. Set StartAgents to 0 or set Server.") } if ($client_server == '' and $client_serveractive == '') { fail("You must set either passvie or active (or both) checks via the Server or ServerActive options.") } [...]
}
Whether you are or not, I note that in that particular class the unqualified name $client_server refers to $::zabbix::params::client_server (via class inheritance). If you were expecting the value from hiera then you should be testing $::zabbix::client_server (and therefore that class should 'include ::zabbix', or at minimum it should document that it relies on some other class to have already done so). Alternatively, you could read the value from hiera by calling "hiera('zabbix::client_server', $::zabbix::params::client_server)" to get exactly the same value that $::zabbix::client_server gets.
class zabbix::client::service inherits zabbix::params {
# ensure the main class is declared
include ::zabix
if ($client_startagents != '0' and $client_server == '') { fail("Your StartAgents cannot be greater than 0 or null when Server is also null. Set StartAgents to 0 or set Server.")
}
...
On Wednesday, 24 September 2014 14:08:30 UTC+1, jcbollinger wrote:
On Wednesday, September 24, 2014 5:57:45 AM UTC-5, Danny Roberts wrote:Hi Folks,
I've started writing a module for zabbix monitoring (current version here: https://github.com/kemra102/puppet-zabbix).
I have a basic set-up to install the zabbix client using the module.
There are some values I need to change for our environment so that the config works, in my case I'm trying to set the $zabbix::client_server variable via Hiera so it can be populated via template for the zabbix client.
Currently I have this in common.yaml:
zabbix::client_server: '10.0.0.1'
As far as I know this should work fine and matches the Puppetlabs NTP module way of doing it (in this module we define our own NTP servers in Hiera to override the defaults just fine).
However it doesn't seem to be getting set as one of the error checks I have in place is being triggered due to this value being missing.
Are you talking about these checks:
class zabbix::client::service inherits zabbix::params { if ($client_startagents != '0' and $client_server == '') { fail("Your StartAgents cannot be greater than 0 or null when Server is also null. Set StartAgents to 0 or set Server.") } if ($client_server == '' and $client_serveractive == '') { fail("You must set either passvie or active (or both) checks via the Server or ServerActive options.") } [...]
}
Whether you are or not, I note that in that particular class the unqualified name $client_server refers to $::zabbix::params::client_server (via class inheritance). If you were expecting the value from hiera then you should be testing $::zabbix::client_server (and therefore that class should 'include ::zabbix', or at minimum it should document that it relies on some other class to have already done so). Alternatively, you could read the value from hiera by calling "hiera('zabbix::client_server', $::zabbix::params::client_server)" to get exactly the same value that $::zabbix::client_server gets.
I don't think I've articulated this too well. I know those checks work becuase for example if I hardcode an IP in params.pp for client_server then the check is passed and the config file updated and service started without error.
However for example in our production common.yaml we have:
ntp::servers: [ '0.uk.pool.ntp.org', '1.uk.pool.ntp.org', '2.uk.pool.ntp.org', '3.uk.pool.ntp.org' ]
This correctly modifies the ntp::params::servers variable.
I am trying to achieve the same thing with my zabbix module by having this in common.yaml:
zabbix::client_server: '10.0.0.1'
In order to modify the default value of zabbix::params::client_server
I've had a look through the Puppetlabs NTP code and it doesn't look like you have to do anything special in order to be able to overwrite variables in Hiera beyond what I have already done.
It sounds like you have a misconception. By recording the specified data in Hiera, you provide a value to bind to class ::zabbix's parameter $::zabbix::client_server. If you declare class ::zabbix without specifying a value for that parameter (e.g.include '::zabbix'
orclass { '::zabbix': }
) then $::zabbix::client_server will take the Hiera value. If there were no such value available from Hiera then $::zabbix::client_server would take its default value instead ($::zabbix::params::client_server). In no event is the value of class variable $::zabbix::params::client_server ever different from the one with which it is initialized in the body of class ::zabbix::params.