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


Chronological Thread 
  • From: Sachin Sagar Rai < >
  • To:
  • Subject: [chef] Re: Re: How to handle the elastic_ip associate recipe to finish up smoothly?
  • Date: Sat, 7 Jul 2012 00:12:30 +0545

Anybody, any pointers?

-------------------------------------------
@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow

On Friday, July 6, 2012 at 11:57 AM, Sachin Sagar Rai wrote:

Hi, thanks for the reply.

Out of the 2 options you've suggested, I want to opt for screen/tmux style. Well I can install the screen/tmux at the bootstrapping time but didn't understand on how to run chef-client under that.

Here is my bootstrap file https://gist.github.com/3058377

Can you modify/updated it with what you are suggesting?

Thanks

-------------------------------------------
@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow

On Friday, July 6, 2012 at 6:14 AM, Scott M. Likens wrote:

Hi,

Unfortunately if you are not running chef-solo under (screen and/or tmux) your SSH connection will get interrupted once the new IP address is attached to the instance. 

The only real way to make this better is to either do one of the following:

  1. Run chef-client under screen/tmux on the server itself.   Likely modifying the bootstrap so it installs screen (and or tmux) and then runs chef-client under that. 
  2. Provision the servers first and then run knife bootstrap once the Elastic IP address is attached.
    • ec2-run-instances ami-.... then follow up with ec2-associate-addresses to the instance.

I hope that helps.

Scott

On 7/5/12 6:04 AM, Millisami wrote:
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?

!DSPAM:4ff59409196631440839711!








Archive powered by MHonArc 2.6.16.

§