----- Original Message -----
> From: "R.I.Pienaar" <[email protected]>
> To: [email protected]
> Sent: Tuesday, November 13, 2012 6:22:15 PM
> Subject: [Puppet-dev] creating a class with resources in it dynamically
>
> hello,
>
> I want to be able to do create a bunch of resources inside a class
> ie. a bit like create_resources with with the additional step of
> also creating the class.
I think I go this working to a point I can play with my idea:
node "default" {
notice(inline_template('<%=
compiler = scope.compiler
main_stage = compiler.catalog.resource(:stage, :main)
klass = Puppet::Parser::Resource.new("class", "dynamic", :scope =>
compiler.newscope(nil))
klass.scope.resource = klass
compiler.add_class("dynamic")
compiler.catalog.add_edge(main_stage, klass)
date = Puppet::Parser::Resource.new(:exec, "/bin/date", :scope =>
klass.scope)
date[:refreshonly] = true
compiler.add_resource(klass.scope, date)
require "pp"
compiler.catalog.pretty_inspect
%>'))
notify{"X": notify => Class["dynamic"]}
}
This creates a class called "dynamic" on the fly, adds it to the main stage,
add a refreshonly exec to the class and finally notifies the class from the
normal puppet resource that notifies it, the refreshonly exec runs as expected
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" 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-dev?hl=en.