On 26 Apr 2010, at 12:24, Bernd Adamowicz wrote: > Hi all, > > given these two classes inside the file > '/etc/puppet/modules/templates_eval/manifests/init.pp': > > 53 class templates_eval::providevars { > 54 > 55 > $hibernate_connection_dialect="org.hibernate.dialect.Oracle10gDialect" > 56 } > 57 > 58 class templates_eval::testvars { > 59 > 60 include templates_eval::providevars > 61 > 62 file { > 63 "/tmp/tmplteval.properties": > 64 ensure => "present", > 65 mode => 644, > 66 content => > template("templates_eval/global.properties.erb"), > 67 } > 68 }
This will not work as you expect, as the include templates_eval:;providevars creates a lower scope. You would need either have the $hiber... variable defined in the templates_eval::testvars class directly, or inherit the providevars class like: class templates_eval::testvars inherits templates_eval::providevars { ... } > > Obviously the 'include templates_eval::providevars' inside class > 'templates_eval::testvars' has no impact. I tried several other approaches > (importing manifests, etc.), too. But none of them worked. So the basic > question is: How can I have a set of variables defined in scope X (where X > might be a manifest, a class, or a define) and include it into scope Y (where > Y will most likely be a class or maybe a node). > Importing a file works at the parsing stage rather than the compilation stage (where variables are interpreted), so this would also not work as you expect. I like to thing of the parser/import phase as puppet merging all the *.pp files into one big PP file, which is then compiled based on the node in question (and the facts provided by that node). I'm pretty sure something more clever actually happens, but it's not a bad place to start for thinking about how the scope works - import is more like #include in a C preprocessor. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@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.