Hi all! I have quation: how i may use nested variables/facts? For example, I have variable $iface. It''s variable declared in node brakets, and, use with defenition. iface may be eth0, eth1(Linux), em0, ... <freebsd>, ... is fact: facter | grep eth0 | grep mac macaddress_eth0 => 54:52:00:3D:CB:40 We don''nt know name of $iface in our module (to generate network settings), how we may use nested variables/facts? Syntax: $mac = ${$macaddress_${iface}} Does''nt work. In documentation i did''nt find answer for my quation... -- 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.
Have a look at the generate() and inline_template() functions, one of which should provide you with a workaround to your problem. There may be a more elegant solution though. On 24 Dec 2009, at 09:33, sHaggY_caT <galia.msk@gmail.com> wrote:> Hi all! > > I have quation: how i may use nested variables/facts? For example, I > have variable $iface. It''s variable declared in node brakets, and, use > with defenition. iface may be eth0, eth1(Linux), em0, ... > <freebsd>, ... > > is fact: > > facter | grep eth0 | grep mac > macaddress_eth0 => 54:52:00:3D:CB:40 > > We don''nt know name of $iface in our module (to generate network > settings), how we may use nested variables/facts? Syntax: > > $mac = ${$macaddress_${iface}} > > Does''nt work. > > In documentation i did''nt find answer for my quation... > > -- > > 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 > . > >-- 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.
Thank you very much for answer. Do you may print simple working example? I don''t find it in documentation, sorry On 24 дек, 11:09, Mike Pountney <mike.pount...@gmail.com> wrote:> Have a look at the generate() and inline_template() functions, one of > which should provide you with a workaround to your problem. There may > be a more elegant solution though. > > On 24 Dec 2009, at 09:33, sHaggY_caT <galia....@gmail.com> wrote: > > > > > Hi all! > > > I have quation: how i may use nested variables/facts? For example, I > > have variable $iface. It''s variable declared in node brakets, and, use > > with defenition. iface may be eth0, eth1(Linux), em0, ... > > <freebsd>, ... > > > is fact: > > > facter | grep eth0 | grep mac > > macaddress_eth0 => 54:52:00:3D:CB:40 > > > We don''nt know name of $iface in our module (to generate network > > settings), how we may use nested variables/facts? Syntax: > > > $mac = ${$macaddress_${iface}} > > > Does''nt work. > > > In documentation i did''nt find answer for my quation... > > > -- > > > 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 athttp://groups.google.com/group/puppet-users?hl=en > > .-- 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.
sHaggY_caT wrote:> Thank you very much for answer. > > Do you may print simple working example? >$ifaces = split($interfaces, '','') define do::it { $tpl = "<% if has_variable?(\"ipaddress_$name\") -%> The IP address for $name is: <%= ipaddress_$name %> <% end -%> " notice(inline_template($tpl)) } do::it { $ifaces: } -scott -- 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.
Thank''s, Scott :) Happy New Year! On 26 дек, 01:18, Scott Smith <sc...@ohlol.net> wrote:> sHaggY_caT wrote: > > Thank you very much for answer. > > > Do you may print simple working example? > > $ifaces = split($interfaces, '','') > > define do::it { > $tpl = "<% if has_variable?(\"ipaddress_$name\") -%> > The IP address for $name is: <%= ipaddress_$name %> > <% end -%> > " > > notice(inline_template($tpl)) > > } > > do::it { $ifaces: } > > -scott-- 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.
On 24.12.2009 11:33, sHaggY_caT wrote:> Hi all! > > I have quation: how i may use nested variables/facts? For example, I > have variable $iface. It''s variable declared in node brakets, and, use > with defenition. iface may be eth0, eth1(Linux), em0, ... > <freebsd>, ... > > is fact: > > facter | grep eth0 | grep mac > macaddress_eth0 => 54:52:00:3D:CB:40 > > We don''nt know name of $iface in our module (to generate network > settings), how we may use nested variables/facts? Syntax: > > $mac = ${$macaddress_${iface}} >Shouldn''t this be ${macaddress_${iface}} ? Silviu> Does''nt work. > > In documentation i did''nt find answer for my quation... > > -- > > 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. > > >-- 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.
Silviu Paragina wrote:>> $mac = ${$macaddress_${iface}} >> > Shouldn''t this be ${macaddress_${iface}} ? >Have you tried that? Doesn''t work for me in 0.25.1. -scott -- 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.
On 26.12.2009 20:10, Scott Smith wrote:> Silviu Paragina wrote: > >>> $mac = ${$macaddress_${iface}} >>> >>> >> Shouldn''t this be ${macaddress_${iface}} ? >> >> > Have you tried that? Doesn''t work for me in 0.25.1. >Not really, tested it now, and you are right, but there was an extra $ in there, sorry :"> Silviu> -scott > > -- > > 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. > > >-- 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.
Seemingly Similar Threads
- Variable interpolation challenge
- Is it possible to evaluate a string as a parameter name?
- template issue: nested variables?
- facter --yaml leaves some fields blank
- Error 400 on SERVER: Could not parse for environment production: Syntax error at '{'; expected '}'