Issue #5236 has been updated by Ken Barber.
Status changed from Accepted to Closed
Actually this does work:
hostclass :foo, :arguments => {"myparam" => nil} do
notice [scope.lookupvar("myparam")]
end
node "default" do
create_resource :class, :foo, :myparam => "foo"
end
Which is functionally the same as:
class foo ($myparam) {
notice($myparam)
}
node "default" {
class { "foo": myparam => "foo" }
}
I've updated the Wiki to reflect this:
<http://projects.puppetlabs.com/projects/puppet/wiki/Ruby_Dsl>
And added another sample to my rubydsl-examples site:
<https://github.com/bobsh/puppet-rubydsl-examples/blob/master/classes/classes2.rb>
I'm going to close this ticket, as it seems like it was primarily a
documentation issue.
----------------------------------------
Bug #5236: Ruby DSL cannot declare parameterized classes
https://projects.puppetlabs.com/issues/5236
Author: Dan Bode
Status: Closed
Priority: High
Assignee:
Category: API
Target version:
Affected Puppet version:
Keywords: internal dsl hostclass
parameterized_classes
Branch:
it should be possible to declare parameterized classes using the ruby dsl:
/tmp/notify.rb
<pre>
hostclass 'foo', 'bar' do
notify 'foop', :message => 'foobar'
end
node 'default' do
hostclass 'foo', :bar => 'test'
end
</pre>
trying to apply the above manifest, results in the error below.
<pre>
#>puppet apply /tmp/notify.rb --debug --trace
/usr/lib/ruby/site_ruby/1.8/puppet/dsl/resource_api.rb:38:in `method_missing'
(eval):7:in `parse_ruby_file'
/usr/lib/ruby/site_ruby/1.8/puppet/dsl/resource_api.rb:19:in `instance_eval'
/usr/lib/ruby/site_ruby/1.8/puppet/dsl/resource_api.rb:19:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:295:in `evaluate_ruby_code'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:78:in `evaluate_code'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:225:in `evaluate_ast_node'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:103:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:18:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in
`compile'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:188:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in
`compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:115:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:35:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:393:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/usr/bin/puppet:4
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:21:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in
`compile'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:188:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in
`compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:115:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:35:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:393:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/usr/bin/puppet:4
undefined method `hostclass' for #<Puppet::DSL::ResourceAPI:0xb790786c> on node
puppetfoo.localdomain
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.