Hi James, On Tuesday, January 8, 2013 11:19:13 PM UTC, jdehnert wrote: > > I want to pass a few variables through to the other files in a module. I > have a define statement that sets one default... > > define redis::install ( $port = 6397, $version ) > > What I am unclear on is how far does this define reach in my module? For > instance, do I need to have everything that uses these variables included > in the same file as the define, or if I put the define in init.pp can I use > those variables in the config.pp file? > > I'm not quite sure what you mean by "how far does the define reach in my module". Those variables in the example above are parameters to the define itself and can be used inside that define, you can't refer to those variables from another container like you can a variable in a class.
If you reference a variable outside the current scope you need to make sure that the container the variable is in is declared in the manifest for this node. In short, if you are using $redis::params::version you need to ensure you "include redis::params" or similar. To demonstrate, run the following code with "puppet apply <file>": define test($var = 'woof') { include dog } class dog { if $var == undef { warning("var = undef") } else { warning("var = '$var'") } } test { "meow": } #try reference the define variable warning("define var = '${test::var}'") class one { $foo = 'bar' include two } class two { warning("foo = '${foo}'") } include one -Luke > -- > Thanks, > James "Zeke" Dehnert > > > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/gow6N8iiMtMJ. 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.