FORBIDDEN_IVARS | = | [:@run_context, :@node, :@not_if, :@only_if, :@enclosing_provider] |
HIDDEN_IVARS | = | [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider] |
allowed_actions | [RW] | |
cookbook_name | [RW] | |
elapsed_time | [R] | |
enclosing_provider | [RW] | |
not_if_args | [R] | |
only_if_args | [R] | |
params | [RW] | |
provider | [RW] | |
recipe_name | [RW] | |
resource_name | [R] | |
retries | [RW] | |
retry_delay | [RW] | |
run_context | [RW] | |
source_line | [RW] | |
updated | [R] |
Set or return the "identity attribute" for this resource class. This is generally going to be the "name attribute" for this resource. In other words, the resource type plus this attribute uniquely identify a given bit of state that chef manages. For a File resource, this would be the path, for a package resource, it will be the package name. This will show up in chef-client‘s audit records as a searchable field.
Resources that want providers namespaced somewhere other than Chef::Provider can set the namespace with provider_base Ex:
class MyResource < Chef::Resource provider_base Chef::Provider::Deploy # ...other stuff end
Maps a short_name (and optionally a platform and version) to a Chef::Resource. This allows finer grained per platform resource attributes and the end of overloaded resource definitions (I‘m looking at you Chef::Resource::Package) Ex:
class WindowsFile < Chef::Resource provides :file, :on_platforms => ["windows"] # ...other stuff end
TODO: 2011-11-02 schisamo - platform_version support
Returns a resource based on a short_name and a node‘s platform and version.
short_name<Symbol>: | short_name of the resource (ie :directory) |
node<Chef::Node>: | Node object to look up platform and version in |
<Chef::Resource>: | returns the proper Chef::Resource class |
Returns a resource based on a short_name anda platform and version.
short_name<Symbol>: | short_name of the resource (ie :directory) |
platform<Symbol,String>: | platform name |
version<String>: | platform version |
<Chef::Resource>: | returns the proper Chef::Resource class |
Set or return the list of "state attributes" implemented by the Resource subclass. State attributes are attributes that describe the desired state of the system, such as file permissions or ownership. In general, state attributes are attributes that could be populated by examining the state of the system (e.g., File.stat can tell you the permissions on an existing file). Contrarily, attributes that are not "state attributes" usually modify the way Chef itself behaves, for example by providing additional options for a package manager to use when installing a package.
This list is used by the Chef client auditing system to extract information from resources to describe changes made to the system.
If command is a block, returns false if the block returns true, true if it returns false. ("Do not run this resource if the block is true")
If the command is not a block, executes the command. If it returns a 0 exitstatus, returns false. ("Do not run this resource if the command returns 0")
command<String>: | A a string to execute. |
opts<Hash>: | Options control the execution of the command |
block<Proc>: | A ruby block to run. Ignored if a command is given. |
If command is a block, returns true if the block returns true, false if it returns false. ("Only run this resource if the block is true")
If the command is not a block, executes the command. If it returns any status other than 0, it returns false (clearly, a 0 status code is true)
command<String>: | A a string to execute. |
opts<Hash>: | Options control the execution of the command |
block<Proc>: | A ruby block to run. Ignored if a command is given. |
Iterates over all immediate and delayed notifications, calling resolve_resource_reference on each in turn, causing them to resolve lazy/forward references.
Evaluates not_if and only_if conditionals. Returns a falsey value if any of the conditionals indicate that this resource should be skipped, i.e., if an only_if evaluates to false or a not_if evaluates to true.
If this resource should be skipped, returns the first conditional that "fails" its check. Subsequent conditionals are not evaluated, so in general it‘s not a good idea to rely on side effects from not_if or only_if commands/blocks being evaluated.