[chef] How to handle the elastic_ip associate recipe to finish up smoothly?


Chronological Thread 
  • From: Millisami < >
  • To:
  • Subject: [chef] How to handle the elastic_ip associate recipe to finish up smoothly?
  • Date: Thu, 5 Jul 2012 06:04:06 -0700 (PDT)


Hi Chefellas!

I fire up a ec2 instance on AWS as follows:

    knife ec2 server create -E staging -N cf-worker -x ubuntu -G cf-worker -i
~/.ssh/deployer.pem -r 'role[resque_worker]'

    .....
    ec2-50-16-125-18.compute-1.amazonaws.com update-initramfs: Generating
/boot/initrd.img-3.2.0-23-virtual
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:10:15 +0000]
INFO: *** Chef 10.12.0 ***
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:10:18 +0000]
INFO: Client key /etc/chef/client.pem is not present - registering
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:10:27 +0000]
INFO: Setting the run_list to ["role[resque_worker]"] from JSON
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:10:29 +0000]
INFO: Run List is [role[resque_worker]]
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:10:29 +0000]
INFO: Run List expands to [chef-client::delete_validation, 
chef-client::config,
chef-client::service, apt, git, build-essential, timezone, openssh, postfix,
postfix::aliases, unattended_upgrades, ntp, base::install_ruby, vim, sudo,
base, base::sshd, aws, base::iptables, users::sysadmins, cf_users,
cf_worker::default, cf_worker::deploy, cf_worker::resque,
cf_worker::associate_eip]
    .....

The last recipe cf_worker::associate_eip in the run_list is as follows:


    if node.has_key?("cloud")
      include_recipe "aws"

      aws = data_bag_item("aws", "main")
      elastic_ips = data_bag_item("aws", "elastic_ips")

      eip = elastic_ips['cf_worker'][node.chef_environment]

      aws_elastic_ip "eip_cf_worker" do
        aws_access_key aws['aws_access_key_id']
        aws_secret_access_key aws['aws_secret_access_key']
        ip eip
        action :associate
      end
    end

If I exclude this last recipe, everything goes smoothly and well and the
chef-handler completes successfully.
But If I include it, doesn't matter the order, whether I put it at first or
middle or last, the moment it associates the Elastic Ip, it keeps on hanging.

    .....
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:20:52 +0000]
INFO: Processing service[god-monitor] action restart (cf_worker::resque line
29)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:20:57 +0000]
INFO: service[god-monitor] restarted
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:20:57 +0000]
INFO: Processing service[god-monitor] action start (cf_worker::resque line 29)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:03 +0000]
INFO: Processing aws_elastic_ip[eip_cf_worker] action associate
(cf_worker::associate_eip line 10)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:03 +0000]
INFO: New RightAws::Ec2 using shared connections mode
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:03 +0000]
INFO: Opening new HTTPS connection to us-east-1.ec2.amazonaws.com:443
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: Attaching Elastic IP 23.23.85.126 to the instance
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: template[/etc/chef/client.rb] sending create action to
ruby_block[reload_client_config] (delayed)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: Processing ruby_block[reload_client_config] action create
(chef-client::config line 53)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: ruby_block[reload_client_config] called
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: template[/etc/init.d/chef-client] sending restart action to
service[chef-client] (delayed)
    ec2-50-16-125-18.compute-1.amazonaws.com [Thu, 05 Jul 2012 12:21:07 +0000]
INFO: Processing service[chef-client] action restart (chef-client::service 
line
76)
    ...KEEPS ON HANGING UNTIL I FORCEFULLY (Ctrl + C) stop it...

Its so weird and I couldn't figure out why this happens?
How you guys handle the elastic ip scenerio?



Archive powered by MHonArc 2.6.16.

§