summaryrefslogtreecommitdiff
path: root/lib/chef/resource
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@opscode.com>2012-10-30 10:39:35 -0400
committerSeth Chisamore <schisamo@opscode.com>2012-10-30 10:39:35 -0400
commit24dc69a9a97e82a6e4207de68d6dcc664178249b (patch)
tree19bb289c9f88b4bbab066bc56b95d6d222fd5c35 /lib/chef/resource
parent9348c1c9c80ee757354d624b7dc1b78ebc7605c4 (diff)
downloadchef-24dc69a9a97e82a6e4207de68d6dcc664178249b.tar.gz
[OC-3564] move core Chef to the repo root \o/ \m/
The opscode/chef repository now only contains the core Chef library code used by chef-client, knife and chef-solo!
Diffstat (limited to 'lib/chef/resource')
-rw-r--r--lib/chef/resource/apt_package.rb43
-rw-r--r--lib/chef/resource/bash.rb33
-rw-r--r--lib/chef/resource/breakpoint.rb35
-rw-r--r--lib/chef/resource/chef_gem.rb53
-rw-r--r--lib/chef/resource/conditional.rb101
-rw-r--r--lib/chef/resource/cookbook_file.rb52
-rw-r--r--lib/chef/resource/cron.rb202
-rw-r--r--lib/chef/resource/csh.rb33
-rw-r--r--lib/chef/resource/deploy.rb403
-rw-r--r--lib/chef/resource/deploy_revision.rb40
-rw-r--r--lib/chef/resource/directory.rb65
-rw-r--r--lib/chef/resource/dpkg_package.rb34
-rw-r--r--lib/chef/resource/easy_install_package.rb57
-rw-r--r--lib/chef/resource/env.rb63
-rw-r--r--lib/chef/resource/erl_call.rb86
-rw-r--r--lib/chef/resource/execute.rb132
-rw-r--r--lib/chef/resource/file.rb96
-rw-r--r--lib/chef/resource/freebsd_package.rb35
-rw-r--r--lib/chef/resource/gem_package.rb53
-rw-r--r--lib/chef/resource/git.rb46
-rw-r--r--lib/chef/resource/group.rb83
-rw-r--r--lib/chef/resource/http_request.rb64
-rw-r--r--lib/chef/resource/ifconfig.rb149
-rw-r--r--lib/chef/resource/ips_package.rb42
-rw-r--r--lib/chef/resource/link.rb92
-rw-r--r--lib/chef/resource/log.rb65
-rw-r--r--lib/chef/resource/macports_package.rb29
-rw-r--r--lib/chef/resource/mdadm.rb105
-rw-r--r--lib/chef/resource/mount.rb139
-rw-r--r--lib/chef/resource/ohai.rb54
-rw-r--r--lib/chef/resource/package.rb84
-rw-r--r--lib/chef/resource/pacman_package.rb33
-rw-r--r--lib/chef/resource/perl.rb33
-rw-r--r--lib/chef/resource/portage_package.rb33
-rw-r--r--lib/chef/resource/python.rb33
-rw-r--r--lib/chef/resource/remote_directory.rb125
-rw-r--r--lib/chef/resource/remote_file.rb81
-rw-r--r--lib/chef/resource/route.rb140
-rw-r--r--lib/chef/resource/rpm_package.rb34
-rw-r--r--lib/chef/resource/ruby.rb33
-rw-r--r--lib/chef/resource/ruby_block.rb51
-rw-r--r--lib/chef/resource/scm.rb151
-rw-r--r--lib/chef/resource/script.rb63
-rw-r--r--lib/chef/resource/service.rb164
-rw-r--r--lib/chef/resource/smartos_package.rb36
-rw-r--r--lib/chef/resource/solaris_package.rb36
-rw-r--r--lib/chef/resource/subversion.rb37
-rw-r--r--lib/chef/resource/template.rb76
-rw-r--r--lib/chef/resource/timestamped_deploy.rb31
-rw-r--r--lib/chef/resource/user.rb134
-rw-r--r--lib/chef/resource/yum_package.rb63
51 files changed, 3955 insertions, 0 deletions
diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb
new file mode 100644
index 0000000000..524abbb370
--- /dev/null
+++ b/lib/chef/resource/apt_package.rb
@@ -0,0 +1,43 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/apt'
+
+class Chef
+ class Resource
+ class AptPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :apt_package
+ @provider = Chef::Provider::Package::Apt
+ @default_release = nil
+ end
+
+ def default_release(arg=nil)
+ set_or_return(
+ :default_release,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/bash.rb b/lib/chef/resource/bash.rb
new file mode 100644
index 0000000000..374bca9e11
--- /dev/null
+++ b/lib/chef/resource/bash.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Bash < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :bash
+ @interpreter = "bash"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/breakpoint.rb b/lib/chef/resource/breakpoint.rb
new file mode 100644
index 0000000000..34aeae6b47
--- /dev/null
+++ b/lib/chef/resource/breakpoint.rb
@@ -0,0 +1,35 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Breakpoint < Chef::Resource
+
+ def initialize(action="break", *args)
+ @name = caller.first
+ super(@name, *args)
+ @action = "break"
+ @allowed_actions << :break
+ @provider = Chef::Provider::Breakpoint
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
new file mode 100644
index 0000000000..d8de0edc00
--- /dev/null
+++ b/lib/chef/resource/chef_gem.rb
@@ -0,0 +1,53 @@
+#
+# Author:: Bryan McLellan <btm@loftninjas.org>
+# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/resource/gem_package'
+
+class Chef
+ class Resource
+ class ChefGem < Chef::Resource::Package::GemPackage
+
+ provides :chef_gem, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :chef_gem
+ @provider = Chef::Provider::Package::Rubygems
+ end
+
+ # The chef_gem resources is for installing gems to the current gem environment only for use by Chef cookbooks.
+ def gem_binary(arg=nil)
+ if arg
+ raise ArgumentError, "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments."
+ end
+
+ nil
+ end
+
+ def after_created
+ # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled
+ # Action could be an array of symbols, but probably won't (think install + enable for a package)
+ Array(@action).each do |action|
+ self.run_action(action)
+ end
+ Gem.clear_paths
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb
new file mode 100644
index 0000000000..3f892af827
--- /dev/null
+++ b/lib/chef/resource/conditional.rb
@@ -0,0 +1,101 @@
+#
+# Author:: Daniel DeLeo (<dan@opscode.com>)
+# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/mixin/shell_out'
+
+class Chef
+ class Resource
+ class Conditional
+ include Chef::Mixin::ShellOut
+
+ # We only create these via the `not_if` or `only_if` constructors, and
+ # not the default constructor
+ class << self
+ private :new
+ end
+
+ def self.not_if(command=nil, command_opts={}, &block)
+ new(:not_if, command, command_opts, &block)
+ end
+
+ def self.only_if(command=nil, command_opts={}, &block)
+ new(:only_if, command, command_opts, &block)
+ end
+
+ attr_reader :positivity
+ attr_reader :command
+ attr_reader :command_opts
+ attr_reader :block
+
+ def initialize(positivity, command=nil, command_opts={}, &block)
+ @positivity = positivity
+ case command
+ when String
+ @command, @command_opts = command, command_opts
+ @block = nil
+ when nil
+ raise ArgumentError, "only_if/not_if requires either a command or a block" unless block_given?
+ @command, @command_opts = nil, nil
+ @block = block
+ else
+ raise ArgumentError, "Invalid only_if/not_if command: #{command.inspect} (#{command.class})"
+ end
+ end
+
+ def continue?
+ case @positivity
+ when :only_if
+ evaluate
+ when :not_if
+ !evaluate
+ else
+ raise "Cannot evaluate resource conditional of type #{@positivity}"
+ end
+ end
+
+ def evaluate
+ @command ? evaluate_command : evaluate_block
+ end
+
+ def evaluate_command
+ shell_out(@command, @command_opts).status.success?
+ rescue Chef::Exceptions::CommandTimeout
+ Chef::Log.warn "Command '#{@command}' timed out"
+ false
+ end
+
+ def evaluate_block
+ @block.call
+ end
+
+ def description
+ cmd_or_block = @command ? "command `#{@command}`" : "ruby block"
+ "#{@positivity} #{cmd_or_block}"
+ end
+
+ def to_text
+ if @command
+ "#{positivity} \"#{@command}\""
+ else
+ "#{@positivity} { #code block }"
+ end
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/cookbook_file.rb b/lib/chef/resource/cookbook_file.rb
new file mode 100644
index 0000000000..de758aef71
--- /dev/null
+++ b/lib/chef/resource/cookbook_file.rb
@@ -0,0 +1,52 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/file'
+require 'chef/provider/cookbook_file'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class CookbookFile < Chef::Resource::File
+ include Chef::Mixin::Securable
+
+ provides :cookbook_file, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @provider = Chef::Provider::CookbookFile
+ @resource_name = :cookbook_file
+ @action = "create"
+ @source = ::File.basename(name)
+ @cookbook = nil
+ @provider = Chef::Provider::CookbookFile
+ end
+
+ def source(source_filename=nil)
+ set_or_return(:source, source_filename, :kind_of => String)
+ end
+
+ def cookbook(cookbook_name=nil)
+ set_or_return(:cookbook, cookbook_name, :kind_of => String)
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb
new file mode 100644
index 0000000000..5f858cec81
--- /dev/null
+++ b/lib/chef/resource/cron.rb
@@ -0,0 +1,202 @@
+#
+# Author:: Bryan McLellan (btm@loftninjas.org)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Bryan McLellan
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Cron < Chef::Resource
+
+ identity_attr :command
+
+ state_attrs :minute, :hour, :day, :month, :weekday, :user
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :cron
+ @action = :create
+ @allowed_actions.push(:create, :delete)
+ @minute = "*"
+ @hour = "*"
+ @day = "*"
+ @month = "*"
+ @weekday = "*"
+ @command = nil
+ @user = "root"
+ @mailto = nil
+ @path = nil
+ @shell = nil
+ @home = nil
+ @environment = {}
+ end
+
+ def minute(arg=nil)
+ if arg.is_a?(Integer)
+ converted_arg = arg.to_s
+ else
+ converted_arg = arg
+ end
+ begin
+ if integerize(arg) > 59 then raise RangeError end
+ rescue ArgumentError
+ end
+ set_or_return(
+ :minute,
+ converted_arg,
+ :kind_of => String
+ )
+ end
+
+ def hour(arg=nil)
+ if arg.is_a?(Integer)
+ converted_arg = arg.to_s
+ else
+ converted_arg = arg
+ end
+ begin
+ if integerize(arg) > 23 then raise RangeError end
+ rescue ArgumentError
+ end
+ set_or_return(
+ :hour,
+ converted_arg,
+ :kind_of => String
+ )
+ end
+
+ def day(arg=nil)
+ if arg.is_a?(Integer)
+ converted_arg = arg.to_s
+ else
+ converted_arg = arg
+ end
+ begin
+ if integerize(arg) > 31 then raise RangeError end
+ rescue ArgumentError
+ end
+ set_or_return(
+ :day,
+ converted_arg,
+ :kind_of => String
+ )
+ end
+
+ def month(arg=nil)
+ if arg.is_a?(Integer)
+ converted_arg = arg.to_s
+ else
+ converted_arg = arg
+ end
+ begin
+ if integerize(arg) > 12 then raise RangeError end
+ rescue ArgumentError
+ end
+ set_or_return(
+ :month,
+ converted_arg,
+ :kind_of => String
+ )
+ end
+
+ def weekday(arg=nil)
+ if arg.is_a?(Integer)
+ converted_arg = arg.to_s
+ else
+ converted_arg = arg
+ end
+ begin
+ if integerize(arg) > 7 then raise RangeError end
+ rescue ArgumentError
+ end
+ set_or_return(
+ :weekday,
+ converted_arg,
+ :kind_of => String
+ )
+ end
+
+ def mailto(arg=nil)
+ set_or_return(
+ :mailto,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def path(arg=nil)
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def home(arg=nil)
+ set_or_return(
+ :home,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def shell(arg=nil)
+ set_or_return(
+ :shell,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def command(arg=nil)
+ set_or_return(
+ :command,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def user(arg=nil)
+ set_or_return(
+ :user,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def environment(arg=nil)
+ set_or_return(
+ :environment,
+ arg,
+ :kind_of => Hash
+ )
+ end
+
+ private
+
+ # On Ruby 1.8, Kernel#Integer will happily do this for you. On 1.9, no.
+ def integerize(integerish)
+ Integer(integerish)
+ rescue TypeError
+ 0
+ end
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/csh.rb b/lib/chef/resource/csh.rb
new file mode 100644
index 0000000000..6e871e8605
--- /dev/null
+++ b/lib/chef/resource/csh.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Csh < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :csh
+ @interpreter = "csh"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb
new file mode 100644
index 0000000000..8b614028bf
--- /dev/null
+++ b/lib/chef/resource/deploy.rb
@@ -0,0 +1,403 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# EX:
+# deploy "/my/deploy/dir" do
+# repo "git@github.com/whoami/project"
+# revision "abc123" # or "HEAD" or "TAG_for_1.0" or (subversion) "1234"
+# user "deploy_ninja"
+# enable_submodules true
+# migrate true
+# migration_command "rake db:migrate"
+# environment "RAILS_ENV" => "production", "OTHER_ENV" => "foo"
+# shallow_clone true
+# action :deploy # or :rollback
+# restart_command "touch tmp/restart.txt"
+# git_ssh_wrapper "wrap-ssh4git.sh"
+# scm_provider Chef::Provider::Git # is the default, for svn: Chef::Provider::Subversion
+# svn_username "whoami"
+# svn_password "supersecret"
+# end
+
+require "chef/resource/scm"
+
+class Chef
+ class Resource
+
+ # Deploy: Deploy apps from a source control repository.
+ #
+ # Callbacks:
+ # Callbacks can be a block or a string. If given a block, the code
+ # is evaluated as an embedded recipe, and run at the specified
+ # point in the deploy process. If given a string, the string is taken as
+ # a path to a callback file/recipe. Paths are evaluated relative to the
+ # release directory. Callback files can contain chef code (resources, etc.)
+ #
+ class Deploy < Chef::Resource
+
+ provider_base Chef::Provider::Deploy
+
+ identity_attr :repository
+
+ state_attrs :deploy_to, :revision
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :deploy
+ @deploy_to = name
+ @environment = nil
+ @repository_cache = 'cached-copy'
+ @copy_exclude = []
+ @purge_before_symlink = %w{log tmp/pids public/system}
+ @create_dirs_before_symlink = %w{tmp public config}
+ @symlink_before_migrate = {"config/database.yml" => "config/database.yml"}
+ @symlinks = {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
+ @revision = 'HEAD'
+ @action = :deploy
+ @migrate = false
+ @rollback_on_error = false
+ @remote = "origin"
+ @enable_submodules = false
+ @shallow_clone = false
+ @scm_provider = Chef::Provider::Git
+ @svn_force_export = false
+ @provider = Chef::Provider::Deploy::Timestamped
+ @allowed_actions.push(:force_deploy, :deploy, :rollback)
+ @additional_remotes = Hash[]
+ @keep_releases = 5
+ end
+
+ # where the checked out/cloned code goes
+ def destination
+ @destination ||= shared_path + "/#{@repository_cache}"
+ end
+
+ # where shared stuff goes, i.e., logs, tmp, etc. goes here
+ def shared_path
+ @shared_path ||= @deploy_to + "/shared"
+ end
+
+ # where the deployed version of your code goes
+ def current_path
+ @current_path ||= @deploy_to + "/current"
+ end
+
+ def depth
+ @shallow_clone ? "5" : nil
+ end
+
+ # note: deploy_to is your application "meta-root."
+ def deploy_to(arg=nil)
+ set_or_return(
+ :deploy_to,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def repo(arg=nil)
+ set_or_return(
+ :repo,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ alias :repository :repo
+
+ def remote(arg=nil)
+ set_or_return(
+ :remote,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def role(arg=nil)
+ set_or_return(
+ :role,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def restart_command(arg=nil, &block)
+ arg ||= block
+ set_or_return(
+ :restart_command,
+ arg,
+ :kind_of => [ String, Proc ]
+ )
+ end
+ alias :restart :restart_command
+
+ def migrate(arg=nil)
+ set_or_return(
+ :migrate,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def migration_command(arg=nil)
+ set_or_return(
+ :migration_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def rollback_on_error(arg=nil)
+ set_or_return(
+ :rollback_on_error,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def user(arg=nil)
+ set_or_return(
+ :user,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def group(arg=nil)
+ set_or_return(
+ :group,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def enable_submodules(arg=nil)
+ set_or_return(
+ :enable_submodules,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def shallow_clone(arg=nil)
+ set_or_return(
+ :shallow_clone,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def repository_cache(arg=nil)
+ set_or_return(
+ :repository_cache,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def copy_exclude(arg=nil)
+ set_or_return(
+ :copy_exclude,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def revision(arg=nil)
+ set_or_return(
+ :revision,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ alias :branch :revision
+
+ def git_ssh_wrapper(arg=nil)
+ set_or_return(
+ :git_ssh_wrapper,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ alias :ssh_wrapper :git_ssh_wrapper
+
+ def svn_username(arg=nil)
+ set_or_return(
+ :svn_username,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def svn_password(arg=nil)
+ set_or_return(
+ :svn_password,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def svn_arguments(arg=nil)
+ set_or_return(
+ :svn_arguments,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def svn_info_args(arg=nil)
+ set_or_return(
+ :svn_arguments,
+ arg,
+ :kind_of => [ String ])
+ end
+
+ def scm_provider(arg=nil)
+ klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
+ lookup_provider_constant(arg)
+ else
+ arg
+ end
+ set_or_return(
+ :scm_provider,
+ klass,
+ :kind_of => [ Class ]
+ )
+ end
+
+ def svn_force_export(arg=nil)
+ set_or_return(
+ :svn_force_export,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def environment(arg=nil)
+ if arg.is_a?(String)
+ Chef::Log.debug "Setting RAILS_ENV, RACK_ENV, and MERB_ENV to `#{arg}'"
+ Chef::Log.warn "[DEPRECATED] please modify your deploy recipe or attributes to set the environment using a hash"
+ arg = {"RAILS_ENV"=>arg,"MERB_ENV"=>arg,"RACK_ENV"=>arg}
+ end
+ set_or_return(
+ :environment,
+ arg,
+ :kind_of => [ Hash ]
+ )
+ end
+
+ # The number of old release directories to keep around after cleanup
+ def keep_releases(arg=nil)
+ [set_or_return(
+ :keep_releases,
+ arg,
+ :kind_of => [ Integer ]), 1].max
+ end
+
+ # An array of paths, relative to your app's root, to be purged from a
+ # SCM clone/checkout before symlinking. Use this to get rid of files and
+ # directories you want to be shared between releases.
+ # Default: ["log", "tmp/pids", "public/system"]
+ def purge_before_symlink(arg=nil)
+ set_or_return(
+ :purge_before_symlink,
+ arg,
+ :kind_of => Array
+ )
+ end
+
+ # An array of paths, relative to your app's root, where you expect dirs to
+ # exist before symlinking. This runs after #purge_before_symlink, so you
+ # can use this to recreate dirs that you had previously purged.
+ # For example, if you plan to use a shared directory for pids, and you
+ # want it to be located in $APP_ROOT/tmp/pids, you could purge tmp,
+ # then specify tmp here so that the tmp directory will exist when you
+ # symlink the pids directory in to the current release.
+ # Default: ["tmp", "public", "config"]
+ def create_dirs_before_symlink(arg=nil)
+ set_or_return(
+ :create_dirs_before_symlink,
+ arg,
+ :kind_of => Array
+ )
+ end
+
+ # A Hash of shared/dir/path => release/dir/path. This attribute determines
+ # which files and dirs in the shared directory get symlinked to the current
+ # release directory, and where they go. If you have a directory
+ # $shared/pids that you would like to symlink as $current_release/tmp/pids
+ # you specify it as "pids" => "tmp/pids"
+ # Default {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
+ def symlinks(arg=nil)
+ set_or_return(
+ :symlinks,
+ arg,
+ :kind_of => Hash
+ )
+ end
+
+ # A Hash of shared/dir/path => release/dir/path. This attribute determines
+ # which files in the shared directory get symlinked to the current release
+ # directory and where they go. Unlike map_shared_files, these are symlinked
+ # *before* any migration is run.
+ # For a rails/merb app, this is used to link in a known good database.yml
+ # (with the production db password) before running migrate.
+ # Default {"config/database.yml" => "config/database.yml"}
+ def symlink_before_migrate(arg=nil)
+ set_or_return(
+ :symlink_before_migrate,
+ arg,
+ :kind_of => Hash
+ )
+ end
+
+ # Callback fires before migration is run.
+ def before_migrate(arg=nil, &block)
+ arg ||= block
+ set_or_return(:before_migrate, arg, :kind_of => [Proc, String])
+ end
+
+ # Callback fires before symlinking
+ def before_symlink(arg=nil, &block)
+ arg ||= block
+ set_or_return(:before_symlink, arg, :kind_of => [Proc, String])
+ end
+
+ # Callback fires before restart
+ def before_restart(arg=nil, &block)
+ arg ||= block
+ set_or_return(:before_restart, arg, :kind_of => [Proc, String])
+ end
+
+ # Callback fires after restart
+ def after_restart(arg=nil, &block)
+ arg ||= block
+ set_or_return(:after_restart, arg, :kind_of => [Proc, String])
+ end
+
+ def additional_remotes(arg=nil)
+ set_or_return(
+ :additional_remotes,
+ arg,
+ :kind_of => Hash
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/deploy_revision.rb b/lib/chef/resource/deploy_revision.rb
new file mode 100644
index 0000000000..55a3e38130
--- /dev/null
+++ b/lib/chef/resource/deploy_revision.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Copyright:: Copyright (c) 2009 Daniel DeLeo
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+
+ # Convenience class for using the deploy resource with the revision
+ # deployment strategy (provider)
+ class DeployRevision < Chef::Resource::Deploy
+ def initialize(*args, &block)
+ super
+ @resource_name = :deploy_revision
+ @provider = Chef::Provider::Deploy::Revision
+ end
+ end
+
+ class DeployBranch < Chef::Resource::DeployRevision
+ def initialize(*args, &block)
+ super
+ @resource_name = :deploy_branch
+ end
+ end
+
+ end
+end
diff --git a/lib/chef/resource/directory.rb b/lib/chef/resource/directory.rb
new file mode 100644
index 0000000000..a5d5ea7366
--- /dev/null
+++ b/lib/chef/resource/directory.rb
@@ -0,0 +1,65 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+require 'chef/provider/directory'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class Directory < Chef::Resource
+
+ identity_attr :path
+
+ state_attrs :group, :mode, :owner
+
+ include Chef::Mixin::Securable
+
+ provides :directory, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :directory
+ @path = name
+ @action = :create
+ @recursive = false
+ @allowed_actions.push(:create, :delete)
+ @provider = Chef::Provider::Directory
+ end
+
+ def recursive(arg=nil)
+ set_or_return(
+ :recursive,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def path(arg=nil)
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/dpkg_package.rb b/lib/chef/resource/dpkg_package.rb
new file mode 100644
index 0000000000..02886e8649
--- /dev/null
+++ b/lib/chef/resource/dpkg_package.rb
@@ -0,0 +1,34 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/dpkg'
+
+class Chef
+ class Resource
+ class DpkgPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :dpkg_package
+ @provider = Chef::Provider::Package::Dpkg
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/easy_install_package.rb b/lib/chef/resource/easy_install_package.rb
new file mode 100644
index 0000000000..10e80bdd3b
--- /dev/null
+++ b/lib/chef/resource/easy_install_package.rb
@@ -0,0 +1,57 @@
+#
+# Author:: Joe Williams (<joe@joetify.com>)
+# Copyright:: Copyright (c) 2009 Joe Williams
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+
+class Chef
+ class Resource
+ class EasyInstallPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :easy_install_package
+ @provider = Chef::Provider::Package::EasyInstall
+ end
+
+ def easy_install_binary(arg=nil)
+ set_or_return(
+ :easy_install_binary,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def python_binary(arg=nil)
+ set_or_return(
+ :python_install_binary,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def module_name(arg=nil)
+ set_or_return(
+ :module_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/env.rb b/lib/chef/resource/env.rb
new file mode 100644
index 0000000000..4b5fe6cc09
--- /dev/null
+++ b/lib/chef/resource/env.rb
@@ -0,0 +1,63 @@
+#
+# Author:: Doug MacEachern (<dougm@vmware.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2010 VMware, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+ class Env < Chef::Resource
+
+ identity_attr :key_name
+
+ state_attrs :value
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :env
+ @key_name = name
+ @value = nil
+ @action = :create
+ @delim = nil
+ @allowed_actions.push(:create, :delete, :modify)
+ end
+
+ def key_name(arg=nil)
+ set_or_return(
+ :key_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def value(arg=nil)
+ set_or_return(
+ :value,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def delim(arg=nil)
+ set_or_return(
+ :delim,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/erl_call.rb b/lib/chef/resource/erl_call.rb
new file mode 100644
index 0000000000..e0e38926bb
--- /dev/null
+++ b/lib/chef/resource/erl_call.rb
@@ -0,0 +1,86 @@
+#
+# Author:: Joe Williams (<joe@joetify.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Joe Williams
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class ErlCall < Chef::Resource
+
+ # erl_call : http://erlang.org/doc/man/erl_call.html
+
+ identity_attr :code
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :erl_call
+
+ @code = "q()." # your erlang code goes here
+ @cookie = nil # cookie of the erlang node
+ @distributed = false # if you want to have a distributed erlang node
+ @name_type = "sname" # type of erlang hostname name or sname
+ @node_name = "chef@localhost" # the erlang node hostname
+
+ @action = "run"
+ @allowed_actions.push(:run)
+ end
+
+ def code(arg=nil)
+ set_or_return(
+ :code,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def cookie(arg=nil)
+ set_or_return(
+ :cookie,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def distributed(arg=nil)
+ set_or_return(
+ :distributed,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def name_type(arg=nil)
+ set_or_return(
+ :name_type,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def node_name(arg=nil)
+ set_or_return(
+ :node_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
new file mode 100644
index 0000000000..6c07bf9352
--- /dev/null
+++ b/lib/chef/resource/execute.rb
@@ -0,0 +1,132 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Execute < Chef::Resource
+
+ identity_attr :command
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :execute
+ @command = name
+ @backup = 5
+ @action = "run"
+ @creates = nil
+ @cwd = nil
+ @environment = nil
+ @group = nil
+ @path = nil
+ @returns = 0
+ @timeout = nil
+ @user = nil
+ @allowed_actions.push(:run)
+ @umask = nil
+ end
+
+ def umask(arg=nil)
+ set_or_return(
+ :umask,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+ def command(arg=nil)
+ set_or_return(
+ :command,
+ arg,
+ :kind_of => [ String, Array ]
+ )
+ end
+
+ def creates(arg=nil)
+ set_or_return(
+ :creates,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def cwd(arg=nil)
+ set_or_return(
+ :cwd,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def environment(arg=nil)
+ set_or_return(
+ :environment,
+ arg,
+ :kind_of => [ Hash ]
+ )
+ end
+
+ alias :env :environment
+
+ def group(arg=nil)
+ set_or_return(
+ :group,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+ def path(arg=nil)
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => [ Array ]
+ )
+ end
+
+ def returns(arg=nil)
+ set_or_return(
+ :returns,
+ arg,
+ :kind_of => [ Integer, Array ]
+ )
+ end
+
+ def timeout(arg=nil)
+ set_or_return(
+ :timeout,
+ arg,
+ :kind_of => [ Integer ]
+ )
+ end
+
+ def user(arg=nil)
+ set_or_return(
+ :user,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+
+
+ end
+ end
+end
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
new file mode 100644
index 0000000000..0b92f3332d
--- /dev/null
+++ b/lib/chef/resource/file.rb
@@ -0,0 +1,96 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+require 'chef/platform'
+require 'chef/provider/file'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class File < Chef::Resource
+ include Chef::Mixin::Securable
+
+ identity_attr :path
+
+ if Platform.windows?
+ # Use Windows rights instead of standard *nix permissions
+ state_attrs :checksum, :rights, :deny_rights
+ else
+ state_attrs :checksum, :owner, :group, :mode
+ end
+
+ provides :file, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :file
+ @path = name
+ @backup = 5
+ @action = "create"
+ @allowed_actions.push(:create, :delete, :touch, :create_if_missing)
+ @provider = Chef::Provider::File
+ @diff = nil
+ end
+
+
+ def content(arg=nil)
+ set_or_return(
+ :content,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def backup(arg=nil)
+ set_or_return(
+ :backup,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
+
+ def checksum(arg=nil)
+ set_or_return(
+ :checksum,
+ arg,
+ :regex => /^[a-zA-Z0-9]{64}$/
+ )
+ end
+
+ def path(arg=nil)
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def diff(arg=nil)
+ set_or_return(
+ :diff,
+ arg,
+ :kind_of => String
+ )
+ end
+
+
+ end
+ end
+end
diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb
new file mode 100644
index 0000000000..9a9a84900e
--- /dev/null
+++ b/lib/chef/resource/freebsd_package.rb
@@ -0,0 +1,35 @@
+#
+# Author:: AJ Christensen (<aj@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/freebsd'
+
+class Chef
+ class Resource
+ class FreebsdPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :freebsd_package
+ @provider = Chef::Provider::Package::Freebsd
+ end
+
+ end
+ end
+end
+
diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb
new file mode 100644
index 0000000000..6def7b6653
--- /dev/null
+++ b/lib/chef/resource/gem_package.rb
@@ -0,0 +1,53 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+
+class Chef
+ class Resource
+ class GemPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :gem_package
+ @provider = Chef::Provider::Package::Rubygems
+ end
+
+ def source(arg=nil)
+ set_or_return(:source, arg, :kind_of => [ String, Array ])
+ end
+
+ # Sets a custom gem_binary to run for gem commands.
+ def gem_binary(gem_cmd=nil)
+ set_or_return(:gem_binary,gem_cmd,:kind_of => [ String ])
+ end
+
+ ##
+ # Options for the gem install, either a Hash or a String. When a hash is
+ # given, the options are passed to Gem::DependencyInstaller.new, and the
+ # gem will be installed via the gems API. When a String is given, the gem
+ # will be installed by shelling out to the gem command. Using a Hash of
+ # options with an explicit gem_binary will result in undefined behavior.
+ def options(opts=nil)
+ set_or_return(:options,opts,:kind_of => [String,Hash])
+ end
+
+
+ end
+ end
+end
diff --git a/lib/chef/resource/git.rb b/lib/chef/resource/git.rb
new file mode 100644
index 0000000000..774bb24f24
--- /dev/null
+++ b/lib/chef/resource/git.rb
@@ -0,0 +1,46 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "chef/resource/scm"
+
+class Chef
+ class Resource
+ class Git < Chef::Resource::Scm
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :git
+ @provider = Chef::Provider::Git
+ @additional_remotes = Hash[]
+ end
+
+ def additional_remotes(arg=nil)
+ set_or_return(
+ :additional_remotes,
+ arg,
+ :kind_of => Hash
+ )
+ end
+
+ alias :branch :revision
+ alias :reference :revision
+
+ alias :repo :repository
+ end
+ end
+end
diff --git a/lib/chef/resource/group.rb b/lib/chef/resource/group.rb
new file mode 100644
index 0000000000..76f3a779ae
--- /dev/null
+++ b/lib/chef/resource/group.rb
@@ -0,0 +1,83 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 OpsCode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+ class Group < Chef::Resource
+
+ identity_attr :group_name
+
+ state_attrs :members
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :group
+ @group_name = name
+ @gid = nil
+ @members = []
+ @action = :create
+ @append = false
+ @allowed_actions.push(:create, :remove, :modify, :manage)
+ end
+
+ def group_name(arg=nil)
+ set_or_return(
+ :group_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def gid(arg=nil)
+ set_or_return(
+ :gid,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+ def members(arg=nil)
+ converted_members = arg.is_a?(String) ? [].push(arg) : arg
+ set_or_return(
+ :members,
+ converted_members,
+ :kind_of => [ Array ]
+ )
+ end
+
+ alias_method :users, :members
+
+ def append(arg=nil)
+ set_or_return(
+ :append,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def system(arg=nil)
+ set_or_return(
+ :system,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
new file mode 100644
index 0000000000..d31ff0b1c9
--- /dev/null
+++ b/lib/chef/resource/http_request.rb
@@ -0,0 +1,64 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class HttpRequest < Chef::Resource
+
+ identity_attr :url
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :http_request
+ @message = name
+ @url = nil
+ @action = :get
+ @headers = {}
+ @allowed_actions.push(:get, :put, :post, :delete, :head, :options)
+ end
+
+ def url(args=nil)
+ set_or_return(
+ :url,
+ args,
+ :kind_of => String
+ )
+ end
+
+ def message(args=nil)
+ set_or_return(
+ :message,
+ args,
+ :kind_of => Object
+ )
+ end
+
+ def headers(args=nil)
+ set_or_return(
+ :headers,
+ args,
+ :kind_of => Hash
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb
new file mode 100644
index 0000000000..daa8a572a0
--- /dev/null
+++ b/lib/chef/resource/ifconfig.rb
@@ -0,0 +1,149 @@
+#
+# Author:: Jason K. Jackson (jasonjackson@gmail.com)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Jason K. Jackson
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Ifconfig < Chef::Resource
+
+ identity_attr :device
+
+ state_attrs :inet_addr, :mask
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :ifconfig
+ @target = name
+ @action = :add
+ @allowed_actions.push(:add, :delete, :enable, :disable)
+ @hwaddr = nil
+ @mask = nil
+ @inet_addr = nil
+ @bcast = nil
+ @mtu = nil
+ @metric = nil
+ @device = nil
+ @onboot = nil
+ @network = nil
+ @bootproto = nil
+ @onparent = nil
+ end
+
+ def target(arg=nil)
+ set_or_return(
+ :target,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def device(arg=nil)
+ set_or_return(
+ :device,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def hwaddr(arg=nil)
+ set_or_return(
+ :hwaddr,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def inet_addr(arg=nil)
+ set_or_return(
+ :inet_addr,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def bcast(arg=nil)
+ set_or_return(
+ :bcast,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def mask(arg=nil)
+ set_or_return(
+ :mask,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def mtu(arg=nil)
+ set_or_return(
+ :mtu,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def metric(arg=nil)
+ set_or_return(
+ :metric,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def onboot(arg=nil)
+ set_or_return(
+ :onboot,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def network(arg=nil)
+ set_or_return(
+ :network,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def bootproto(arg=nil)
+ set_or_return(
+ :bootproto,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def onparent(arg=nil)
+ set_or_return(
+ :onparent,
+ arg,
+ :kind_of => String
+ )
+ end
+ end
+
+ end
+end
+
+
diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb
new file mode 100644
index 0000000000..f82e0877df
--- /dev/null
+++ b/lib/chef/resource/ips_package.rb
@@ -0,0 +1,42 @@
+#
+# Author:: Jason Williams (<williamsjj@digitar.com>)
+# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/ips'
+
+class Chef
+ class Resource
+ class IpsPackage < ::Chef::Resource::Package
+ def initialize(name, run_context = nil)
+ super(name, run_context)
+ @resource_name = :ips_package
+ @provider = Chef::Provider::Package::Ips
+ @allowed_actions = [ :install, :remove, :upgrade ]
+ @accept_license = false
+ end
+
+ def accept_license(arg=nil)
+ set_or_return(
+ :purge,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
new file mode 100644
index 0000000000..a0fab0428d
--- /dev/null
+++ b/lib/chef/resource/link.rb
@@ -0,0 +1,92 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class Link < Chef::Resource
+ include Chef::Mixin::Securable
+
+ provides :link, :on_platform => :all
+
+ identity_attr :target_file
+
+ state_attrs :to, :owner, :group
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :link
+ @to = nil
+ @action = :create
+ @link_type = :symbolic
+ @target_file = name
+ @allowed_actions.push(:create, :delete)
+ @provider = Chef::Provider::Link
+ end
+
+ def to(arg=nil)
+ set_or_return(
+ :to,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def target_file(arg=nil)
+ set_or_return(
+ :target_file,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def link_type(arg=nil)
+ real_arg = arg.kind_of?(String) ? arg.to_sym : arg
+ set_or_return(
+ :link_type,
+ real_arg,
+ :equal_to => [ :symbolic, :hard ]
+ )
+ end
+
+ def group(arg=nil)
+ set_or_return(
+ :group,
+ arg,
+ :regex => Chef::Config[:group_valid_regex]
+ )
+ end
+
+ def owner(arg=nil)
+ set_or_return(
+ :owner,
+ arg,
+ :regex => Chef::Config[:user_valid_regex]
+ )
+ end
+
+ # make link quack like a file (XXX: not for public consumption)
+ def path
+ @target_file
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
new file mode 100644
index 0000000000..d1b6b5af0b
--- /dev/null
+++ b/lib/chef/resource/log.rb
@@ -0,0 +1,65 @@
+#
+# Author:: Cary Penniman (<cary@rightscale.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+class Chef
+ class Resource
+ class Log < Chef::Resource
+
+ identity_attr :name
+
+ # Sends a string from a recipe to a log provider
+ #
+ # log "some string to log" do
+ # level :info # (default) also supports :warn, :debug, and :error
+ # end
+ #
+ # === Example
+ # log "your string to log"
+ #
+ # or
+ #
+ # log "a debug string" { level :debug }
+ #
+
+ # Initialize log resource with a name as the string to log
+ #
+ # === Parameters
+ # name<String>:: Message to log
+ # collection<Array>:: Collection of included recipes
+ # node<Chef::Node>:: Node where resource will be used
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :log
+ @level = :info
+ @action = :write
+ end
+
+ # <Symbol> Log level, one of :debug, :info, :warn, :error or :fatal
+ def level(arg=nil)
+ set_or_return(
+ :level,
+ arg,
+ :equal_to => [ :debug, :info, :warn, :error, :fatal ]
+ )
+ end
+
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/macports_package.rb b/lib/chef/resource/macports_package.rb
new file mode 100644
index 0000000000..911d3c19cb
--- /dev/null
+++ b/lib/chef/resource/macports_package.rb
@@ -0,0 +1,29 @@
+#
+# Author:: David Balatero (<dbalatero@gmail.com>)
+# Copyright:: Copyright (c) 2009 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+ class MacportsPackage < Chef::Resource::Package
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :macports_package
+ @provider = Chef::Provider::Package::Macports
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb
new file mode 100644
index 0000000000..46a85b2475
--- /dev/null
+++ b/lib/chef/resource/mdadm.rb
@@ -0,0 +1,105 @@
+#
+# Author:: Joe Williams (<joe@joetify.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Joe Williams
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Mdadm < Chef::Resource
+
+ identity_attr :raid_device
+
+ state_attrs :devices, :level, :chunk
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :mdadm
+
+ @chunk = 16
+ @devices = []
+ @exists = false
+ @level = 1
+ @metadata = "0.90"
+ @bitmap = nil
+ @raid_device = name
+
+ @action = :create
+ @allowed_actions.push(:create, :assemble, :stop)
+ end
+
+ def chunk(arg=nil)
+ set_or_return(
+ :chunk,
+ arg,
+ :kind_of => [ Integer ]
+ )
+ end
+
+ def devices(arg=nil)
+ set_or_return(
+ :devices,
+ arg,
+ :kind_of => [ Array ]
+ )
+ end
+
+ def exists(arg=nil)
+ set_or_return(
+ :exists,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def level(arg=nil)
+ set_or_return(
+ :level,
+ arg,
+ :kind_of => [ Integer ]
+ )
+ end
+
+ def metadata(arg=nil)
+ set_or_return(
+ :metadata,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def bitmap(arg=nil)
+ set_or_return(
+ :bitmap,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def raid_device(arg=nil)
+ set_or_return(
+ :raid_device,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+
+ end
+ end
+end
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
new file mode 100644
index 0000000000..8c32bdd280
--- /dev/null
+++ b/lib/chef/resource/mount.rb
@@ -0,0 +1,139 @@
+#
+# Author:: Joshua Timberman (<joshua@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Opscode, Inc
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Mount < Chef::Resource
+
+ identity_attr :device
+
+ state_attrs :mount_point, :device_type, :fstype
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :mount
+ @mount_point = name
+ @device = nil
+ @device_type = :device
+ @fstype = "auto"
+ @options = ["defaults"]
+ @dump = 0
+ @pass = 2
+ @mounted = false
+ @enabled = false
+ @action = :mount
+ @supports = { :remount => false }
+ @allowed_actions.push(:mount, :umount, :remount, :enable, :disable)
+ end
+
+ def mount_point(arg=nil)
+ set_or_return(
+ :mount_point,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def device(arg=nil)
+ set_or_return(
+ :device,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def device_type(arg=nil)
+ real_arg = arg.kind_of?(String) ? arg.to_sym : arg
+ set_or_return(
+ :device_type,
+ real_arg,
+ :equal_to => [ :device, :label, :uuid ]
+ )
+ end
+
+ def fstype(arg=nil)
+ set_or_return(
+ :fstype,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def options(arg=nil)
+ if arg.is_a?(String)
+ converted_arg = arg.gsub(/,/, ' ').split(/ /)
+ else
+ converted_arg = arg
+ end
+ set_or_return(
+ :options,
+ converted_arg,
+ :kind_of => [ Array ]
+ )
+ end
+
+ def dump(arg=nil)
+ set_or_return(
+ :dump,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
+
+ def pass(arg=nil)
+ set_or_return(
+ :pass,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
+
+ def mounted(arg=nil)
+ set_or_return(
+ :mounted,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def enabled(arg=nil)
+ set_or_return(
+ :enabled,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def supports(args={})
+ if args.is_a? Array
+ args.each { |arg| @supports[arg] = true }
+ elsif args.any?
+ @supports = args
+ else
+ @supports
+ end
+ end
+
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb
new file mode 100644
index 0000000000..48e55e9f01
--- /dev/null
+++ b/lib/chef/resource/ohai.rb
@@ -0,0 +1,54 @@
+#
+# Author:: Michael Leinartas (<mleinartas@gmail.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2010 Michael Leinartas
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+ class Ohai < Chef::Resource
+
+ identity_attr :name
+
+ state_attrs :plugin
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :ohai
+ @name = name
+ @allowed_actions.push(:reload)
+ @action = :reload
+ @plugin = nil
+ end
+
+ def plugin(arg=nil)
+ set_or_return(
+ :plugin,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def name(arg=nil)
+ set_or_return(
+ :name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb
new file mode 100644
index 0000000000..eaad3e2e58
--- /dev/null
+++ b/lib/chef/resource/package.rb
@@ -0,0 +1,84 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Package < Chef::Resource
+
+ identity_attr :package_name
+
+ state_attrs :version, :options
+
+ def initialize(name, run_context=nil)
+ super
+ @action = :install
+ @allowed_actions.push(:install, :upgrade, :remove, :purge, :reconfig)
+ @candidate_version = nil
+ @options = nil
+ @package_name = name
+ @resource_name = :package
+ @response_file = nil
+ @source = nil
+ @version = nil
+ end
+
+ def package_name(arg=nil)
+ set_or_return(
+ :package_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def version(arg=nil)
+ set_or_return(
+ :version,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def response_file(arg=nil)
+ set_or_return(
+ :response_file,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def source(arg=nil)
+ set_or_return(
+ :source,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def options(arg=nil)
+ set_or_return(
+ :options,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/pacman_package.rb b/lib/chef/resource/pacman_package.rb
new file mode 100644
index 0000000000..d66c93be66
--- /dev/null
+++ b/lib/chef/resource/pacman_package.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Jan Zimmek (<jan.zimmek@web.de>)
+# Copyright:: Copyright (c) 2010 Jan Zimmek
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+
+class Chef
+ class Resource
+ class PacmanPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :pacman_package
+ @provider = Chef::Provider::Package::Pacman
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/perl.rb b/lib/chef/resource/perl.rb
new file mode 100644
index 0000000000..d3cf696cbb
--- /dev/null
+++ b/lib/chef/resource/perl.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Perl < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :perl
+ @interpreter = "perl"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
new file mode 100644
index 0000000000..fc72381482
--- /dev/null
+++ b/lib/chef/resource/portage_package.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+
+class Chef
+ class Resource
+ class PortagePackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :portage_package
+ @provider = Chef::Provider::Package::Portage
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/python.rb b/lib/chef/resource/python.rb
new file mode 100644
index 0000000000..85a5348d27
--- /dev/null
+++ b/lib/chef/resource/python.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Python < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :python
+ @interpreter = "python"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
new file mode 100644
index 0000000000..490e3c6ba7
--- /dev/null
+++ b/lib/chef/resource/remote_directory.rb
@@ -0,0 +1,125 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/directory'
+require 'chef/provider/remote_directory'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class RemoteDirectory < Chef::Resource::Directory
+ include Chef::Mixin::Securable
+
+ provides :remote_directory, :on_platforms => :all
+
+ identity_attr :path
+
+ state_attrs :files_owner, :files_group, :files_mode
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :remote_directory
+ @path = name
+ @source = ::File.basename(name)
+ @delete = false
+ @action = :create
+ @recursive = true
+ @purge = false
+ @files_backup = 5
+ @files_owner = nil
+ @files_group = nil
+ @files_mode = 0644 unless Chef::Platform.windows?
+ @overwrite = true
+ @allowed_actions.push(:create, :create_if_missing, :delete)
+ @cookbook = nil
+ @provider = Chef::Provider::RemoteDirectory
+ end
+
+ def source(args=nil)
+ set_or_return(
+ :source,
+ args,
+ :kind_of => String
+ )
+ end
+
+ def files_backup(arg=nil)
+ set_or_return(
+ :files_backup,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
+
+ def purge(arg=nil)
+ set_or_return(
+ :purge,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def files_group(arg=nil)
+ set_or_return(
+ :files_group,
+ arg,
+ :regex => Chef::Config[:group_valid_regex]
+ )
+ end
+
+ if Chef::Platform.windows?
+ # create a second instance of the 'rights' attribute
+ Chef::Mixin::Securable.rights_attribute(:files_rights)
+ end
+
+ def files_mode(arg=nil)
+ set_or_return(
+ :files_mode,
+ arg,
+ :regex => /^\d{3,4}$/
+ )
+ end
+
+ def files_owner(arg=nil)
+ set_or_return(
+ :files_owner,
+ arg,
+ :regex => Chef::Config[:user_valid_regex]
+ )
+ end
+
+ def overwrite(arg=nil)
+ set_or_return(
+ :overwrite,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def cookbook(args=nil)
+ set_or_return(
+ :cookbook,
+ args,
+ :kind_of => String
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
new file mode 100644
index 0000000000..2798cba3f2
--- /dev/null
+++ b/lib/chef/resource/remote_file.rb
@@ -0,0 +1,81 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/file'
+require 'chef/provider/remote_file'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class RemoteFile < Chef::Resource::File
+ include Chef::Mixin::Securable
+
+ provides :remote_file, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :remote_file
+ @action = "create"
+ @source = nil
+ @provider = Chef::Provider::RemoteFile
+ end
+
+ def source(*args)
+ if not args.empty?
+ args = Array(args).flatten
+ validate_source(args)
+ @source = args
+ elsif self.instance_variable_defined?(:@source) == true
+ @source
+ end
+ end
+
+ def checksum(args=nil)
+ set_or_return(
+ :checksum,
+ args,
+ :kind_of => String
+ )
+ end
+
+ def after_created
+ validate_source(@source)
+ end
+
+ private
+
+ def validate_source(source)
+ raise ArgumentError, "#{resource_name} has an empty source" if source.empty?
+ source.each do |src|
+ unless absolute_uri?(src)
+ raise Exceptions::InvalidRemoteFileURI,
+ "#{src.inspect} is not a valid `source` parameter for #{resource_name}. `source` must be an absolute URI or an array of URIs."
+ end
+ end
+ end
+
+ def absolute_uri?(source)
+ source.kind_of?(String) and URI.parse(source).absolute?
+ rescue URI::InvalidURIError
+ false
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb
new file mode 100644
index 0000000000..cdd61f3a4b
--- /dev/null
+++ b/lib/chef/resource/route.rb
@@ -0,0 +1,140 @@
+#
+# Author:: Bryan McLellan (btm@loftninjas.org)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2009 Bryan McLellan
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Route < Chef::Resource
+
+ identity_attr :target
+
+ state_attrs :netmask, :gateway
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :route
+ @target = name
+ @action = :add
+ @allowed_actions.push(:add, :delete)
+ @netmask = nil
+ @gateway = nil
+ @metric = nil
+ @device = nil
+ @route_type = :host
+ @networking = nil
+ @networking_ipv6 = nil
+ @hostname = nil
+ @domainname = nil
+ @domain = nil
+ end
+
+ def networking(arg=nil)
+ set_or_return(
+ :networking,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def networking_ipv6(arg=nil)
+ set_or_return(
+ :networking_ipv6,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def hostname(arg=nil)
+ set_or_return(
+ :hostname,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def domainname(arg=nil)
+ set_or_return(
+ :domainname,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def domain(arg=nil)
+ set_or_return(
+ :domain,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def target(arg=nil)
+ set_or_return(
+ :target,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def netmask(arg=nil)
+ set_or_return(
+ :netmask,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def gateway(arg=nil)
+ set_or_return(
+ :gateway,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def metric(arg=nil)
+ set_or_return(
+ :metric,
+ arg,
+ :kind_of => Integer
+ )
+ end
+
+ def device(arg=nil)
+ set_or_return(
+ :device,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def route_type(arg=nil)
+ real_arg = arg.kind_of?(String) ? arg.to_sym : arg
+ set_or_return(
+ :route_type,
+ real_arg,
+ :equal_to => [ :host, :net ]
+ )
+ end
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/rpm_package.rb b/lib/chef/resource/rpm_package.rb
new file mode 100644
index 0000000000..7ab1202ef2
--- /dev/null
+++ b/lib/chef/resource/rpm_package.rb
@@ -0,0 +1,34 @@
+#
+# Author:: Thomas Bishop (<bishop.thomas@gmail.com>)
+# Copyright:: Copyright (c) 2010 Thomas Bishop
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/rpm'
+
+class Chef
+ class Resource
+ class RpmPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :rpm_package
+ @provider = Chef::Provider::Package::Rpm
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/ruby.rb b/lib/chef/resource/ruby.rb
new file mode 100644
index 0000000000..7617839bab
--- /dev/null
+++ b/lib/chef/resource/ruby.rb
@@ -0,0 +1,33 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/script'
+
+class Chef
+ class Resource
+ class Ruby < Chef::Resource::Script
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :ruby
+ @interpreter = "ruby"
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/ruby_block.rb b/lib/chef/resource/ruby_block.rb
new file mode 100644
index 0000000000..296345bde3
--- /dev/null
+++ b/lib/chef/resource/ruby_block.rb
@@ -0,0 +1,51 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: AJ Christensen (<aj@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+ class RubyBlock < Chef::Resource
+
+ identity_attr :block_name
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :ruby_block
+ @action = "run"
+ @allowed_actions << :create << :run
+ @block_name = name
+ end
+
+ def block(&block)
+ if block_given? and block
+ @block = block
+ else
+ @block
+ end
+ end
+
+ def block_name(arg=nil)
+ set_or_return(
+ :block_name,
+ arg,
+ :kind_of => String
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/scm.rb b/lib/chef/resource/scm.rb
new file mode 100644
index 0000000000..781e09a2c9
--- /dev/null
+++ b/lib/chef/resource/scm.rb
@@ -0,0 +1,151 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Scm < Chef::Resource
+
+ identity_attr :destination
+
+ state_attrs :revision
+
+ def initialize(name, run_context=nil)
+ super
+ @destination = name
+ @resource_name = :scm
+ @enable_submodules = false
+ @revision = "HEAD"
+ @remote = "origin"
+ @ssh_wrapper = nil
+ @depth = nil
+ @allowed_actions.push(:checkout, :export, :sync, :diff, :log)
+ @action = [:sync]
+ end
+
+ def destination(arg=nil)
+ set_or_return(
+ :destination,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def repository(arg=nil)
+ set_or_return(
+ :repository,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def revision(arg=nil)
+ set_or_return(
+ :revision,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def user(arg=nil)
+ set_or_return(
+ :user,
+ arg,
+ :kind_of => [String, Integer]
+ )
+ end
+
+ def group(arg=nil)
+ set_or_return(
+ :group,
+ arg,
+ :kind_of => [String, Integer]
+ )
+ end
+
+ def svn_username(arg=nil)
+ set_or_return(
+ :svn_username,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def svn_password(arg=nil)
+ set_or_return(
+ :svn_password,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def svn_arguments(arg=nil)
+ @svn_arguments, arg = nil, nil if arg == false
+ set_or_return(
+ :svn_arguments,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def svn_info_args(arg=nil)
+ @svn_info_args, arg = nil, nil if arg == false
+ set_or_return(
+ :svn_info_args,
+ arg,
+ :kind_of => String)
+ end
+
+ # Capistrano and git-deploy use ``shallow clone''
+ def depth(arg=nil)
+ set_or_return(
+ :depth,
+ arg,
+ :kind_of => Integer
+ )
+ end
+
+ def enable_submodules(arg=nil)
+ set_or_return(
+ :enable_submodules,
+ arg,
+ :kind_of => [TrueClass, FalseClass]
+ )
+ end
+
+ def remote(arg=nil)
+ set_or_return(
+ :remote,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ def ssh_wrapper(arg=nil)
+ set_or_return(
+ :ssh_wrapper,
+ arg,
+ :kind_of => String
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
new file mode 100644
index 0000000000..6a7c8e0d5e
--- /dev/null
+++ b/lib/chef/resource/script.rb
@@ -0,0 +1,63 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/execute'
+
+class Chef
+ class Resource
+ class Script < Chef::Resource::Execute
+
+ identity_attr :command
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :script
+ @command = name
+ @code = nil
+ @interpreter = nil
+ @flags = nil
+ end
+
+ def code(arg=nil)
+ set_or_return(
+ :code,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def interpreter(arg=nil)
+ set_or_return(
+ :interpreter,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def flags(arg=nil)
+ set_or_return(
+ :flags,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb
new file mode 100644
index 0000000000..3ace5cbec3
--- /dev/null
+++ b/lib/chef/resource/service.rb
@@ -0,0 +1,164 @@
+#
+# Author:: AJ Christensen (<aj@hjksolutions.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class Service < Chef::Resource
+
+ identity_attr :service_name
+
+ state_attrs :enabled, :running
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :service
+ @service_name = name
+ @enabled = nil
+ @running = nil
+ @parameters = nil
+ @pattern = service_name
+ @start_command = nil
+ @stop_command = nil
+ @status_command = nil
+ @restart_command = nil
+ @reload_command = nil
+ @priority = nil
+ @action = "nothing"
+ @startup_type = :automatic
+ @supports = { :restart => false, :reload => false, :status => false }
+ @allowed_actions.push(:enable, :disable, :start, :stop, :restart, :reload)
+ end
+
+ def service_name(arg=nil)
+ set_or_return(
+ :service_name,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # regex for match against ps -ef when !supports[:has_status] && status == nil
+ def pattern(arg=nil)
+ set_or_return(
+ :pattern,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # command to call to start service
+ def start_command(arg=nil)
+ set_or_return(
+ :start_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # command to call to stop service
+ def stop_command(arg=nil)
+ set_or_return(
+ :stop_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # command to call to get status of service
+ def status_command(arg=nil)
+ set_or_return(
+ :status_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # command to call to restart service
+ def restart_command(arg=nil)
+ set_or_return(
+ :restart_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def reload_command(arg=nil)
+ set_or_return(
+ :reload_command,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ # if the service is enabled or not
+ def enabled(arg=nil)
+ set_or_return(
+ :enabled,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ # if the service is running or not
+ def running(arg=nil)
+ set_or_return(
+ :running,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ # Priority arguments can have two forms:
+ #
+ # - a simple number, in which the default start runlevels get
+ # that as the start value and stop runlevels get 100 - value.
+ #
+ # - a hash like { 2 => [:start, 20], 3 => [:stop, 55] }, where
+ # the service will be marked as started with priority 20 in
+ # runlevel 2, stopped in 3 with priority 55 and no symlinks or
+ # similar for other runlevels
+ #
+ def priority(arg=nil)
+ set_or_return(:priority,
+ arg,
+ :kind_of => [ Integer, String, Hash ])
+ end
+
+ def parameters(arg=nil)
+ set_or_return(
+ :parameters,
+ arg,
+ :kind_of => [ Hash ] )
+ end
+
+ def supports(args={})
+ if args.is_a? Array
+ args.each { |arg| @supports[arg] = true }
+ elsif args.any?
+ @supports = args
+ else
+ @supports
+ end
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/smartos_package.rb b/lib/chef/resource/smartos_package.rb
new file mode 100644
index 0000000000..315481bd93
--- /dev/null
+++ b/lib/chef/resource/smartos_package.rb
@@ -0,0 +1,36 @@
+#
+# Author:: Toomas Pelberg (<toomasp@gmx.net>)
+# Copyright:: Copyright (c) 2010 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/smartos'
+
+class Chef
+ class Resource
+ class SmartOSPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :smartos_package
+ @provider = Chef::Provider::Package::SmartOS
+ end
+
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/solaris_package.rb b/lib/chef/resource/solaris_package.rb
new file mode 100644
index 0000000000..becf0236ad
--- /dev/null
+++ b/lib/chef/resource/solaris_package.rb
@@ -0,0 +1,36 @@
+#
+# Author:: Toomas Pelberg (<toomasp@gmx.net>)
+# Copyright:: Copyright (c) 2010 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/solaris'
+
+class Chef
+ class Resource
+ class SolarisPackage < Chef::Resource::Package
+
+ def initialize(name, collection=nil, node=nil)
+ super(name, collection, node)
+ @resource_name = :solaris_package
+ @provider = Chef::Provider::Package::Solaris
+ end
+
+ end
+ end
+end
+
+
diff --git a/lib/chef/resource/subversion.rb b/lib/chef/resource/subversion.rb
new file mode 100644
index 0000000000..e3226d8b3b
--- /dev/null
+++ b/lib/chef/resource/subversion.rb
@@ -0,0 +1,37 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "chef/resource/scm"
+
+class Chef
+ class Resource
+ class Subversion < Chef::Resource::Scm
+
+ def initialize(name, run_context=nil)
+ super
+ @svn_arguments = '--no-auth-cache'
+ @svn_info_args = '--no-auth-cache'
+ @resource_name = :subversion
+ @provider = Chef::Provider::Subversion
+ allowed_actions << :force_export
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
new file mode 100644
index 0000000000..af51b64700
--- /dev/null
+++ b/lib/chef/resource/template.rb
@@ -0,0 +1,76 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Author:: Tyler Cloke (<tyler@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/file'
+require 'chef/provider/template'
+require 'chef/mixin/securable'
+
+class Chef
+ class Resource
+ class Template < Chef::Resource::File
+ include Chef::Mixin::Securable
+
+ provides :template, :on_platforms => :all
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :template
+ @action = "create"
+ @source = "#{::File.basename(name)}.erb"
+ @cookbook = nil
+ @local = false
+ @variables = Hash.new
+ @provider = Chef::Provider::Template
+ end
+
+ def source(file=nil)
+ set_or_return(
+ :source,
+ file,
+ :kind_of => [ String ]
+ )
+ end
+
+ def variables(args=nil)
+ set_or_return(
+ :variables,
+ args,
+ :kind_of => [ Hash ]
+ )
+ end
+
+ def cookbook(args=nil)
+ set_or_return(
+ :cookbook,
+ args,
+ :kind_of => [ String ]
+ )
+ end
+
+ def local(args=nil)
+ set_or_return(
+ :local,
+ args,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/timestamped_deploy.rb b/lib/chef/resource/timestamped_deploy.rb
new file mode 100644
index 0000000000..d89274bb44
--- /dev/null
+++ b/lib/chef/resource/timestamped_deploy.rb
@@ -0,0 +1,31 @@
+#
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Copyright:: Copyright (c) 2009 Daniel DeLeo
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Resource
+
+ # Convenience class for using the deploy resource with the timestamped
+ # deployment strategy (provider)
+ class TimestampedDeploy < Chef::Resource::Deploy
+ def initialize(*args, &block)
+ super(*args, &block)
+ @provider = Chef::Provider::Deploy::Timestamped
+ end
+ end
+ end
+end
diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb
new file mode 100644
index 0000000000..4d8c4ac11b
--- /dev/null
+++ b/lib/chef/resource/user.rb
@@ -0,0 +1,134 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource'
+
+class Chef
+ class Resource
+ class User < Chef::Resource
+
+ identity_attr :username
+
+ state_attrs :uid, :gid, :home
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :user
+ @username = name
+ @comment = nil
+ @uid = nil
+ @gid = nil
+ @home = nil
+ @shell = nil
+ @password = nil
+ @system = false
+ @manage_home = false
+ @non_unique = false
+ @action = :create
+ @supports = {
+ :manage_home => false,
+ :non_unique => false
+ }
+ @allowed_actions.push(:create, :remove, :modify, :manage, :lock, :unlock)
+ end
+
+ def username(arg=nil)
+ set_or_return(
+ :username,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def comment(arg=nil)
+ set_or_return(
+ :comment,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def uid(arg=nil)
+ set_or_return(
+ :uid,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+ def gid(arg=nil)
+ set_or_return(
+ :gid,
+ arg,
+ :kind_of => [ String, Integer ]
+ )
+ end
+
+ alias_method :group, :gid
+
+ def home(arg=nil)
+ set_or_return(
+ :home,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def shell(arg=nil)
+ set_or_return(
+ :shell,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def password(arg=nil)
+ set_or_return(
+ :password,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def system(arg=nil)
+ set_or_return(
+ :system,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def manage_home(arg=nil)
+ set_or_return(
+ :manage_home,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ def non_unique(arg=nil)
+ set_or_return(
+ :non_unique,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb
new file mode 100644
index 0000000000..bcb1f65667
--- /dev/null
+++ b/lib/chef/resource/yum_package.rb
@@ -0,0 +1,63 @@
+#
+# Author:: AJ Christensen (<aj@opscode.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+require 'chef/provider/package/yum'
+
+class Chef
+ class Resource
+ class YumPackage < Chef::Resource::Package
+
+ def initialize(name, run_context=nil)
+ super
+ @resource_name = :yum_package
+ @provider = Chef::Provider::Package::Yum
+ @flush_cache = { :before => false, :after => false }
+ @allow_downgrade = false
+ end
+
+ # Install a specific arch
+ def arch(arg=nil)
+ set_or_return(
+ :arch,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def flush_cache(args={})
+ if args.is_a? Array
+ args.each { |arg| @flush_cache[arg] = true }
+ elsif args.any?
+ @flush_cache = args
+ else
+ @flush_cache
+ end
+ end
+
+ def allow_downgrade(arg=nil)
+ set_or_return(
+ :allow_downgrade,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
+
+ end
+ end
+end