Mark Phillips
2011-Mar-09 13:41 UTC
[Puppet Users] Odd behaviour in extlookup; include & inherit of variables
Hi all, I''ve been testing something today that I can''t get to play ball the way I''d like. Here''s the setup: site.pp import "nodes" $extlookup_datadir = "/etc/puppet/envs/poc/extdata" $extlookup_precedence = ["%{fqdn}", "common"] nodes.pp class core { include hostinfo include motd } hostinfo module, init.pp class hostinfo { $os = extlookup("os") $region = extlookup("region") } module motd, init.pp class motd { include "motd::$operatingsystem" } class motd::common { file { "/etc/motd": owner => root, group => sys, mode => 0644, content => template("motd/motd.erb"), } } module motd, redhat.pp class motd::redhat inherits motd::common {} External data CSV: testhost:extdata$ egrep ''^(os|region)'' testhost.domain.com.csv os,core-redhat-5.5.1.19-11-10.x86_64 region,eu Originally the hostinfo module was laid out in the same way we do all the modules, i.e. init.pp has parent class which ''includes'' class:: $operatingsystem and a class::common {} , then $operatingsystem.pp has ''class blah::redhat inherits blah::common''. But in the early part of the problem I realised the OS layout for ''hostinfo'' was bogus, and dropped it for simplification. $os and $region were constantly failing to be found, but if I took the extlookup statements and copy n'' pasted, verbatim, into the motd module itself, it worked. So then I tried a run stage to see if I could ensure hostinfo was imported before anything else. This was placed in site.pp: stage { "initialise": before => Stage[main] } class { "hostinfo": stage => "initialise"; } This is the first time I''ve messed with run stages, so I''m not 100% I got that right. It ran, and with puppet master --no-daemonize --debug I could see it being imported. So that was a good start in my mind. $os and $region still failed to be found though. So, I cut hostinfo out of nodes.pp, and put ''inherits hostinfo'' into ''class motd''; this worked fine, the variables were found as I''d like. How come it doesn''t work with run stages, or includes? Am I missing something fundamental here? Thanks --Mark -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.