Ohad Levy
2009-Feb-19 03:53 UTC
[Puppet Users] variables that are available inside a template
Hi, I''m looking to find a way to get the target filename inside a template. (e.g. if I have file {"/tmp/foo": content => template("foo")} I want to have a variable represent "/tmp/foo" inside the template. I''ve already tried using file, scope etc, but looking at the code, it doesn''t seems that i can access the filename inside the template (unless using a define and than using $name). Anyone has a better idea? Thanks, Ohad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews
2009-Feb-19 16:56 UTC
[Puppet Users] Re: variables that are available inside a template
could you define the filename as a variable first, somewhere within the class eg $filename = "/tmp/foo"; and pick it up in the template < %= filename %> I''ve not tried it myself but that might work Paul 2009/2/19 Ohad Levy <ohadlevy@gmail.com>> Hi, > > I''m looking to find a way to get the target filename inside a template. > (e.g. if I have > file {"/tmp/foo": content => template("foo")} I want to have a variable > represent "/tmp/foo" inside the template. > > I''ve already tried using file, scope etc, but looking at the code, it > doesn''t seems that i can access the filename inside the template (unless > using a define and than using $name). > > Anyone has a better idea? > > Thanks, > Ohad > > > >-- Paul Matthews ---------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ohad Levy
2009-Feb-20 02:58 UTC
[Puppet Users] Re: variables that are available inside a template
Thanks, I know that, but I was hoping to avoid it.. as I want to pass an array of files to the same template. is there a scope variable which define the current resource? maybe something like scope.name? Ohad On Fri, Feb 20, 2009 at 12:56 AM, paul matthews < paulsmatthews@googlemail.com> wrote:> could you define the filename as a variable first, somewhere within the > class > eg > $filename = "/tmp/foo"; > > and pick it up in the template > < %= filename %> > > I''ve not tried it myself but that might work > > Paul > > 2009/2/19 Ohad Levy <ohadlevy@gmail.com> > > Hi, >> >> I''m looking to find a way to get the target filename inside a template. >> (e.g. if I have >> file {"/tmp/foo": content => template("foo")} I want to have a variable >> represent "/tmp/foo" inside the template. >> >> I''ve already tried using file, scope etc, but looking at the code, it >> doesn''t seems that i can access the filename inside the template (unless >> using a define and than using $name). >> >> Anyone has a better idea? >> >> Thanks, >> Ohad >> >> >> > > > -- > Paul Matthews > ---------------------------------------------------------------------- > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brice Figureau
2009-Feb-20 08:21 UTC
[Puppet Users] Re: variables that are available inside a template
On Fri, 2009-02-20 at 10:58 +0800, Ohad Levy wrote:> Thanks, I know that, but I was hoping to avoid it.. as I want to pass > an array of files to the same template. > > is there a scope variable which define the current resource? maybe > something like scope.name?I think what you''re looking for is scope.resource. But I''m not sure you have access to this inside a template. But I understand your need, so that might be an interesting feature request (ie access to the current resource parameters inside a template). Open a redmine feature request and it''ll be discussed :-) -- Brice Figureau My Blog: http://www.masterzen.fr/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---