Douglas Garstang
2011-Aug-08 18:19 UTC
[Puppet Users] Hash Interpolation inside double quotes?
I''ve got this: file { ''/opt/sugarsync/tomcat/tomcat-home/current'': ensure => "tomcat-$config[''tomcat_version_server'']"; where $config[''tomcat_version_server''] was set with extlookup (the yaml one), by loading: --- tomcat_config: tomcat_version_server: 6.0.20-1 tomcat_version_libs: 1.0-1 Inside those double quotes, where variable interpolation is supposed to occur, I''m actually getting: tomcat-tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] Not ''6.0.20-1''. How can I interpolate a hash inside a string? Is this a bug? Doug. -- 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.
Brian Gallew
2011-Aug-08 18:22 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
String interpolation in the Puppet DSL is strictly variable->string, and does not handle arrays. For what you want, use inline_template("tomcat-<%= $config[''tomcat_version_server''] %>") On Aug 8, 2011, at 11:19 AM, Douglas Garstang wrote:> I''ve got this: > > file { > ''/opt/sugarsync/tomcat/tomcat-home/current'': > ensure => "tomcat-$config[''tomcat_version_server'']"; > > where $config[''tomcat_version_server''] was set with extlookup (the yaml one), by loading: > > --- > tomcat_config: > tomcat_version_server: 6.0.20-1 > tomcat_version_libs: 1.0-1 > > Inside those double quotes, where variable interpolation is supposed to occur, I''m actually getting: > > tomcat-tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] > > Not ''6.0.20-1''. How can I interpolate a hash inside a string? Is this a bug? > > Doug. > > -- > 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.
Douglas Garstang
2011-Aug-08 18:52 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
Hmmm.... I tried that, with: file { ''/opt/sugarsync/tomcat/tomcat-home/current'': ensure => inline_template("tomcat-<%$config[''tomcat_version_server''] %>"); } and that results in: Aug 8 11:51:03 hpma01p1 puppet-master[18712]: compile error (erb):1: no .<digit> floating literal anymore; put 0 before dot _erbout = ''''; _erbout.concat "tomcat-"; _erbout.concat(( tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] ).to_s); _erbout ^ (erb):1: syntax error _erbout = ''''; _erbout.concat "tomcat-"; _erbout.concat(( tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] ).to_s); _erbout ^ (erb):1: syntax error _erbout = ''''; _erbout.concat "tomcat-"; _erbout.concat(( tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] ).to_s); _erbout ^ (erb):1: no .<digit> floating literal anymore; put 0 before dot _erbout = ''''; _erbout.concat "tomcat-"; _erbout.concat(( tomcat_versi On Mon, Aug 8, 2011 at 11:22 AM, Brian Gallew <geek@gallew.org> wrote:> String interpolation in the Puppet DSL is strictly variable->string, and > does not handle arrays. For what you want, use > inline_template("tomcat-<%= $config[''tomcat_version_server''] %>") > > > On Aug 8, 2011, at 11:19 AM, Douglas Garstang wrote: > > > I''ve got this: > > > > file { > > ''/opt/sugarsync/tomcat/tomcat-home/current'': > > ensure => "tomcat-$config[''tomcat_version_server'']"; > > > > where $config[''tomcat_version_server''] was set with extlookup (the yaml > one), by loading: > > > > --- > > tomcat_config: > > tomcat_version_server: 6.0.20-1 > > tomcat_version_libs: 1.0-1 > > > > Inside those double quotes, where variable interpolation is supposed to > occur, I''m actually getting: > > > > > tomcat-tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] > > > > Not ''6.0.20-1''. How can I interpolate a hash inside a string? Is this a > bug? > > > > Doug. > > > > -- > > 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. > >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.
vagn scott
2011-Aug-08 19:47 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
On 08/08/2011 02:52 PM, Douglas Garstang wrote:> > file { > ''/opt/sugarsync/tomcat/tomcat-home/current'': > ensure => inline_template("tomcat-<%= > $config[''tomcat_version_server''] %>"); > } >Try without the dollar sign: file { ''/opt/sugarsync/tomcat/tomcat-home/current'': ensure => inline_template("tomcat-<%= config[''tomcat_version_server''] %>"); } -- 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.
Douglas Garstang
2011-Aug-08 19:58 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
Thanks. That did it. Ugly... On Mon, Aug 8, 2011 at 12:47 PM, vagn scott <vagnscott@gmail.com> wrote:> On 08/08/2011 02:52 PM, Douglas Garstang wrote: > >> >> file { >> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >> ensure => inline_template("tomcat-<%= $config[''tomcat_version_ >> **server''] %>"); >> } >> >> > Try without the dollar sign: > > > file { > ''/opt/sugarsync/tomcat/tomcat-**home/current'': > ensure => inline_template("tomcat-<%> config[''tomcat_version_server''**] %>"); > } > > -- > 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 <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.
Scott Smith
2011-Aug-08 20:01 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
Works the same as it does in Bourne shell. If you want to use double quotes inside a double-quoted string, you have to escape them. Or use single quotes. On Mon, Aug 8, 2011 at 12:58 PM, Douglas Garstang <doug.garstang@gmail.com>wrote:> Thanks. That did it. Ugly... > > > On Mon, Aug 8, 2011 at 12:47 PM, vagn scott <vagnscott@gmail.com> wrote: > >> On 08/08/2011 02:52 PM, Douglas Garstang wrote: >> >>> >>> file { >>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>> ensure => inline_template("tomcat-<%= $config[''tomcat_version_ >>> **server''] %>"); >>> } >>> >>> >> Try without the dollar sign: >> >> >> file { >> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >> ensure => inline_template("tomcat-<%>> config[''tomcat_version_server''**] %>"); >> } >> >> -- >> 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 <puppet-users%2Bunsubscribe@googlegroups.com>. >> For more options, visit this group at http://groups.google.com/** >> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >> . >> >> > > > -- > Regards, > > Douglas Garstang > http://www.linkedin.com/in/garstang > Email: doug.garstang@gmail.com > Cell: +1-805-340-5627 > > -- > 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.
Douglas Garstang
2011-Aug-08 20:09 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
I wasn''t trying to use double quotes inside a double quoted string. On Mon, Aug 8, 2011 at 1:01 PM, Scott Smith <scott@ohlol.net> wrote:> Works the same as it does in Bourne shell. If you want to use double quotes > inside a double-quoted string, you have to escape them. Or use single > quotes. > > On Mon, Aug 8, 2011 at 12:58 PM, Douglas Garstang <doug.garstang@gmail.com > > wrote: > >> Thanks. That did it. Ugly... >> >> >> On Mon, Aug 8, 2011 at 12:47 PM, vagn scott <vagnscott@gmail.com> wrote: >> >>> On 08/08/2011 02:52 PM, Douglas Garstang wrote: >>> >>>> >>>> file { >>>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>>> ensure => inline_template("tomcat-<%>>>> $config[''tomcat_version_**server''] %>"); >>>> } >>>> >>>> >>> Try without the dollar sign: >>> >>> >>> file { >>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>> ensure => inline_template("tomcat-<%>>> config[''tomcat_version_server''**] %>"); >>> } >>> >>> -- >>> 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 <puppet-users%2Bunsubscribe@googlegroups.com>. >>> For more options, visit this group at http://groups.google.com/** >>> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>> . >>> >>> >> >> >> -- >> Regards, >> >> Douglas Garstang >> http://www.linkedin.com/in/garstang >> Email: doug.garstang@gmail.com >> Cell: +1-805-340-5627 >> >> -- >> 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. >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.
Scott Smith
2011-Aug-08 20:11 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
D''oh, looks like I need to refresh my vision prescription :( On Mon, Aug 8, 2011 at 1:09 PM, Douglas Garstang <doug.garstang@gmail.com>wrote:> I wasn''t trying to use double quotes inside a double quoted string. > > > On Mon, Aug 8, 2011 at 1:01 PM, Scott Smith <scott@ohlol.net> wrote: > >> Works the same as it does in Bourne shell. If you want to use double >> quotes inside a double-quoted string, you have to escape them. Or use single >> quotes. >> >> On Mon, Aug 8, 2011 at 12:58 PM, Douglas Garstang < >> doug.garstang@gmail.com> wrote: >> >>> Thanks. That did it. Ugly... >>> >>> >>> On Mon, Aug 8, 2011 at 12:47 PM, vagn scott <vagnscott@gmail.com> wrote: >>> >>>> On 08/08/2011 02:52 PM, Douglas Garstang wrote: >>>> >>>>> >>>>> file { >>>>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>>>> ensure => inline_template("tomcat-<%>>>>> $config[''tomcat_version_**server''] %>"); >>>>> } >>>>> >>>>> >>>> Try without the dollar sign: >>>> >>>> >>>> file { >>>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>>> ensure => inline_template("tomcat-<%>>>> config[''tomcat_version_server''**] %>"); >>>> } >>>> >>>> -- >>>> 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 <puppet-users%2Bunsubscribe@googlegroups.com>. >>>> For more options, visit this group at http://groups.google.com/** >>>> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>>> . >>>> >>>> >>> >>> >>> -- >>> Regards, >>> >>> Douglas Garstang >>> http://www.linkedin.com/in/garstang >>> Email: doug.garstang@gmail.com >>> Cell: +1-805-340-5627 >>> >>> -- >>> 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. >> > > > > -- > Regards, > > Douglas Garstang > http://www.linkedin.com/in/garstang > Email: doug.garstang@gmail.com > Cell: +1-805-340-5627 > > -- > 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.
Douglas Garstang
2011-Aug-08 20:26 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
But, I would like to replace: file { "${tomcat_home_dir}/current": ensure => inline_template("tomcat-<%config[''tomcat_version_server''] %>"); } with: file { "$config[''tomcat_home_dir'']/current": ensure => inline_template("tomcat-<%config[''tomcat_version_server''] %>"); } ... and I don''t think that will work. Obviously, I can''t use an inline template here... Doug. On Mon, Aug 8, 2011 at 1:11 PM, Scott Smith <scott@ohlol.net> wrote:> D''oh, looks like I need to refresh my vision prescription :( > > > On Mon, Aug 8, 2011 at 1:09 PM, Douglas Garstang <doug.garstang@gmail.com>wrote: > >> I wasn''t trying to use double quotes inside a double quoted string. >> >> >> On Mon, Aug 8, 2011 at 1:01 PM, Scott Smith <scott@ohlol.net> wrote: >> >>> Works the same as it does in Bourne shell. If you want to use double >>> quotes inside a double-quoted string, you have to escape them. Or use single >>> quotes. >>> >>> On Mon, Aug 8, 2011 at 12:58 PM, Douglas Garstang < >>> doug.garstang@gmail.com> wrote: >>> >>>> Thanks. That did it. Ugly... >>>> >>>> >>>> On Mon, Aug 8, 2011 at 12:47 PM, vagn scott <vagnscott@gmail.com>wrote: >>>> >>>>> On 08/08/2011 02:52 PM, Douglas Garstang wrote: >>>>> >>>>>> >>>>>> file { >>>>>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>>>>> ensure => inline_template("tomcat-<%>>>>>> $config[''tomcat_version_**server''] %>"); >>>>>> } >>>>>> >>>>>> >>>>> Try without the dollar sign: >>>>> >>>>> >>>>> file { >>>>> ''/opt/sugarsync/tomcat/tomcat-**home/current'': >>>>> ensure => inline_template("tomcat-<%>>>>> config[''tomcat_version_server''**] %>"); >>>>> } >>>>> >>>>> -- >>>>> 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<puppet-users%2Bunsubscribe@googlegroups.com> >>>>> . >>>>> For more options, visit this group at http://groups.google.com/** >>>>> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>>>> . >>>>> >>>>> >>>> >>>> >>>> -- >>>> Regards, >>>> >>>> Douglas Garstang >>>> http://www.linkedin.com/in/garstang >>>> Email: doug.garstang@gmail.com >>>> Cell: +1-805-340-5627 >>>> >>>> -- >>>> 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. >>> >> >> >> >> -- >> Regards, >> >> Douglas Garstang >> http://www.linkedin.com/in/garstang >> Email: doug.garstang@gmail.com >> Cell: +1-805-340-5627 >> >> -- >> 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. >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.
vagn scott
2011-Aug-08 20:37 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
On 08/08/2011 04:26 PM, Douglas Garstang wrote:> But, I would like to replace: > > file { > "${tomcat_home_dir}/current": > ensure => inline_template("tomcat-<%= > config[''tomcat_version_server''] %>"); > } > > with: > > file { > "$config[''tomcat_home_dir'']/current": > ensure => inline_template("tomcat-<%= > config[''tomcat_version_server''] %>"); > } >$f = inline_template("<%= config[''tomcat_home_dir''] -%>/current") $v = inline_template("tomcat-<%= config[''tomcat_version_server''] %>") file { "${f}": ensure => "${v}", } Or similar. -- vagn -- 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.
Thomas Bellman
2011-Aug-08 21:18 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
Douglas Garstang wrote:> How can I interpolate a hash inside a string?Like this: "tomcat-${config[''tomcat_version_server'']}" The curly braces groups things so the parser knows that the variable expression to expand doesn''t end after the "g" in "config". I''m not sure where this is documented, though. I can''t find it after a quick look in the language guide, where I had expected it to be. /Bellman -- 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.
Stefan Schulte
2011-Aug-08 21:25 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
On Mon, Aug 08, 2011 at 11:19:36AM -0700, Douglas Garstang wrote:> I''ve got this: > > file { > ''/opt/sugarsync/tomcat/tomcat-home/current'': > ensure => "tomcat-$config[''tomcat_version_server'']"; > > where $config[''tomcat_version_server''] was set with extlookup (the yaml > one), by loading: > > --- > tomcat_config: > tomcat_version_server: 6.0.20-1 > tomcat_version_libs: 1.0-1 > > Inside those double quotes, where variable interpolation is supposed to > occur, I''m actually getting: > > tomcat-tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] > > Not ''6.0.20-1''. How can I interpolate a hash inside a string? Is this a bug? > > Doug. >IIRC it should read "tomcat-${config[''tomcat_version_server'']}" (notice the curling braces). Otherwise puppet will print the hash first (and concats all keys and values) and then just put [''tomcat_version_server''] after it. Does the above suggestion work? -Stefan
Douglas Garstang
2011-Aug-08 21:57 UTC
Re: [Puppet Users] Hash Interpolation inside double quotes?
Seems to work... Thanks. I got this: file { "${config[''tomcat_home_dir'']}/current": ensure => "tomcat-${config[''tomcat_version_server'']}", require => Package[''ss-tomcat-server'']; } Slightly cleaner than the inline template approach (which didn''t work for the name anyway). Doug. On Mon, Aug 8, 2011 at 2:25 PM, Stefan Schulte < stefan.schulte@taunusstein.net> wrote:> On Mon, Aug 08, 2011 at 11:19:36AM -0700, Douglas Garstang wrote: > > I''ve got this: > > > > file { > > ''/opt/sugarsync/tomcat/tomcat-home/current'': > > ensure => "tomcat-$config[''tomcat_version_server'']"; > > > > where $config[''tomcat_version_server''] was set with extlookup (the yaml > > one), by loading: > > > > --- > > tomcat_config: > > tomcat_version_server: 6.0.20-1 > > tomcat_version_libs: 1.0-1 > > > > Inside those double quotes, where variable interpolation is supposed to > > occur, I''m actually getting: > > > > > tomcat-tomcat_version_libs1.0-1tomcat_version_server6.0.20-1[''tomcat_version_server''] > > > > Not ''6.0.20-1''. How can I interpolate a hash inside a string? Is this a > bug? > > > > Doug. > > > IIRC it should read "tomcat-${config[''tomcat_version_server'']}" (notice > the curling braces). Otherwise puppet will print the hash first (and > concats all keys and values) and then just put [''tomcat_version_server''] > after it. > > Does the above suggestion work? > > -Stefan >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.