Class | Chef::Node
In: | lib/chef/node.rb lib/chef/node/attribute.rb
Parent: | Object

### Methods

[] []= apply_expansion_attributes attribute attribute= attribute? build cdb_destroy cdb_list cdb_list_by_environment cdb_load cdb_save chef_environment chef_server_rest construct_attributes consume_attributes consume_external_attrs consume_run_list couchdb_id= create create_design_document default default_unless destroy display_hash each each_attribute exists? expand! find_file find_or_create json_create list list_by_environment load load_attribute_by_short_filename load_attributes method_missing name new node normal normal_unless override override_unless recipe? reset_defaults_and_overrides role? run_list run_list? save set set_unless store tags to_hash to_json to_s update_from!

### Included Modules

Chef::Mixin::CheckHelper Chef::Mixin::FromFile Chef::Mixin::ParamsValidate Chef::Mixin::LanguageIncludeAttribute Chef::IndexQueue::Indexable

### Classes and Modules

Class Chef::Node::Attribute

### Constants

DESIGN_DOCUMENT | = | { "version" => 11, "language" => "javascript", "views" => { "all" => { "map" => <<-EOJS function(doc) { if (doc.chef_type == "node") { emit(doc.name, doc); } } EOJS

### Attributes

automatic_attrs | [RW] |
cookbook_collection | [RW] | TODO: 5/18/2010 cw/timh. cookbook_collection should be removed from here and for any place it‘s needed, it should be accessed through a Chef::RunContext
couchdb | [RW] |
couchdb_id | [R] |
couchdb_rev | [RW] |
default_attrs | [RW] |
normal_attrs | [RW] |
override_attrs | [RW] |
recipe_list | [RW] |
run_list | [RW] |
run_state | [RW] |

### Public Class methods

build(node_name)
cdb_list(inflate=false, couchdb=nil)

List all the Chef::Node objects in the CouchDB. If inflate is set to true, you will get the full list of all Nodes, fully inflated.

cdb_list_by_environment(environment, inflate=false, couchdb=nil)
cdb_load(name, couchdb=nil)

Load a node by name from CouchDB

create_design_document(couchdb=nil)

Set up our CouchDB design document

exists?(nodename, couchdb)
find_or_create(node_name)
json_create(o)

Create a Chef::Node from JSON

list(inflate=false)
list_by_environment(environment, inflate=false)
load(name)

Load a node by name

new(couchdb=nil)

Create a new Chef::Node object.

### Public Instance methods

[](attrib)

Return an attribute of this node. Returns nil if the attribute is not found.

[]=(attrib, value)

Set an attribute of this node

apply_expansion_attributes(expansion)

Apply the default and overrides attributes from the expansion passed in, which came from roles.

attribute()

Used by the DSL

attribute=(value)
attribute?(attrib)

Return true if this Node has a given attribute, false if not. Takes either a symbol or a string.

Only works on the top level. Preferred way is to use the normal [] style lookup and call attribute?()

cdb_destroy()

Remove this node from the CouchDB

cdb_save()

Save this node to the CouchDB

chef_environment(arg=nil)
chef_server_rest()
construct_attributes()
consume_attributes(attrs)

Consumes the combined run_list and other attributes in `attrs`

consume_external_attrs(ohai_data, json_cli_attrs)

Consume data from ohai and Attributes provided as JSON on the command line.

consume_run_list(attrs)

Extracts the run list from `attrs` and applies it. Returns the remaining attributes

couchdb_id=(value)
create()

Create the node via the REST API

default()

Set a default of this node, but auto-vivifiy any Mashes that might be missing

default_unless()

Set a default attribute of this node, auto-vivifiying any mashes that are missing, but if the final value already exists, don‘t set it

destroy()

Remove this node via the REST API

display_hash()
each(&block)

Yield each key of the top level to the block.

each_attribute(&block)

Iterates over each attribute, passing the attribute and value to the block.

expand!(data_source = 'server')

Expands the node‘s run list and sets the default and override attributes. Also applies stored attributes (from json provided on the command line)

Returns the fully-expanded list of recipes, a RunListExpansion.

find_file(fqdn)

Find a recipe for this Chef::Node by fqdn. Will search first for Chef::Config["node_path"]/fqdn.rb, then hostname.rb, then default.rb.

Returns a new Chef::Node object.

Raises an ArgumentError if it cannot find the node.

load_attribute_by_short_filename(name, src_cookbook_name)

Used by DSL. Loads the attribute file specified by the short name of the file, e.g., loads specified cookbook‘s

      "attributes/mailservers.rb"

if passed

      "mailservers"

load_attributes()

Load all attribute files for all cookbooks associated with this node.

method_missing(symbol, *args)

Encouraged to only get used for lookups - while you can do sets from here, it‘s not as explicit as using the normal/default/override interface.

name(arg=nil)

Set the name of this Node, or return the current name.

node()

Used by DSL

normal()

Set a normal attribute of this node, but auto-vivifiy any Mashes that might be missing

normal_unless()

Set a normal attribute of this node, auto-vivifiying any mashes that are missing, but if the final value already exists, don‘t set it

override()

Set an override attribute of this node, but auto-vivifiy any Mashes that might be missing

override_unless()

Set an override attribute of this node, auto-vivifiying any mashes that are missing, but if the final value already exists, don‘t set it

recipe?(recipe_name)

Returns true if this Node expects a given recipe, false if not.

First, the run list is consulted to see whether the recipe is explicitly included. If it‘s not there, it looks in run_state[:seen_recipes], which is populated by include_recipe statements in the DSL (and thus would not be in the run list).

NOTE: It‘s used by cookbook authors

reset_defaults_and_overrides()

Clear defaults and overrides, so that any deleted attributes between runs are still gone.

role?(role_name)

Returns true if this Node expects a given role, false if not.

run_list(*args)

Returns an Array of roles and recipes, in the order they will be applied. If you call it with arguments, they will become the new list of roles and recipes.

run_list?(item)

Returns true if this Node expects a given role, false if not.

save()

Save this node via the REST API

set()

Alias for normal

set_unless()

Alias for normal_unless

store(attrib, value)
tags()

Lazy initializer for tags attribute

to_hash()

Transform the node to a Hash

to_json(*a)

Serialize this object as a hash

to_s()
update_from!(o)

[Validate]