Hi, On Wed, 20 Jun 2012 15:02:43 -0700 (PDT) Nick Fagerlund <nick.fagerl...@puppetlabs.com> wrote:
> What R.I. said. Hyphens in variable names and class names are a no-no, > although they kinda work in some versions of Puppet. Use underscores > instead. > > (Why are hyphens a problem? Well, partly because you can subtract variables > in expressions. The ambiguity turned out to be a problem.) For me the workaround in this case then was just a string.gsub( '-', '_') in the custom fact and corresponding changes in my modules. If need be then I can always regsubst('_', '-', G) back again, though in my case, I didn't have to. I've not given it too much thought but I do have sympathy for argument that divergence of (some of) Puppet's logical representations and their labels from what's extant on the system reduces clarity and could introduce error. I'm not talking about class names nor packages really (there are already restrictions there for things like camelCase IIRC) but lower down it gets more murky. Service names (i.e. init scripts et al.) are *almost* an example as they're vendor controlled but ultimately I can't think of a case where you'd use them as variables. It was because of OS idiocy that I had to follow the symlinks for /dev/disk/by-path/xen-vbd-* in a custom fact, but I have no control over what those files are called. Having to munge the result of that file lookup with underscores and then call it as $::xen_vbd_2049 (or whatever) does feel icky because it's a mental hoop to jump through: the fact no-longer absolutely matches the name of the symlink. The more I think about it having to do the rename in facter doesn't seem great to me either as it seems to me it puts the logic in the wrong place. The style guide does explicitly say to not use dashes but if hyphens in variables are a no-no it may be worth explicitly saying so in the Variables section of language guide, and putting it in big red letters in the Reserved Words section so that idiots like don't miss it first time ;) Cheers, Steph -- Steph Gosling <st...@chuci.org> -- 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.