I'm using fog to provision servers on EC2.
I have:
EC2 = Fog::Compute.new provider: 'AWS', aws_access_key_id: AWS_ACCESS_KEY, aws_secret_access_key: AWS_SECRET_KEY s = EC2.servers.bootstrap image_id: AMI_ID, flavor_id: FLAVOR_ID, private_key_path: '~/.ssh/id_rsa', public_key_path: '~/.ssh/id_rsa.pub', tags: { Name: TAGGED_NAME }, username: ROOT_USER
when I run that in a rakefile and it hangs on s = EC2.servers.bootstrap
for a long time.
Any thoughts or pointers?
I ran into this problem also. After a couple of EC2 instance deploys I ended up getting stuck (it literally worked 1 night, and then got stuck the next morning).
My quick fix was to log into Amazon EC2, delete the keypair associated to my deployment.. IE:
EC2 = Fog::Compute.new provider: 'AWS',
region: REGION,
aws_access_key_id: AWS_ACCESS_KEY,
aws_secret_access_key: AWS_SECRET_KEY
Fog.credential = waffles
s = EC2.servers.bootstrap image_id: AMI_ID,
flavor_id: FLAVOR_ID,
private_key_path: '~/.ssh/id_rsa',
public_key_path: '~/.ssh/id_rsa.pub',
tags: { Name: TAGGED_NAME },
username: ROOT_USER
This will create a key pair called "fog_waffles b6:21:d1:3d:2b:b9:e7:48:b9:75:50:3f:03:5b:fb:85". Delete it and you should be able to move forward.
From what I can tell the keypair doesn't get updated/replaced if you create a new instance with the same keypair name. If you delete that instance, and then create a new instance using a new keypair with the same name it seems to run into problems.
More on EC2 keypairs
Addendum
The version of fog I'm using is 1.9.
If you have multiple people creating instances, you might want to go with something like this:
EC2 = Fog::Compute.new provider: 'AWS',
region: REGION,
aws_access_key_id: AWS_ACCESS_KEY,
aws_secret_access_key: AWS_SECRET_KEY
Fog.credential = waffles
s = EC2.servers.bootstrap image_id: AMI_ID,
flavor_id: FLAVOR_ID,
private_key_path: '~/.ssh/id_rsa',
public_key_path: '~/.ssh/id_rsa.pub',
tags: { Name: TAGGED_NAME },
username: ROOT_USER
EC2.delete_key_pair("fog_waffles")
This will make sure that the key pair never runs into a conflict. It's OK to delete it since it's only needed for the deployment of the instance. Fog drops your public key into authorized_keys once the instance is deployed, which allows you to access the instance.
Another option would be to change Fog.credential to be unique for each user (instead of deleting it). IE:
Fog.credential = waffles_ryan