Andrew Heagle
2010-Apr-18 03:24 UTC
[Puppet Users] Evaluate the value of a variable''s value
Hi, Is it possible for puppet to do the equivalent to this in bash: andrew@comet:~$ a=1 andrew@comet:~$ x="a" andrew@comet:~$ eval echo \$$x 1 Or this perl: #!/usr/bin/perl $a=1; $x="a"; print $$x; (Output would be 1) Or would I need to write a function to do this? Thanks, Andrew -- 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.
Dan Carley
2010-Apr-19 12:05 UTC
Re: [Puppet Users] Evaluate the value of a variable''s value
On 18 April 2010 04:24, Andrew Heagle <andrew@logaan.com> wrote:> Hi, > > Is it possible for puppet to do the equivalent to this in bash: > andrew@comet:~$ a=1 > andrew@comet:~$ x="a" > andrew@comet:~$ eval echo \$$x > 1 > > Or this perl: > #!/usr/bin/perl > $a=1; > $x="a"; > print $$x; > (Output would be 1) > > Or would I need to write a function to do this? >It''s possible with inline_template(): dan.carley@jim ~ $ puppet $a = 1 $x = "a" notice("Bad:", inline_template("<%= x %>")) notice("Good:", inline_template("<%= $x %>")) ^D notice: Scope(Class[main]): Bad: a notice: Scope(Class[main]): Good: 1 -- 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.
Andrew Heagle
2010-Apr-20 14:35 UTC
[Puppet Users] Re: Evaluate the value of a variable''s value
On Apr 19, 8:05 am, Dan Carley <dan.car...@gmail.com> wrote:> > It''s possible with inline_template(): > > dan.carley@jim ~ $ puppet > $a = 1 > $x = "a" > notice("Bad:", inline_template("<%= x %>")) > notice("Good:", inline_template("<%= $x %>")) > ^D > notice: Scope(Class[main]): Bad: a > notice: Scope(Class[main]): Good: 1That is exactly what I was looking for. Works great, thanks! Regards, Andrew -- 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.