Class | Chef::Resource

In:

lib/chef/resource.rb
lib/chef/resource/subversion.rb
lib/chef/resource/rpm_package.rb
lib/chef/resource/gem_package.rb
lib/chef/resource/easy_install_package.rb
lib/chef/resource/breakpoint.rb
lib/chef/resource/conditional.rb
lib/chef/resource/execute.rb
lib/chef/resource/ohai.rb
lib/chef/resource/timestamped_deploy.rb
lib/chef/resource/apt_package.rb
lib/chef/resource/template.rb
lib/chef/resource/git.rb
lib/chef/resource/link.rb
lib/chef/resource/perl.rb
lib/chef/resource/pacman_package.rb
lib/chef/resource/yum_package.rb
lib/chef/resource/solaris_package.rb
lib/chef/resource/service.rb
lib/chef/resource/dpkg_package.rb
lib/chef/resource/remote_directory.rb
lib/chef/resource/remote_file.rb
lib/chef/resource/user.rb
lib/chef/resource/directory.rb
lib/chef/resource/cookbook_file.rb
lib/chef/resource/ruby_block.rb
lib/chef/resource/macports_package.rb
lib/chef/resource/python.rb
lib/chef/resource/freebsd_package.rb
lib/chef/resource/script.rb
lib/chef/resource/env.rb
lib/chef/resource/scm.rb
lib/chef/resource/http_request.rb
lib/chef/resource/erl_call.rb
lib/chef/resource/mdadm.rb
lib/chef/resource/log.rb
lib/chef/resource/deploy.rb
lib/chef/resource/file.rb
lib/chef/resource/cron.rb
lib/chef/resource/portage_package.rb
lib/chef/resource/ruby.rb
lib/chef/resource/mount.rb
lib/chef/resource/deploy_revision.rb
lib/chef/resource/bash.rb
lib/chef/resource/package.rb
lib/chef/resource/route.rb
lib/chef/resource/ifconfig.rb
lib/chef/resource/csh.rb
lib/chef/resource/group.rb

Parent: | Object

### Methods

action add_notification attribute build_from_file defined_at epic_fail ignore_failure initialize inspect is json_create load_prior_resource method_missing name new node noop not_if notifies notifies_delayed notifies_immediately only_if provider provider_base resolve_notification_references resources retries retry_delay run_action should_skip? subscribes supports to_hash to_json to_s to_text updated= updated? updated_by_last_action updated_by_last_action?

### Included Modules

Chef::Mixin::CheckHelper Chef::Mixin::ParamsValidate Chef::Mixin::Language Chef::Mixin::ConvertToClassName Chef::Mixin::Deprecation Chef::Mixin::ConvertToClassName

### Classes and Modules

Class Chef::Resource::AptPackage
Class Chef::Resource::Bash
Class Chef::Resource::Breakpoint
Class Chef::Resource::Conditional
Class Chef::Resource::CookbookFile
Class Chef::Resource::Cron
Class Chef::Resource::Csh
Class Chef::Resource::Deploy
Class Chef::Resource::DeployBranch
Class Chef::Resource::DeployRevision
Class Chef::Resource::Directory
Class Chef::Resource::DpkgPackage
Class Chef::Resource::EasyInstallPackage
Class Chef::Resource::Env
Class Chef::Resource::ErlCall
Class Chef::Resource::Execute
Class Chef::Resource::File
Class Chef::Resource::FreebsdPackage
Class Chef::Resource::GemPackage
Class Chef::Resource::Git
Class Chef::Resource::Group
Class Chef::Resource::HttpRequest
Class Chef::Resource::Ifconfig
Class Chef::Resource::Link
Class Chef::Resource::Log
Class Chef::Resource::MacportsPackage
Class Chef::Resource::Mdadm
Class Chef::Resource::Mount
Class Chef::Resource::Notification
Class Chef::Resource::Ohai
Class Chef::Resource::Package
Class Chef::Resource::PacmanPackage
Class Chef::Resource::Perl
Class Chef::Resource::PortagePackage
Class Chef::Resource::Python
Class Chef::Resource::RemoteDirectory
Class Chef::Resource::RemoteFile
Class Chef::Resource::Route
Class Chef::Resource::RpmPackage
Class Chef::Resource::Ruby
Class Chef::Resource::RubyBlock
Class Chef::Resource::Scm
Class Chef::Resource::Script
Class Chef::Resource::Service
Class Chef::Resource::SolarisPackage
Class Chef::Resource::Subversion
Class Chef::Resource::Template
Class Chef::Resource::TimestampedDeploy
Class Chef::Resource::User
Class Chef::Resource::YumPackage

### Constants

FORBIDDEN_IVARS | = | [:@run_context, :@node, :@not_if, :@only_if]
HIDDEN_IVARS | = | [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node]

### Attributes

allowed_actions | [RW] |
cookbook_name | [RW] |
delayed_notifications | [R] |
enclosing_provider | [RW] |
immediate_notifications | [R] | Each notify entry is a resource/action pair, modeled as an Struct with a resource and action member
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] |

### Public Class methods

attribute(attr_name, validation_opts={})
build_from_file(cookbook_name, filename, run_context)
initialize(name, run_context)

default initialize method that ensures that when initialize is finally wrapped (see below), super is called in the event that the resource definer does not implement initialize

json_create(o)
new(name, run_context=nil)
provider_base(arg=nil)

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

### Public Instance methods

action(arg=nil)
add_notification(action, resources, timing=:delayed)
defined_at()
epic_fail(arg=nil)
ignore_failure(arg=nil)
inspect()
is(*args)
load_prior_resource()
method_missing(method_symbol, *args, &block)

If an unknown method is invoked, determine whether the enclosing Provider‘s lexical scope can fulfill the request. E.g. This happens when the Resource‘s block invokes new_resource.

name(name=nil)
node()
noop(tf=nil)
not_if(command=nil, opts={}, &block)

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")

### Parameters

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.

### Evaluation

- evaluates to true if the block is false, or if the command returns a non-zero exit status.
- evaluates to false if the block is true, or if the command returns a 0 exit status.

notifies(*args)
notifies_delayed(action, resource_spec)
notifies_immediately(action, resource_spec)
only_if(command=nil, opts={}, &block)

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)

### Parameters

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.

### Evaluation

- evaluates to true if the block is true, or if the command returns 0
- evaluates to false if the block is false, or if the command returns a non-zero exit code.

provider(arg=nil)
resolve_notification_references()

Iterates over all immediate and delayed notifications, calling resolve_resource_reference on each in turn, causing them to resolve lazy/forward references.

resources(*args)
retries(arg=nil)
retry_delay(arg=nil)
run_action(action)
should_skip?()

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.

subscribes(action, resources, timing=:delayed)
supports(args={})
to_hash()
to_json(*a)

Serialize this object as a hash

to_s()
to_text()
updated=(true_or_false)
updated?()
updated_by_last_action(true_or_false)
updated_by_last_action?()

[Validate]