Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with creating EBS Volume #223

Closed
tonyjchong opened this issue Jun 26, 2014 · 4 comments
Closed

Need help with creating EBS Volume #223

tonyjchong opened this issue Jun 26, 2014 · 4 comments

Comments

@tonyjchong
Copy link

Hi, I think I'm missing an attribute but not sure where. Here are my attributes in my elastic search role.

elasticsearch => {
:data => {
            :devices => {
                '/dev/xvda2' => {
                    :file_system => "ext3",
                    :mount_options => "rw,user",
                    :mount_path => "/mnt2/",
                    :format_command => "mkfs.ext3",
                    :fs_check_command => "dumpe2fs",
                    :ebs => {
                        :size => "1024",
                        :delete_on_termination => true,
                        :type => "io1",
                        :device => "/dev/sda2"                  }
                }
            }
        }
    }
}

Then I get this error:

 * ruby_block[Create EBS volume on /dev/xvda2 (size: 1024GB)] action run[2014-06-26T16:02:19+00:00] INFO: Processing ruby_block[Create EBS volume on /dev/xvda2 (size: 1024GB)] action run (elasticsearch::ebs line 16)

================================================================================
Error executing action `run` on resource 'ruby_block[Create EBS volume on /dev/xvda2 (size: 1024GB)]'
================================================================================


NoMethodError
-------------
undefined method `volumes' for nil:NilClass


Cookbook Trace:
---------------
/var/chef/cache/cookbooks/elasticsearch/libraries/create_ebs.rb:41:in `block (2 levels) in create_ebs'


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/elasticsearch/libraries/create_ebs.rb

 16:     ruby_block "Create EBS volume on #{device} (size: #{params[:ebs][:size]}GB)" do
 17:
 18:       block do
 19:         require 'fog'
 20:         require 'open-uri'
 21:
 22:         region      = params[:region] || node.elasticsearch[:cloud][:aws][:region]
 23:         instance_id = open('http://169.254.169.254/latest/meta-data/instance-id'){|f| f.gets}
 24:         raise "[!] Cannot get instance id from AWS meta-data API" unless instance_id
 25:
 26:         Chef::Log.debug("Region: #{region}, instance ID: #{instance_id}")
 27:
 28:         fog_options = { :provider => 'AWS', :region => region }
 29:         if (access_key = node.elasticsearch[:cloud][:aws][:access_key]) &&
 30:             (secret_key = node.elasticsearch[:cloud][:aws][:secret_key])
 31:           fog_options.merge!(:aws_access_key_id => access_key, :aws_secret_access_key => secret_key)
 32:         else  # Lack of credentials implies a IAM role will provide keys
 33:           fog_options.merge!(:use_iam_profile => true)
 34:         end
 35:         aws = Fog::Compute.new(fog_options)
 36:
 37:         server = aws.servers.get instance_id
 38:
 39:         # Create EBS volume if the device is free
 40:         ebs_device = params[:ebs][:device] || device
 41:         unless server.volumes.map(&:device).include?(ebs_device)
 42:           options = { :device                => ebs_device,
 43:                       :size                  => params[:ebs][:size],
 44:                       :delete_on_termination => params[:ebs][:delete_on_termination],
 45:                       :availability_zone     => server.availability_zone,
 46:                       :server                => server }
 47:
 48:           options[:type] = params[:ebs][:type] if params[:ebs][:type]
 49:           options[:iops] = params[:ebs][:iops] if params[:ebs][:iops] and params[:ebs][:type] == "io1"
 50:
 51:           if params[:ebs][:snapshot_id]
 52:             if snapshot = aws.snapshots.get(params[:ebs][:snapshot_id])
 53:               Chef::Log.info "Creating EBS from snapshot: #{snapshot.id} (" +
 54:                              "Tags: #{snapshot.tags.inspect}, "             +
 55:                              "Description: #{snapshot.description})"
 56:               options[:snapshot_id] = snapshot.id
 57:             else
 58:               __message = "[!] Cannot find snapshot: #{params[:ebs][:snapshot_id]}"
 59:               Chef::Log.fatal __message
 60:               raise __message
 61:             end
 62:           end



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/elasticsearch/libraries/create_ebs.rb:16:in `create_ebs'

ruby_block("Create EBS volume on /dev/xvda2 (size: 1024GB)") do
  action "run"
  retries 0
  retry_delay 2
  guard_interpreter :default
  block_name "Create EBS volume on /dev/xvda2 (size: 1024GB)"
  cookbook_name "elasticsearch"
  recipe_name "ebs"
  block #<Proc:0x00000002fe7160@/var/chef/cache/cookbooks/elasticsearch/libraries/create_ebs.rb:18>
end



[2014-06-26T16:02:22+00:00] INFO: Running queued delayed notifications before re-raising exception

Thanks everyone.

@sotzing
Copy link

sotzing commented Sep 4, 2014

I had the same issue and eventually realized my cloud.aws.region attribute was incorrectly set (to another region). correcting it took care of the problem for me.

@redterror
Copy link

@sotzing - thanks for that comment, it helped me.

Perhaps the better thing to do would be to fetch more of the instance metadata and pull the region from there?

@martinb3
Copy link
Contributor

martinb3 commented Jul 1, 2015

You might also try the aws cookbook. It probably has better support for EBS volumes than this one.

@martinb3
Copy link
Contributor

martinb3 commented Jul 6, 2015

Hello! It sounds like you were able to get this working. In the meantime, we've re-written the cookbook using libraries that expose resources and providers, and we've removed support for the EBS recipe. I would recommend using the AWS chef cookbook for this use case now. Hope this helps.

@martinb3 martinb3 closed this as completed Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants