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

Methods

Included Modules

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

Classes and Modules

Class Chef::Resource::AptPackage
Class Chef::Resource::Bash
Class Chef::Resource::Breakpoint
Class Chef::Resource::ChefGem
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::IpsPackage
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::PlatformMap
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::SmartOSPackage
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, :@enclosing_provider]
HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider]

Attributes

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] 

Public Class methods

Look up a subclass by class_name which should be a string that matches `Subclass.name`

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.

Callback when subclass is defined. Adds subclass to list of subclasses.

Each notify entry is a resource/action pair, modeled as an Struct with a resource and action member

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

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

Track all subclasses of Resource. This is used so names can be looked up when attempting to deserialize from JSON. (See: json_compat)

Returns a resource based on a short_name and a node‘s platform and version.

Parameters

short_name<Symbol>:short_name of the resource (ie :directory)
node<Chef::Node>:Node object to look up platform and version in

Returns

<Chef::Resource>:returns the proper Chef::Resource class

Returns a resource based on a short_name anda platform and version.

Parameters

short_name<Symbol>:short_name of the resource (ie :directory)
platform<Symbol,String>:platform name
version<String>:platform version

Returns

<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.

Public Instance methods

Hook to allow a resource to run specific code after creation

as_json does most of the to_json heavy lifted. It exists here in case activesupport is loaded. activesupport will call as_json and skip over to_json. This ensure json is encoded as expected

Returns the value of the identity attribute, if declared. Falls back to name if no identity attribute is declared.

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.

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.

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.

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.

Returns a Hash of attribute => value for the state attributes declared in the resource‘s class definition.

Serialize this object as a hash

[Validate]