piavlo
2011-Aug-12 18:06 UTC
[Puppet Users] need help with using tamplate function in Ruby DSL
HI,
I''m trying to use tamplate function in ruby dsl but I miserably fail.
Then I just invoke it without using it in any resource like this
template [''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''],
it works and i see
....
debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template
nagios/conf.d/app_alerts/ssa_nagios_contact.erb
debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/
ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/
modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in
0.00
seconds
debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/
ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/
nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00
seconds
...
But obviously i need to use it inside resource - which does not work
file(
"#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc'']
[''_id'']}.cfg",
:content => template [''nagios/conf.d/app_alerts/
ssa_nagios_contact.erb''],
:ensure => :file,
:owner => ''root'',
:group => ''root'',
:mode => 0755,
:require => "File[#{nagios_confdir}/app_alerts/ssa/contacts]"
)
end
this fails with:
debug: importing ''/etc/puppet/modules/nagios/manifests/
ssa_nagios_contacts.rb'' in environment production
err: (eval):53:in `parse_ruby_file'': compile error
(eval):42: syntax error, unexpected tLBRACK, expecting kDO or
''{'' or
''(''
:content => template [''nagios/conf.d/app_alerts/
ssa_...
^
(eval):42: syntax error, unexpected '','', expecting
kEND
(eval):44: syntax error, unexpected '','', expecting
kEND
(eval):45: syntax error, unexpected '','', expecting
kEND
(eval):47: syntax error, unexpected '')'', expecting
kEND
(eval):53: syntax error, unexpected $end, expecting kEND
Please help.
Thanks
Alex
--
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.
Craig White
2011-Aug-12 18:16 UTC
Re: [Puppet Users] need help with using tamplate function in Ruby DSL
template should be a string, not an array
content => template("''nagios/ssa_nagios_contact.erb") #
assuming it''s in modules/nagios/templates
also, I think your ''require'' should probably look like
require => File["#{nagios_confdir}/app_alerts/ssa/contacts"],
but maybe your way will work
Craig
On Aug 12, 2011, at 11:06 AM, piavlo wrote:
>
> HI,
>
> I''m trying to use tamplate function in ruby dsl but I miserably
fail.
> Then I just invoke it without using it in any resource like this
>
> template
[''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''],
>
> it works and i see
>
> ....
> debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template
> nagios/conf.d/app_alerts/ssa_nagios_contact.erb
> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/
> ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/
> modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in
> 0.00
> seconds
> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/
> ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/
> nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00
> seconds
> ...
>
> But obviously i need to use it inside resource - which does not work
>
> file(
"#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc'']
> [''_id'']}.cfg",
> :content => template [''nagios/conf.d/app_alerts/
> ssa_nagios_contact.erb''],
> :ensure => :file,
> :owner => ''root'',
> :group => ''root'',
> :mode => 0755,
> :require =>
"File[#{nagios_confdir}/app_alerts/ssa/contacts]" )
>
> end
>
> this fails with:
>
> debug: importing ''/etc/puppet/modules/nagios/manifests/
> ssa_nagios_contacts.rb'' in environment production
> err: (eval):53:in `parse_ruby_file'': compile error
> (eval):42: syntax error, unexpected tLBRACK, expecting kDO or
''{'' or
> ''(''
> :content => template [''nagios/conf.d/app_alerts/
> ssa_...
>
> ^
> (eval):42: syntax error, unexpected '','', expecting
> kEND
> (eval):44: syntax error, unexpected '','', expecting
> kEND
> (eval):45: syntax error, unexpected '','', expecting
> kEND
> (eval):47: syntax error, unexpected '')'', expecting
> kEND
> (eval):53: syntax error, unexpected $end, expecting kEND
>
> Please help.
>
> Thanks
> Alex
>
> --
> 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.
>
--
Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com
1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com
Need help communicating between generations at work to achieve your desired
success? Let us help!
--
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.
piavlo
2011-Aug-12 18:53 UTC
[Puppet Users] Re: need help with using tamplate function in Ruby DSL
Hi Craig, You suggestions are correct for Puppet DSL but this code is a Ruby DSL http://projects.puppetlabs.com/projects/1/wiki/Ruby_Dsl On Aug 12, 9:16 pm, Craig White <craig.wh...@ttiltd.com> wrote:> template should be a string, not an array > > content => template("''nagios/ssa_nagios_contact.erb") # assuming it''s in modules/nagios/templates > > also, I think your ''require'' should probably look like > > require => File["#{nagios_confdir}/app_alerts/ssa/contacts"], > > but maybe your way will work > > Craig > > On Aug 12, 2011, at 11:06 AM, piavlo wrote: > > > > > > > > > > > > > HI, > > > I''m trying to use tamplate function in ruby dsl but I miserably fail. > > Then I just invoke it without using it in any resource like this > > > template [''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''], > > > it works and i see > > > .... > > debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template > > nagios/conf.d/app_alerts/ssa_nagios_contact.erb > > debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > > ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/ > > modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in > > 0.00 > > seconds > > debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > > ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/ > > nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00 > > seconds > > ... > > > But obviously i need to use it inside resource - which does not work > > > file( "#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc''] > > [''_id'']}.cfg", > > :content => template [''nagios/conf.d/app_alerts/ > > ssa_nagios_contact.erb''], > > :ensure => :file, > > :owner => ''root'', > > :group => ''root'', > > :mode => 0755, > > :require => "File[#{nagios_confdir}/app_alerts/ssa/contacts]" ) > > > end > > > this fails with: > > > debug: importing ''/etc/puppet/modules/nagios/manifests/ > > ssa_nagios_contacts.rb'' in environment production > > err: (eval):53:in `parse_ruby_file'': compile error > > (eval):42: syntax error, unexpected tLBRACK, expecting kDO or ''{'' or > > ''('' > > :content => template [''nagios/conf.d/app_alerts/ > > ssa_... > > > ^ > > (eval):42: syntax error, unexpected '','', expecting > > kEND > > (eval):44: syntax error, unexpected '','', expecting > > kEND > > (eval):45: syntax error, unexpected '','', expecting > > kEND > > (eval):47: syntax error, unexpected '')'', expecting > > kEND > > (eval):53: syntax error, unexpected $end, expecting kEND > > > Please help. > > > Thanks > > Alex > > > -- > > 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 athttp://groups.google.com/group/puppet-users?hl=en. > > -- > Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.wh...@ttiltd.com > 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~www.ttiassessments.com > > Need help communicating between generations at work to achieve your desired success? Let us help!-- 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.
piavlo
2011-Aug-15 21:30 UTC
[Puppet Users] Re: need help with using tamplate function in Ruby DSL
Is there any Ruby DSL expert that has a clue how to use the template function properly? Thanks On Aug 12, 9:06 pm, piavlo <lolitus...@gmail.com> wrote:> HI, > > I''m trying to use tamplate function in ruby dsl but I miserably fail. > Then I just invoke it without using it in any resource like this > > template [''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''], > > it works and i see > > .... > debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template > nagios/conf.d/app_alerts/ssa_nagios_contact.erb > debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/ > modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in > 0.00 > seconds > debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/ > nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00 > seconds > ... > > But obviously i need to use it inside resource - which does not work > > file( "#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc''] > [''_id'']}.cfg", > :content => template [''nagios/conf.d/app_alerts/ > ssa_nagios_contact.erb''], > :ensure => :file, > :owner => ''root'', > :group => ''root'', > :mode => 0755, > :require => "File[#{nagios_confdir}/app_alerts/ssa/contacts]" ) > > end > > this fails with: > > debug: importing ''/etc/puppet/modules/nagios/manifests/ > ssa_nagios_contacts.rb'' in environment production > err: (eval):53:in `parse_ruby_file'': compile error > (eval):42: syntax error, unexpected tLBRACK, expecting kDO or ''{'' or > ''('' > :content => template [''nagios/conf.d/app_alerts/ > ssa_... > > ^ > (eval):42: syntax error, unexpected '','', expecting > kEND > (eval):44: syntax error, unexpected '','', expecting > kEND > (eval):45: syntax error, unexpected '','', expecting > kEND > (eval):47: syntax error, unexpected '')'', expecting > kEND > (eval):53: syntax error, unexpected $end, expecting kEND > > Please help. > > Thanks > Alex-- 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.
Nan Liu
2011-Aug-15 21:54 UTC
Re: [Puppet Users] Re: need help with using tamplate function in Ruby DSL
In the wiki link you sent, I would try: call_function(:template, ...) Thanks, Nan On Mon, Aug 15, 2011 at 2:30 PM, piavlo <lolitushka@gmail.com> wrote:> Is there any Ruby DSL expert that has a clue how to use the template > function properly? > > Thanks > > On Aug 12, 9:06 pm, piavlo <lolitus...@gmail.com> wrote: >> HI, >> >> I''m trying to use tamplate function in ruby dsl but I miserably fail. >> Then I just invoke it without using it in any resource like this >> >> template [''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''], >> >> it works and i see >> >> .... >> debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template >> nagios/conf.d/app_alerts/ssa_nagios_contact.erb >> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ >> ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/ >> modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in >> 0.00 >> seconds >> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ >> ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/ >> nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00 >> seconds >> ... >> >> But obviously i need to use it inside resource - which does not work >> >> file( "#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc''] >> [''_id'']}.cfg", >> :content => template [''nagios/conf.d/app_alerts/ >> ssa_nagios_contact.erb''], >> :ensure => :file, >> :owner => ''root'', >> :group => ''root'', >> :mode => 0755, >> :require => "File[#{nagios_confdir}/app_alerts/ssa/contacts]" ) >> >> end >> >> this fails with: >> >> debug: importing ''/etc/puppet/modules/nagios/manifests/ >> ssa_nagios_contacts.rb'' in environment production >> err: (eval):53:in `parse_ruby_file'': compile error >> (eval):42: syntax error, unexpected tLBRACK, expecting kDO or ''{'' or >> ''('' >> :content => template [''nagios/conf.d/app_alerts/ >> ssa_... >> >> ^ >> (eval):42: syntax error, unexpected '','', expecting >> kEND >> (eval):44: syntax error, unexpected '','', expecting >> kEND >> (eval):45: syntax error, unexpected '','', expecting >> kEND >> (eval):47: syntax error, unexpected '')'', expecting >> kEND >> (eval):53: syntax error, unexpected $end, expecting kEND >> >> Please help. >> >> Thanks >> Alex > > -- > 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.
piavlo
2011-Aug-16 03:02 UTC
[Puppet Users] Re: need help with using tamplate function in Ruby DSL
Nau , thank you so much it works !!! I was somehow stuck after trying other example based on the wiki call_function "notice", ["params1"] which did not work while the correct example did not draw my attention call_function(:realize, ''Foo[bar]'') Both examples seem to be valid, just syntactically different - any idea what''s the functional diff between them and why is that only the second one works for me? Thanks Alex On Aug 16, 12:54 am, Nan Liu <n...@puppetlabs.com> wrote:> In the wiki link you sent, I would try: call_function(:template, ...) > > Thanks, > > Nan > > > > > > > > On Mon, Aug 15, 2011 at 2:30 PM, piavlo <lolitus...@gmail.com> wrote: > > Is there any Ruby DSL expert that has a clue how to use the template > > function properly? > > > Thanks > > > On Aug 12, 9:06 pm, piavlo <lolitus...@gmail.com> wrote: > >> HI, > > >> I''m trying to use tamplate function in ruby dsl but I miserably fail. > >> Then I just invoke it without using it in any resource like this > > >> template [''nagios/conf.d/app_alerts/ssa_nagios_contact.erb''], > > >> it works and i see > > >> .... > >> debug: Scope(Class[Nagios::Ssa_nagios_contacts]): Retrieving template > >> nagios/conf.d/app_alerts/ssa_nagios_contact.erb > >> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > >> ssa_nagios_contact.erb]: Bound template variables for /etc/puppet/ > >> modules/nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in > >> 0.00 > >> seconds > >> debug: template[/etc/puppet/modules/nagios/templates/conf.d/app_alerts/ > >> ssa_nagios_contact.erb]: Interpolated template /etc/puppet/modules/ > >> nagios/templates/conf.d/app_alerts/ssa_nagios_contact.erb in 0.00 > >> seconds > >> ... > > >> But obviously i need to use it inside resource - which does not work > > >> file( "#{nagios_confdir}/app_alerts/ssa/contacts/#{x[''doc''] > >> [''_id'']}.cfg", > >> :content => template [''nagios/conf.d/app_alerts/ > >> ssa_nagios_contact.erb''], > >> :ensure => :file, > >> :owner => ''root'', > >> :group => ''root'', > >> :mode => 0755, > >> :require => "File[#{nagios_confdir}/app_alerts/ssa/contacts]" ) > > >> end > > >> this fails with: > > >> debug: importing ''/etc/puppet/modules/nagios/manifests/ > >> ssa_nagios_contacts.rb'' in environment production > >> err: (eval):53:in `parse_ruby_file'': compile error > >> (eval):42: syntax error, unexpected tLBRACK, expecting kDO or ''{'' or > >> ''('' > >> :content => template [''nagios/conf.d/app_alerts/ > >> ssa_... > > >> ^ > >> (eval):42: syntax error, unexpected '','', expecting > >> kEND > >> (eval):44: syntax error, unexpected '','', expecting > >> kEND > >> (eval):45: syntax error, unexpected '','', expecting > >> kEND > >> (eval):47: syntax error, unexpected '')'', expecting > >> kEND > >> (eval):53: syntax error, unexpected $end, expecting kEND > > >> Please help. > > >> Thanks > >> Alex > > > -- > > 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 athttp://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.