Skip to content

Instantly share code, notes, and snippets.

View rberger's full-sized avatar

Robert J. Berger rberger

View GitHub Profile
ebs_volume "mysql_data_volume" do
aws_access_key node[:runa][:aws_access_key]
aws_secret_access_key node[:runa][:aws_secret_access_key]
volume_id node[:runa][:volume_id]
availability_zone node[:runa][:availability_zone]
device node[:runa][:device]
action :attach
provider "Chef::Provider::Aws::EbsVolume"
end
ebs_volume "mysql_data_volume" do
aws_access_key node[:runa][:aws_access_key]
aws_secret_access_key node[:runa][:aws_secret_access_key]
volume_id node[:runa][:volume_id]
availability_zone node[:runa][:availability_zone]
device node[:runa][:device]
action :attach
provider "aws_ebs_volume"
end
Sun, 29 Nov 2009 05:07:19 +0000] DEBUG: Loading Recipe aws
[Sun, 29 Nov 2009 05:07:19 +0000] DEBUG: Found recipe default in cookbook aws
[Sun, 29 Nov 2009 05:07:19 +0000] DEBUG: right_aws at version 1.10.0
[Sun, 29 Nov 2009 05:07:19 +0000] DEBUG: Loading Recipe runtime-db
[Sun, 29 Nov 2009 05:07:19 +0000] DEBUG: Found recipe default in cookbook runtime-db
/usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/mixin/recipe_definition_dsl_core.rb:57:in `method_missing': Cannot find EbsVolume for ebs_volume (NameError)
Original exception: NameError: uninitialized constant Chef::Resource::EbsVolume
from /var/chef/cache/cookbooks/runtime-db/recipes/default.rb:1:in `from_file'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/cookbook.rb:166:in `load_recipe'
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/compile.rb:156:in `load_recipes'
# You will have to have somehow included the opscode cookbook aws recipe before this
# with a depends statement in the metadata.rb of this recipe
aws_ebs_volume "mysql_data_volume" do
aws_access_key node[:runa][:aws_access_key]
aws_secret_access_key node[:runa][:aws_secret_access_key]
volume_id node[:runa][:volume_id]
availability_zone node[:runa][:availability_zone]
device node[:runa][:device]
action :attach
def setup_volume(action_to_use, volume_info)
aws_ebs_volume "mysql_data_volume" do
Chef::Log.debug("in mysql_data_volume action_to_use: #{action_to_use} volume_info: #{volume_info}")
aws_access_key node[:runa][:aws_access_key]
aws_secret_access_key node[:runa][:aws_secret_access_key]
volume_id (action_to_use == :attach) ? node[:runa][:volume_id] : nil
snapshot_id (action_to_use == :create) ? node[:runa][:snapshot_id] : nil
availability_zone node[:runa][:availability_zone]
device node[:runa][:device]
action action_to_use
[Sun, 29 Nov 2009 23:55:42 +0000] DEBUG: Processing aws_ebs_volume[mysql_data_volume]
[Sun, 29 Nov 2009 23:55:42 +0000] DEBUG: aws_ebs_volume[mysql_data_volume] using Chef::Provider::AwsEbsVolume
[Sun, 29 Nov 2009 23:55:42 +0000] INFO: New RightAws::Ec2 using shared connections mode
[Sun, 29 Nov 2009 23:55:42 +0000] INFO: Opening new HTTPS connection to ec2.amazonaws.com:443
warning: peer certificate won't be verified in this SSL session
[Sun, 29 Nov 2009 23:55:42 +0000] DEBUG: Instance ID is i-0def9d65
[Sun, 29 Nov 2009 23:55:42 +0000] ERROR: aws_ebs_volume[mysql_data_volume] (/usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/mixin/recipe_definition_dsl_core.rb line 54) had an error:
Volume with id vol-5a6e9633 exists but is attached to instance i-7367111b
/var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:38:in `class_from_file'/usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/provider.rb:81:in `instance_eval'/usr/lib/ruby/gems/1.8/gems/chef-0.7.14/lib/chef/provider.rb:81:in `action_attach'/usr/lib/ruby/ge
def setup_volume(action_to_use, volume_info)
Chef::Log.debug("outside mysql_data_volume action_to_use: #{action_to_use} volume_info: #{volume_info}")
aws_ebs_volume "mysql_data_volume" do
Chef::Log.debug("in mysql_data_volume action_to_use: #{action_to_use} volume_info: #{volume_info}")
aws_access_key node[:runa][:aws_access_key]
aws_secret_access_key node[:runa][:aws_secret_access_key]
volume_id (action_to_use == :attach) ? node[:runa][:volume_id] : nil
snapshot_id (action_to_use == :create) ? node[:runa][:snapshot_id] : nil
availability_zone node[:runa][:availability_zone]
http://wiki.opscode.com/display/chef/Light-weight+Resources+and+Providers+%28LWRP%2
Providers
Background
A chef-client run has two stages:
the compilation phase, in which the client examines each Recipe in order and adds its Resources to the ResourceCollection
the ResourceCollection execution phase, in which the client iterates over the ResourceCollection and performs the following:
Based on the Resource's "provider" attribute, a new instance of the specified Provider is created (if the attribute is not set, one is selected based on the local platform). The originating Resource is stored in the new Provider as the @new_resource instance variable.
The load_current_resource method is then called on the provider instance, giving it an opportunity to populate @current_resource with a new resource that represents the current state of the relevant part of the system.
For each action specified in @new_resource.actions, the action_ method that corresponds to each action is called (e.g. action :create will invoke the
[Thu, 11 Feb 2010 22:25:03 +0000] DEBUG: Executing git ls-remote git@github.com:rberger/runa_merchant.git HEAD
[Thu, 11 Feb 2010 22:25:03 +0000] DEBUG: Executing git ls-remote git@github.com:rberger/runa_merchant.git HEAD
[Thu, 11 Feb 2010 22:25:04 +0000] DEBUG: ---- Begin output of git ls-remote git@github.com:rberger/runa_merchant.git HEAD ----
[Thu, 11 Feb 2010 22:25:04 +0000] DEBUG: STDOUT: e148fe14e782d8895890200867cc68ea118eb837 HEAD
[Thu, 11 Feb 2010 22:25:04 +0000] DEBUG: STDERR:
[Thu, 11 Feb 2010 22:25:04 +0000] DEBUG: ---- End output of git ls-remote git@github.com:rberger/runa_merchant.git HEAD ----
[Thu, 11 Feb 2010 22:25:04 +0000] DEBUG: Ran git ls-remote git@github.com:rberger/runa_merchant.git HEAD returned 0
[Thu, 11 Feb 2010 22:25:04 +0000] INFO: deploying branch: HEAD
[Thu, 11 Feb 2010 22:25:04 +0000] INFO: ensuring proper ownership
[Thu, 11 Feb 2010 22:25:05 +0000] INFO: updating the cached checkout
Created the file /etc/init/test.conf with the following contents:
(The behavior is the same if I use $A instead of ${A})
-------- Start of test.conf -----
start on (start_foo A=*)
stop on (stop_foo A=*)
instance ${A}