russell.fulton
2010-Nov-22 03:56 UTC
[Puppet Users] how to use fully qualified names in erb...
I have a class in a file monitor/manifest/masters/dmzo: class dmzo { $rule_categories = [ scan,finger,ftp,telnet,rpc,rservices,ddos,dns,tftp,web- coldfusion,misc,web-php, ] } and probably other variables eventually... In my monitor/manifest/init.pp: module monitor { import "masters/*.pp" define sensor ( $name, $master, $interfaces ) { include $master barnyard { $interfaces : } snort{ $master: interfaces => $interfaces } file { "/home/snort/conf/$master-pp.conf": owner => ''snort'', group => ''snort'', content=>template(''monitor/pulledpork.conf.erb''), ensure=>present; } ................. } and in pulledpork.con.erb : include=<%= rule_categories.join('','') %> and I get the error: "Could not find value for ''rule_categories'' at /etc/puppet/modules/ monitor/manifests/init.pp:62" I have tried qualifying the name by prefixing it with dmzo:: and dmzo. then I get same error for ''dmzo''. I assume I need to qualify the variable name but don''t know how. What I am trying to do is have parameters to a define select a value for a variable that then gets passed to erb. I also want to have the values specified in a single separate file or a series of files in a directory. -- 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.
Daniel Pittman
2010-Nov-22 04:45 UTC
Re: [Puppet Users] how to use fully qualified names in erb...
"russell.fulton" <russell.fulton@gmail.com> writes:> I have a class in a file monitor/manifest/masters/dmzo:[...]> and I get the error: > "Could not find value for ''rule_categories'' at /etc/puppet/modules/ > monitor/manifests/init.pp:62" > > I have tried qualifying the name by prefixing it with dmzo:: and dmzo. then > I get same error for ''dmzo''. I assume I need to qualify the variable name > but don''t know how.I like to keep this visible in the manifest by doing this: class foo { $quux = ''one'' } class bar { include foo $quux = $foo::quux } ...but you can also do this in the erb: <%= scope.lookupvar(''dmzo::rule_categories'') %> This is documented in here: http://projects.puppetlabs.com/projects/1/wiki/Puppet_Templating Oh, and one final template gotcha: various Ruby reserved words can''t be used as template variables. Those include a few like ''fork'' that you might otherwise think to use in rules like yours. Just in case you find yourself wondering why they don''t work as expected. :) Regards, Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- 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.