Issue #16622 has been reported by François Beausoleil. ---------------------------------------- Bug #16622: Undeclared variable should be a syntax error https://projects.puppetlabs.com/issues/16622
Author: François Beausoleil Status: Unreviewed Priority: Normal Assignee: Category: Target version: Affected Puppet version: 2.7.1 Keywords: Branch: I would argue that an undeclared variable should be a syntax error. I applied the following patch to my system yesterday: <pre> commit e1431fe9f512912f19bed20778217fdefd82dd92 Author: François Beausoleil <[email protected]> Date: Wed Sep 26 16:11:00 2012 -0400 Install RabbitMQ Management Visualizer plugin to trace all in/out flows diff --git a/puppet/modules/rabbitmq/manifests/install.pp b/puppet/modules/rabbitmq/manifests/install.pp index d1d39e1..a43d8ae 100644 --- a/puppet/modules/rabbitmq/manifests/install.pp +++ b/puppet/modules/rabbitmq/manifests/install.pp @@ -24,13 +24,21 @@ define rabbitmq::install($version='2.8.1'){ ] } - $plugin_already_installed = '/usr/sbin/rabbitmq-plugins 2>/dev/null list | grep -q "^[[]E[]] rabbitmq_management"' - - exec{"install-rabbitmq-plugins-${version}": + $management_plugin_already_installed = '/usr/sbin/rabbitmq-plugins 2>/dev/null list | grep -q "^[[]E[]] rabbitmq_management"' + exec{"install-rabbitmq-management-plugin-${version}": command => '/usr/sbin/rabbitmq-plugins enable rabbitmq_management', user => 'root', unless => $plugin_already_installed, require => Package["rabbitmq-server"], notify => Rabbitmq::Service[$name], } + + $visualizer_plugin_already_installed = '/usr/sbin/rabbitmq-plugins 2>/dev/null list | grep -q "^[[]E[]] rabbitmq_management_visualiser"' + exec{"install-rabbitmq-visualizer-plugin-${version}": + command => '/usr/sbin/rabbitmq-plugins enable rabbitmq_management_visualiser', + user => 'root', + unless => $plugin_already_installed, + require => Package["rabbitmq-server"], + notify => Rabbitmq::Service[$name], + } } </pre> Because of this ticket's subject, and because I'm complaining about it, you can all readily see what the problem is. Previously, I had only one plugin, and the variable's name was "plugin_already_installed". Now I have two plugins, and I need two variables, one for each plugin. Because of this mistake, my RabbitMQ servers would restart every 30 minutes, which caused all kinds of failures in my system overnight. Had an undeclared variable been a syntax error, Puppet would have failed to apply my catalog, which would NOT have been a fatal problem for the system, only for the specific catalogs. This is a minimal reproducible recipe: <pre> # $already_run = "/usr/bin/true" exec{'todo': command => '/bin/bash -c "echo ran"', unless => $already_run, } </pre> Resulting in: <pre> $ puppet apply a.pp notice: /Stage[main]//Exec[todo]/returns: executed successfully notice: Finished catalog run in 0.10 seconds </pre> Whereas I'd have expected something along the lines of: <pre> $ puppet apply a.pp fatal: a.pp:4 Use of undefined variable "already_run" $ echo $? 1 </pre> I'm on Ubuntu 11.10, using Puppet 2.7.1. What do you guys think? -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
