Roberto Bouza
2010-Oct-27 20:39 UTC
[Puppet Users] Variable Interpolation (double interpolation)
Hello, I have a group of variables like $a_logs_project1 = machine1 $b_logs_project2 = machine2 then on the definition I''m genrating a variable like: $machine_name = "${letter}_logs_${project}" So $machine name will be something like: a_logs_project1 Now I need to convert that (or interpolate it somehow) into the real value "machine1" So I have a variable $machine_name which has the name of the variable which has the real value. Do you have any ideas how to obtain this value? Any help will be appreciated. Thank you. -- 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.
Joe McDonagh
2010-Oct-27 22:23 UTC
Re: [Puppet Users] Variable Interpolation (double interpolation)
On 10/27/2010 04:39 PM, Roberto Bouza wrote:> Hello, > > I have a group of variables like > > $a_logs_project1 = machine1 > $b_logs_project2 = machine2 > > then on the definition I''m genrating a variable like: > > $machine_name = "${letter}_logs_${project}" > > So $machine name will be something like: a_logs_project1 > > Now I need to convert that (or interpolate it somehow) into the real > value "machine1" > > So I have a variable $machine_name which has the name of the variable > which has the real value. Do you have any ideas how to obtain this > value? > > Any help will be appreciated. > > Thank you. > >This works, but... yea: $machine_name = "machine1" $machine1 = "thordur" $value = inline_template("<%= scope.lookupvar(machine_name) -%>") notice("machine 1 is $value") -- -- Joe McDonagh Operations Engineer AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- 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.
Roberto Bouza
2010-Oct-27 23:37 UTC
[Puppet Users] Re: Variable Interpolation (double interpolation)
Thanks!!! It worked like a charm. On Oct 27, 3:23 pm, Joe McDonagh <joseph.e.mcdon...@gmail.com> wrote:> On 10/27/2010 04:39 PM, Roberto Bouza wrote: > > > > > Hello, > > > I have a group of variables like > > > $a_logs_project1 = machine1 > > $b_logs_project2 = machine2 > > > then on the definition I''m genrating a variable like: > > > $machine_name = "${letter}_logs_${project}" > > > So $machine name will be something like: a_logs_project1 > > > Now I need to convert that (or interpolate it somehow) into the real > > value "machine1" > > > So I have a variable $machine_name which has the name of the variable > > which has the real value. Do you have any ideas how to obtain this > > value? > > > Any help will be appreciated. > > > Thank you. > > This works, but... yea: > > $machine_name = "machine1" > $machine1 = "thordur" > $value = inline_template("<%= scope.lookupvar(machine_name) -%>") > notice("machine 1 is $value") > > -- > -- > Joe McDonagh > Operations Engineer > AIM: YoosingYoonickz > IRC: joe-mac on freenode > "When the going gets weird, the weird turn pro."-- 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.
Joe McDonagh
2010-Oct-28 02:00 UTC
Re: [Puppet Users] Re: Variable Interpolation (double interpolation)
On 10/27/2010 07:37 PM, Roberto Bouza wrote:> Thanks!!! > > It worked like a charm. > > On Oct 27, 3:23 pm, Joe McDonagh<joseph.e.mcdon...@gmail.com> wrote: > >FYI, if you''re using 2.6, the new pure Ruby stuff might look better. Unfortunately I have not yet deployed 2.6 for prod so I don''t have much experience using the pure Ruby DSL stuff. -- -- Joe McDonagh Operations Engineer AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- 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.
Felix Frank
2010-Oct-28 07:41 UTC
Re: [Puppet Users] Re: Variable Interpolation (double interpolation)
On 10/28/2010 04:00 AM, Joe McDonagh wrote:> On 10/27/2010 07:37 PM, Roberto Bouza wrote: >> Thanks!!! >> >> It worked like a charm. >> >> On Oct 27, 3:23 pm, Joe McDonagh<joseph.e.mcdon...@gmail.com> wrote: >> > FYI, if you''re using 2.6, the new pure Ruby stuff might look better. > Unfortunately I have not yet deployed 2.6 for prod so I don''t have much > experience using the pure Ruby DSL stuff. >While we''re talking 2.6: $logs = { a => { project1 => "machine1", }, b => { project2 => "machine2", }, } Then $machine_name = $logs[$letter][$project]. Cheers, Felix -- 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.
Roberto Bouza
2010-Oct-28 16:37 UTC
[Puppet Users] Re: Variable Interpolation (double interpolation)
Yes... this would be a better cleaner solution.. sadly we are running 0.25 still until we upgrade. Hashes are great, aren''t they? Thx On Oct 28, 12:41 am, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 10/28/2010 04:00 AM, Joe McDonagh wrote: > > > On 10/27/2010 07:37 PM, Roberto Bouza wrote: > >> Thanks!!! > > >> It worked like a charm. > > >> On Oct 27, 3:23 pm, Joe McDonagh<joseph.e.mcdon...@gmail.com> wrote: > > > FYI, if you''re using 2.6, the new pure Ruby stuff might look better. > > Unfortunately I have not yet deployed 2.6 for prod so I don''t have much > > experience using the pure Ruby DSL stuff. > > While we''re talking 2.6: > > $logs = { > a => { > project1 => "machine1", > }, > b => { > project2 => "machine2", > }, > > } > > Then $machine_name = $logs[$letter][$project]. > > Cheers, > Felix-- 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.