Pete Emerson
2009-Aug-19 18:41 UTC
[Puppet Users] Expanding templates into files for testing purposes
According to http://reductivelabs.com/trac/puppet/wiki/PuppetTemplating I can do this for template syntax checking: erb -x -T ''-'' mytemplate.erb | ruby -c Is there a way to feed ruby values for the variables inside the template and see what the file will look like on a target machine? Pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Vaughan
2009-Aug-20 10:16 UTC
[Puppet Users] Re: Expanding templates into files for testing purposes
I usually just copy the erb, set the variables at the top and then run it. Not too elegant, but it works for testing. Trevor On Wed, Aug 19, 2009 at 14:41, Pete Emerson<pemerson@gmail.com> wrote:> > According to http://reductivelabs.com/trac/puppet/wiki/PuppetTemplating > > I can do this for template syntax checking: > > erb -x -T ''-'' mytemplate.erb | ruby -c > > Is there a way to feed ruby values for the variables inside the > template and see what the file will look like on a target machine? > > Pete > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pete Emerson
2009-Aug-20 16:04 UTC
[Puppet Users] Re: Expanding templates into files for testing purposes
I''m unfortunately ruby ignorant, here''s what I''ve
tried:
My file test.erb:
{ "config" :
{
"datacenter":"<%= datacenter %>"
}
}
I''ll change that to populate the datacenter variable:
$datacenter = ''hello''
{ "config" :
{
"datacenter":"<%= datacenter %>"
}
}
and then run ruby:
$ ruby test.erb
test.erb:2: syntax error
test.erb:4: syntax error
"datacenter":"<%= datacenter %>"
^
test.erb:5: syntax error
I''m missing something simple either in my test.erb or the way I run
ruby on it, or both.
Pete
On Thu, Aug 20, 2009 at 3:16 AM, Trevor Vaughan<peiriannydd@gmail.com>
wrote:>
> I usually just copy the erb, set the variables at the top and then run it.
>
> Not too elegant, but it works for testing.
>
> Trevor
>
> On Wed, Aug 19, 2009 at 14:41, Pete Emerson<pemerson@gmail.com>
wrote:
>>
>> According to http://reductivelabs.com/trac/puppet/wiki/PuppetTemplating
>>
>> I can do this for template syntax checking:
>>
>> erb -x -T ''-'' mytemplate.erb | ruby -c
>>
>> Is there a way to feed ruby values for the variables inside the
>> template and see what the file will look like on a target machine?
>>
>> Pete
>>
>> >
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-Aug-21 02:23 UTC
[Puppet Users] Re: Expanding templates into files for testing purposes
try something like this:
cat a.erb
<%
datacenter="Moon"
description="less heating expanses here"
%>
{ "config" :
{
"datacenter":"<%= datacenter %>"
"description":"<%= description %>"
}
}
erb a.erb
{ "config" :
{
"datacenter":"Moon"
"description":"less heating expanses here"
}
}
On Fri, Aug 21, 2009 at 12:04 AM, Pete Emerson <pemerson@gmail.com> wrote:
>
> I''m unfortunately ruby ignorant, here''s what
I''ve tried:
>
> My file test.erb:
>
> { "config" :
> {
> "datacenter":"<%= datacenter %>"
> }
> }
>
> I''ll change that to populate the datacenter variable:
>
> $datacenter = ''hello''
> { "config" :
> {
> "datacenter":"<%= datacenter %>"
> }
> }
>
> and then run ruby:
>
> $ ruby test.erb
> test.erb:2: syntax error
> test.erb:4: syntax error
> "datacenter":"<%= datacenter %>"
> ^
> test.erb:5: syntax error
>
> I''m missing something simple either in my test.erb or the way I
run
> ruby on it, or both.
>
> Pete
>
> On Thu, Aug 20, 2009 at 3:16 AM, Trevor
Vaughan<peiriannydd@gmail.com>
> wrote:
> >
> > I usually just copy the erb, set the variables at the top and then run
> it.
> >
> > Not too elegant, but it works for testing.
> >
> > Trevor
> >
> > On Wed, Aug 19, 2009 at 14:41, Pete Emerson<pemerson@gmail.com>
wrote:
> >>
> >> According to
http://reductivelabs.com/trac/puppet/wiki/PuppetTemplating
> >>
> >> I can do this for template syntax checking:
> >>
> >> erb -x -T ''-'' mytemplate.erb | ruby -c
> >>
> >> Is there a way to feed ruby values for the variables inside the
> >> template and see what the file will look like on a target machine?
> >>
> >> Pete
> >>
> >> >
> >>
> >
> > >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---