Thanks John, the "if has_variable" was the key and allowed me to remove the default variable definition.
If anyone is interested I posted an explanation and link to the source here, http://itscblog.tamu.edu/managing-zabbix-agents-with-puppet/. Thanks - Trey On Jun 6, 8:38 am, jcbollinger <john.bollin...@stjude.org> wrote: > On Jun 3, 11:58 am,treydock<treyd...@gmail.com> wrote: > > > I am getting the following error on about every other manual run of > > puppet... (hostnames removed) > > > err: Could not retrieve catalog from remote server: Error 400 on > > SERVER: Failed to parse template zabbix/userparameter_mysql_conf.erb: > > Could not find value for 'zabbix_mysql_user_parameters' at /etc/puppet/ > > modules/zabbix/manifests/classes/mysql.pp:7 on node > > puppetclient.domain > > If runs sometimes succeed and sometimes fail for the same node then > you probably have a missing dependency somewhere. If there were > exactly one missing dependency involved then the first-order estimate > would be that half your runs would fail. > > > > > > > > > > > If I then do another puppet run, I do not receive the error. It seems > > that just about every other manual run during testing of new module > > changes has this happen. This is occuring on ALL my puppet clients > > that are using the zabbix::mysql module. All systems running > > Puppet-2.6.8. Below is the full debug log and my zabbix module. > > > The $zabbix_mysql_user_parameters variable is optional...right now > > only one node has it defined explicitly, like so: > > > $zabbix_mysql_user_parameters = { > > item1 => { 'name' => 'mediawiki.usercount[*]', 'command' => > > 'mysql -B -s -e "SELECT count(*) FROM user" $1'}, > > } > > > This is the mysql class for zabbix where the empty variable is defined > > so that if no node has it defined it shouldn't fail... > > > $zabbix_mysql_user_parameters = [] > > > class zabbix::mysql inherits zabbix::agent { > > > file { > > "$zabbix_userparameter_config_dir/userparameter_mysql.conf": > > content => template("zabbix/ > > userparameter_mysql_conf.erb"), > > group => "zabbix", > > owner => "zabbix", > > mode => "600", > > require => Package["zabbix-agent"]; > > > "$zabbix_user_home_dir/.my.cnf": > > source => "puppet:///modules/zabbix/.my.cnf", > > group => "zabbix", > > owner => "zabbix", > > mode => "600", > > require => [ Package["zabbix-agent"], > > File["$zabbix_user_home_dir"] ]; > > } > > > } > > The variable definition is at top level in the class's file? And > you're relying on that to provide a default definition of the > variable? Ew. Now you have dynamic scoping thrown in. But that > ought to be parse-order dependent, so although it could explain some > nodes succeeding but others failing, I don't think it explains > individual nodes flopping back and forth between success and failure. > > > Here's the variables usage in the template... > > <% zabbix_mysql_user_parameters.each do |key, value_hash| -%> > > UserParameter=<%= value_hash['name'] %>,HOME=<%= zabbix_user_home_dir > > %> <%= value_hash['command'] %> > > <% end -%> > > > Would the solution be to make the template call use this instead?? > > > <% if has_variable?("zabbix_mysql_user_parameters") -%> > > <% zabbix_mysql_user_parameters.each do |key, value_hash| -%> > > UserParameter=<%= value_hash['name'] %>,HOME=<%= zabbix_user_home_dir > > %> <%= value_hash['command'] %> > > <% end -%> > > <% end -%> > > Maybe. Does the node that has a customized value for the variable > ever fail? Does it always get the userparameter_mysql.conf template > filled correctly? If so then yes, your template change should do the > trick, and you could then also remove the default variable definition > (which isn't reliably working anyway). > > Otherwise, probably not. That solution would likely make the errors > disappear, but it wouldn't fix the actual problem. Chances are that > nodes with customized $zabbix_mysql_user_parameters would flip flop. > In that case, the solution would probably require figuring out what > dependency is needed and putting it in. > > John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.