Jay Christopherson
2013-Jul-30 17:32 UTC
[Puppet Users] Failed to parse template, wrong number of arguments (create_resources)
I''m having some issues trying to track down a problem I''m having parsing a simple template, using create_resources and Hiera. Here''s my setup (abridged): ../hieradata/settings.yaml: *global:* * variables:* * env: foo* * * *appSpecific:* * serverName: someServer* ../modules/test/manifests/init.pp: *class test {* * create_resources(test::variables, hiera(''global''))* * $appcfg = hiera(''appSpecific'')* * * * define variables($env) {* * file { "app_cfg":* * path => "/etc/app/app.cfg",* * owner => root,* * group => root,* * mode => 644,* * notify => Service["app"],* * content => template("test/$env.cfg.erb"),* * }* * }* * * * * *.....* *}* * * ../templates/foo.cfg.erg: * ServerName <%= appcfg[''serverName''] %>* * * And this is the error I get: *err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template test/foo.cfg.erb:* * Filepath: /etc/puppet/modules/test/templates/foo.cfg.erb* * Line: 1* * Detail: wrong number of arguments* * at /etc/puppet/modules/test/manifests/init.pp:12 on node appnode* If I commend out the "create_resources" and the "define" blocks, the template works just fine. I''m guessing maybe there is a scope issue here or something, but I haven''t been able to track it down. I''ve tried this: *ServerName <%= scope.lookupvar(test::appcfg[''serverName'']) %>* * * but still no workie. Any pointers or advice would be appreciated. * * -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Jay Christopherson
2013-Jul-30 18:32 UTC
[Puppet Users] Re: Failed to parse template, wrong number of arguments (create_resources)
Ok, I figured out my first issues, which was a scope issue. There template reference works as: ServerName <%= scope.lookupvar(''test::appcfg::serverName'') %> Now I have something like this, that *was* working: *<% appcfg[''backends''][''nodes''].each do |server| -%>* * <%= server %>* *<% end -%>* but I can''t quite seem to find the correct scope syntax to make it work. I''ve tried a few variations, but haven''t hit on it yet. On Tue, Jul 30, 2013 at 10:32 AM, Jay Christopherson <jc.listmail@gmail.com>wrote:> I''m having some issues trying to track down a problem I''m having parsing a > simple template, using create_resources and Hiera. Here''s my setup > (abridged): > > ../hieradata/settings.yaml: > > *global:* > * variables:* > * env: foo* > * > * > *appSpecific:* > * serverName: someServer* > > > ../modules/test/manifests/init.pp: > > *class test {* > * create_resources(test::variables, hiera(''global''))* > * $appcfg = hiera(''appSpecific'')* > * > * > * define variables($env) {* > * file { "app_cfg":* > * path => "/etc/app/app.cfg",* > * owner => root,* > * group => root,* > * mode => 644,* > * notify => Service["app"],* > * content => template("test/$env.cfg.erb"),* > * }* > * }* > * > * > * > * > *.....* > *}* > * > * > ../templates/foo.cfg.erg: > > * ServerName <%= appcfg[''serverName''] %>* > * > * > And this is the error I get: > > *err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Failed to parse template test/foo.cfg.erb:* > * Filepath: /etc/puppet/modules/test/templates/foo.cfg.erb* > * Line: 1* > * Detail: wrong number of arguments* > * at /etc/puppet/modules/test/manifests/init.pp:12 on node appnode* > > > If I commend out the "create_resources" and the "define" blocks, the > template works just fine. I''m guessing maybe there is a scope issue here > or something, but I haven''t been able to track it down. I''ve tried this: > > *ServerName <%= scope.lookupvar(test::appcfg[''serverName'']) %>* > * > * > but still no workie. > > Any pointers or advice would be appreciated. > > > * > * > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Jay Christopherson
2013-Jul-30 18:34 UTC
[Puppet Users] Re: Failed to parse template, wrong number of arguments (create_resources)
And I guess I solved my own issues. I muddled around and this syntax works: *<% scope[''test::appcfg''][''backends''][''nodes''].each do |server| -%>* * <%= server %>* *<% end -%>* On Tue, Jul 30, 2013 at 11:32 AM, Jay Christopherson <jc.listmail@gmail.com>wrote:> Ok, I figured out my first issues, which was a scope issue. There > template reference works as: > > ServerName <%= scope.lookupvar(''test::appcfg::serverName'') %> > > Now I have something like this, that *was* working: > > *<% appcfg[''backends''][''nodes''].each do |server| -%>* > * <%= server %>* > *<% end -%>* > > but I can''t quite seem to find the correct scope syntax to make it work. > I''ve tried a few variations, but haven''t hit on it yet. > > > On Tue, Jul 30, 2013 at 10:32 AM, Jay Christopherson < > jc.listmail@gmail.com> wrote: > >> I''m having some issues trying to track down a problem I''m having parsing >> a simple template, using create_resources and Hiera. Here''s my setup >> (abridged): >> >> ../hieradata/settings.yaml: >> >> *global:* >> * variables:* >> * env: foo* >> * >> * >> *appSpecific:* >> * serverName: someServer* >> >> >> ../modules/test/manifests/init.pp: >> >> *class test {* >> * create_resources(test::variables, hiera(''global''))* >> * $appcfg = hiera(''appSpecific'')* >> * >> * >> * define variables($env) {* >> * file { "app_cfg":* >> * path => "/etc/app/app.cfg",* >> * owner => root,* >> * group => root,* >> * mode => 644,* >> * notify => Service["app"],* >> * content => template("test/$env.cfg.erb"),* >> * }* >> * }* >> * >> * >> * >> * >> *.....* >> *}* >> * >> * >> ../templates/foo.cfg.erg: >> >> * ServerName <%= appcfg[''serverName''] %>* >> * >> * >> And this is the error I get: >> >> *err: Could not retrieve catalog from remote server: Error 400 on >> SERVER: Failed to parse template test/foo.cfg.erb:* >> * Filepath: /etc/puppet/modules/test/templates/foo.cfg.erb* >> * Line: 1* >> * Detail: wrong number of arguments* >> * at /etc/puppet/modules/test/manifests/init.pp:12 on node appnode* >> >> >> If I commend out the "create_resources" and the "define" blocks, the >> template works just fine. I''m guessing maybe there is a scope issue here >> or something, but I haven''t been able to track it down. I''ve tried this: >> >> *ServerName <%= scope.lookupvar(test::appcfg[''serverName'']) %>* >> * >> * >> but still no workie. >> >> Any pointers or advice would be appreciated. >> >> >> * >> * >> >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.