Chef Shell Attributes


#1

I’m trying to load Chef Shell in solo mode, and then include_recipe and
inspect the node attributes.

chef-shell --solo --config /etc/chef/solo.rb

loading configuration: /etc/chef/solo.rbSession type: solo
Loading…done.

This is the chef-shell.
Chef Version: 11.4.0
http://www.opscode.com/chef
http://wiki.opscode.com/display/chef/Home

run help' for help,exit’ or ^D to quit.

Ohai2u vagrant@localhost!
chef >
chef > Chef::Config[:cookbook_path]
=> “/vagrant/cookbooks”

Then enter recipe mode, include_recipe “yum”. The recipe is loaded.

Now switch to attributes mode:

chef:recipe > attributes_mode
chef:attributes > node.default
=> {}

What am I missing?

-aob


#2

You might want to look at:

node.attributes

instead. Switching into attributes_mode is not necessary to do that.

node.methods will give you a list of all methods you can call on node. You might be interested in things like node.automatic_attrs, node.default_attrs, …

Hope this helps.

  • Matthias

Am 14.04.2013 um 16:31 schrieb Angus Buchanan angus.o.buchanan@gmail.com:

I’m trying to load Chef Shell in solo mode, and then include_recipe and inspect the node attributes.

chef-shell --solo --config /etc/chef/solo.rb

loading configuration: /etc/chef/solo.rbSession type: solo
Loading…done.

This is the chef-shell.
Chef Version: 11.4.0
http://www.opscode.com/chef
http://wiki.opscode.com/display/chef/Home

run help' for help,exit’ or ^D to quit.

Ohai2u vagrant@localhost!
chef >
chef > Chef::Config[:cookbook_path]
=> “/vagrant/cookbooks”

Then enter recipe mode, include_recipe “yum”. The recipe is loaded.

Now switch to attributes mode:

chef:recipe > attributes_mode
chef:attributes > node.default
=> {}

What am I missing?

-aob


#3

Thanks,

node.default_attrs etc gives the same result. I see automatic attributes,
as expected, but I don’t see default attributes that should have been
loaded as part of the yum cookbook:

default[‘yum’][‘cachedir’] = ‘/var/cache/yum’

For example.

It’s as if running:

include_recipe “yum”

Doesn’t load the attributes.

-aob

On Sun, Apr 14, 2013 at 8:31 PM, Matthias Marschall <
mm@agileweboperations.com> wrote:

You might want to look at:

node.attributes

instead. Switching into attributes_mode is not necessary to do that.

node.methods will give you a list of all methods you can call on node. You
might be interested in things like node.automatic_attrs,
node.default_attrs, …

Hope this helps.

  • Matthias

Am 14.04.2013 um 16:31 schrieb Angus Buchanan <angus.o.buchanan@gmail.com

:

I’m trying to load Chef Shell in solo mode, and then include_recipe and
inspect the node attributes.

chef-shell --solo --config /etc/chef/solo.rb

loading configuration: /etc/chef/solo.rbSession type: solo
Loading…done.

This is the chef-shell.
Chef Version: 11.4.0
http://www.opscode.com/chef
http://wiki.opscode.com/display/chef/Home

run help' for help,exit’ or ^D to quit.

Ohai2u vagrant@localhost!
chef >
chef > Chef::Config[:cookbook_path]
=> “/vagrant/cookbooks”

Then enter recipe mode, include_recipe “yum”. The recipe is loaded.

Now switch to attributes mode:

chef:recipe > attributes_mode
chef:attributes > node.default
=> {}

What am I missing?

-aob