On Wednesday, September 24, 2014 9:26:30 AM UTC-5, Danny Roberts wrote: > > > > 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. > >
Again: the checks I quoted are against $zabbix::params::client_server, whose value does not depend on your Hiera data. If that's what you intended then well and good, but it seems a bit pointless. If those are *not* the failing checks you meant, then please point out the ones you did mean. My effectiveness at predicting the errors in code I cannot analyze is much less than my effectiveness at spotting errors in code that I can analyze. In any event, I don't see anywhere in the code on GitHub that you actually refer to variable $::zabbix::client_server, so I am uncertain how you could know whether it is getting the right value. > 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 > > 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' or class { '::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.* 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. > "Overwrite" sounds like you think something already set is being changed. That is not the case. (Did you perhaps mean "override" instead?) Anyway, your Hiera data look fine, and your class ::zabbix looks fine. I think you're struggling with a scope issue, not an Hiera issue. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c3df1d6e-e6cd-41eb-a02f-03f3887caca1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.