ruby_block that sets/alters attributes


#1

Hello,

I want to set some attributes in a ruby_block resource. I tried saying
"set[:blah][:whatever] = bleck" in the block, but it errors saying “set” is
not defined for Chef::Resource::RubyBlock.

How to accomplish this?

Thank you.


#2

try node[:blah][:whatever] = ‘bleck’ I do that in recipes though never tried it in a block.

Maybe try @node if node is undefined.

FYI, A trick I use while developing recipes:

I use chef-solo on the node I’m developing on with ruby-debug installed

Then I set breakpoints in the recipes so I can inspect variables, etc to see why things aren’t working as expected.

On Jul 7, 2010, at 11:21 PM, Christopher Bottaro wrote:

Hello,

I want to set some attributes in a ruby_block resource. I tried saying “set[:blah][:whatever] = bleck” in the block, but it errors saying “set” is not defined for Chef::Resource::RubyBlock.

How to accomplish this?

Thank you.


#3

Actually,

node.set[:blah][:whatever] = “bleck”

Is what you want in a recipe.

You can also use the Chef Shell (shef) to debug recipes interactively.

http://wiki.opscode.com/display/chef/Shef

On Jul 8, 2010, at 12:36 AM, Alex Soto wrote:

try node[:blah][:whatever] = ‘bleck’ I do that in recipes though never tried it in a block.

Maybe try @node if node is undefined.

FYI, A trick I use while developing recipes:

I use chef-solo on the node I’m developing on with ruby-debug installed

Then I set breakpoints in the recipes so I can inspect variables, etc to see why things aren’t working as expected.

On Jul 7, 2010, at 11:21 PM, Christopher Bottaro wrote:

Hello,

I want to set some attributes in a ruby_block resource. I tried saying “set[:blah][:whatever] = bleck” in the block, but it errors saying “set” is not defined for Chef::Resource::RubyBlock.

How to accomplish this?

Thank you.


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com