Given a variable that holds a class name is it possible to resolve the
value of a variable within that class? For example
class classes::myclass{
$install_dir = ''/xyz''
}
class example($class_name=''classes::myclass''){
file {"/mylink" :
ensure => link,
target => "${${class_name}::install_dir}",
}
}
Right now it appears that the parser doesn''t recognize the inner
variable.
Currently running puppet v3.0.1.
I would like the target of the link to resolve to /xyz. Is this possible?
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Feb-04 15:49 UTC
[Puppet Users] Re: Possible to evaluate embedded variables?
On Saturday, February 2, 2013 12:55:56 PM UTC-6, Schofield wrote:> > Given a variable that holds a class name is it possible to resolve the > value of a variable within that class?Yes, via an inline_template, but it''s a bad idea.> For example > > class classes::myclass{ > $install_dir = ''/xyz'' > } > > class example($class_name=''classes::myclass''){ > file {"/mylink" : > ensure => link, > target => "${${class_name}::install_dir}", > } > } > > Right now it appears that the parser doesn''t recognize the inner variable. > Currently running puppet v3.0.1. > I would like the target of the link to resolve to /xyz. Is this > possible? > >Just to show that it can be done, you should be able to use target => inline_template("<%= scope.lookupvar(''${class_name}::install_dir'') %>") But again, don''t do that. It is fragile, and it is virtually guaranteed to become a mess. If you would like to discuss alternative approaches to the actual problem you are trying to solve, then we would be pleased to do so. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.