Henrik Lindberg
2011-Oct-19 18:36 UTC
[Puppet Users] need clarity on built-on variables for defined types
The documentation says: "Defined types have a number of built-in variables available, including $name and $title, which are set to the title of the resource when it is declared." How can I find out what the other "built-in variables" are? Is it the meta parameters? I Understand that since 2.6.5 it is possible to refer to $title and $name as default values of declared parameters - can the "other built-in variables" also be used this way, or are $name/$title special in this respect? What happened in < 2.6.5 ? Was the result depending on what the value of $name/$title was in the scope where it was declared - or did it just fail? Need this to correctly validate variable references in Geppetto (https://github.com/cloudsmith/geppetto/issues/210) Regards - henrik -- 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.
Nick Fagerlund
2011-Oct-19 21:04 UTC
[Puppet Users] Re: need clarity on built-on variables for defined types
Hey, Henrik. Argh, the language guide. Anyway, I was about to say $title and $name were the only ones, but then I remembered $module_name and $caller_module_name (http://docs.puppetlabs.com/guides/faq.html#are- there-variables-available-other-than-those-provided-by-facter). Those MIGHT be what the language guide was referring to. I''m pretty sure it wasn''t referring to metaparameters, although any metaparameters declared for a defined type instance ARE available as variables inside the definition. I don''t know if the module_name variables can be parameter defaults; you''d have to check. I forget what happens prior to 2.6.5 so you''ll have to check that too, but I THINK $name/$title caught the value they had in the containing scope, which would be the name of the class where the defined resource was declared. (Often "main" when you''re testing one-off manifests.) On Oct 19, 11:36 am, Henrik Lindberg <henrik.lindb...@cloudsmith.com> wrote:> The documentation says: > "Defined types have a number of built-in variables available, including > $name and $title, which are set to the title of the resource when it is > declared." > > How can I find out what the other "built-in variables" are? > Is it the meta parameters? > > I Understand that since 2.6.5 it is possible to refer to $title and > $name as default values of declared parameters - can the "other built-in > variables" also be used this way, or are $name/$title special in this > respect? > > What happened in < 2.6.5 ? Was the result depending on what the value of > $name/$title was in the scope where it was declared - or did it just fail? > > Need this to correctly validate variable references in Geppetto > (https://github.com/cloudsmith/geppetto/issues/210) > > Regards > - henrik-- 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.
Henrik Lindberg
2011-Oct-20 14:33 UTC
Re: [Puppet Users] Re: need clarity on built-on variables for defined types
Yeah, "Arrgh, the language guide."... not very precise. The issue I am trying to solve is how to help a user with available variables in a given scope (this is in Geppetto). What I currently do is check if a variable is known. If not know suggestions are computed. There is no problem with the truly global variables like $operatingsystem - if not found they should be referenced in global scope ($::operatingsystem). But magically injected local variables should not. I also wonder about these magic local variables if they are available from the outside. Is there some clear explanation of $title and $name somewhere. Some examples use $title and others use $name. I know "name" is an alias for a parameter marked as being the "namevar" of a type - but its use is noted as deprecated in favor of the real "namevar". How does the variables $name and $title relate? - henrik On 10/19/11 11:04 PM, Nick Fagerlund wrote:> Hey, Henrik. > > Argh, the language guide. Anyway, I was about to say $title and $name > were the only ones, but then I remembered $module_name and > $caller_module_name (http://docs.puppetlabs.com/guides/faq.html#are- > there-variables-available-other-than-those-provided-by-facter). Those > MIGHT be what the language guide was referring to. I''m pretty sure it > wasn''t referring to metaparameters, although any metaparameters > declared for a defined type instance ARE available as variables inside > the definition. > > I don''t know if the module_name variables can be parameter defaults; > you''d have to check. > > I forget what happens prior to 2.6.5 so you''ll have to check that too, > but I THINK $name/$title caught the value they had in the containing > scope, which would be the name of the class where the defined resource > was declared. (Often "main" when you''re testing one-off manifests.) > > On Oct 19, 11:36 am, Henrik Lindberg<henrik.lindb...@cloudsmith.com> > wrote: >> The documentation says: >> "Defined types have a number of built-in variables available, including >> $name and $title, which are set to the title of the resource when it is >> declared." >> >> How can I find out what the other "built-in variables" are? >> Is it the meta parameters? >> >> I Understand that since 2.6.5 it is possible to refer to $title and >> $name as default values of declared parameters - can the "other built-in >> variables" also be used this way, or are $name/$title special in this >> respect? >> >> What happened in< 2.6.5 ? Was the result depending on what the value of >> $name/$title was in the scope where it was declared - or did it just fail? >> >> Need this to correctly validate variable references in Geppetto >> (https://github.com/cloudsmith/geppetto/issues/210) >> >> Regards >> - henrik >-- 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.