junaid_malik
2011-Mar-23 14:47 UTC
[Puppet Users] way of importing .pp file or some string that contain class definition in ruby dsl
I''m finding the way to import a file or a class stored in string in ruby manifest. I have tried following code to parse the class having packages and services. pp = Puppet::Parser::Parser.new("development") pp.string = "class webhttpd{package { ''httpd'': ensure => installed, } service { ''httpd'': ensure => running, enable => true, require => Package[''httpd''] } }" pp.parse pp = pp = Puppet::Parser::Parser.new("development") pp.file = "web.pp" pp.parse My idea is to re-use the classes written in the pp file style and they are stored in database. I just want to load those classes depending on ''FQDN'' name of a node and then create a node in ruby like this. node name_of_the_node{ create_resource :class, "httpd" } I hope now you get what i''m trying to do in the ruby manifest. If its still not clear then please ask me to explain more about what i want to achieve from this. Thanks. -- 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.
Dan Bode
2011-Mar-23 20:57 UTC
Re: [Puppet Users] way of importing .pp file or some string that contain class definition in ruby dsl
Have a look at external node classifiers, I believe this is a more appropriate approach for what you are trying to accomplish: http://docs.puppetlabs.com/guides/external_nodes.html On Wed, Mar 23, 2011 at 7:47 AM, junaid_malik <junaidmalik14@gmail.com>wrote:> I''m finding the way to import a file or a class stored in string in > ruby manifest. > > I have tried following code to parse the class having packages and > services. > > pp = Puppet::Parser::Parser.new("development") > pp.string = "class webhttpd{package { ''httpd'': ensure => installed, } > service { ''httpd'': ensure => running, enable => true, require => > Package[''httpd''] } }" > pp.parse > > > pp = pp = Puppet::Parser::Parser.new("development") > pp.file = "web.pp" > pp.parse > > My idea is to re-use the classes written in the pp file style and they > are stored in database. I just want to load those classes depending on > ''FQDN'' name of a node and then create a node in ruby like this. > > node name_of_the_node{ > create_resource :class, "httpd" > } > > I hope now you get what i''m trying to do in the ruby manifest. If its > still not clear then please ask me to explain more about what i want > to achieve from this. > > Thanks. > > -- > 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.
Apparently Analagous Threads
- Ruby DSL: create_resource with exec
- Re: [Puppet-dev] Converting to Ruby DSL
- Error: Could not retrieve catalog from remote server: Error 400 on SERVER: A JSON text must at least contain two octets! at /etc/puppet/manifests/site.pp:4 on node irnode
- need urgent help with including Ruby DSL class from puppet manifests
- Using back-ported create_resources in 2.6.x