how to create a node object from a parameterised class?

14 views
Skip to first unread message

Nikolay Sturm

unread,
Feb 18, 2011, 12:34:54 PM2/18/11
to puppe...@googlegroups.com
Hi,

in order to extend cucumber-puppet to support parameterised classes, I
need to create a node object from a parameterised class.

At the moment my code does sth like this:

node = Puppet::Node.new(@facts['hostname'], :classes => @klass)
node.merge(@facts)
@catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node)

Where and how would I have to add the class's parameters?

cheers,

Nikolay

--
"It's all part of my Can't-Do approach to life." Wally

Dan Bode

unread,
Feb 19, 2011, 1:26:01 AM2/19/11
to puppe...@googlegroups.com, Nikolay Sturm
Hi Nikolay,

On Fri, Feb 18, 2011 at 9:34 AM, Nikolay Sturm <goo...@erisiandiscord.de> wrote:
Hi,

in order to extend cucumber-puppet to support parameterised classes, I
need to create a node object from a parameterised class.

At the moment my code does sth like this:

node = Puppet::Node.new(@facts['hostname'], :classes => @klass)
node.merge(@facts)
@catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node)

This is fixed by my patch for param class support for ENC:

http://projects.puppetlabs.com/issues/5045

This will only work against 2.6.5 (currently at rc4)

The only difference is that :classes should take a hash instead of an array.

require 'puppet'
=> true
irb(main):002:0> node = Puppet::Node.new('nodename', :classes => {'ntp' => {'servers' => ['foo'] }})
=> #<Puppet::Node:0xb7841838 @parameters={}, @time=Sun Feb 13 11:49:25 -0600 2011, @name="nodename", @classes={"ntp"=>{"servers"=>["foo"]}}>
irb(main):003:0> node.merge({})
=> "production"
irb(main):004:0> Puppet::Resource::Catalog.find(node.name, :use_node => node)

 
Where and how would I have to add the class's parameters?

cheers,

Nikolay

--
"It's all part of my Can't-Do approach to life." Wally

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppe...@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.


Nikolay Sturm

unread,
Mar 6, 2011, 1:38:39 PM3/6/11
to puppe...@googlegroups.com
* Dan Bode [2011-02-19]:

> This is fixed by my patch for param class support for ENC:
>
> http://projects.puppetlabs.com/issues/5045

> This will only work against 2.6.5 (currently at rc4)
>
> The only difference is that :classes should take a hash instead of an array.

Great, works fine. Thanks for your help!

cheers,

Nikolay

Reply all
Reply to author
Forward
0 new messages