forward3d / cap-ec2

Capify-EC2 rewritten for Capistrano v3
MIT License
181 stars 118 forks source link

Provide access to EC2 server tags in Capistrano recipes #28

Closed eightbitraptor closed 10 years ago

eightbitraptor commented 10 years ago

I needed a way of being able to access values for custom tags that were set across machines from within a Capistrano recipe.

It allows you to write something like this

task :run_arbitrary_command do
  on roles(:web) do |server|
    execute :script, server.ec2_tags['tag_name']
  end
end

It does this by storing a reference to the AWS Instance ID when the Capistrano server object is created inside the ec2_role method.

We can use this id later to rebuild the original AWS::EC2::Instance object referring to that server so we can query it for it's tags, which is done by adding a method to the Capistrano Server class so that instances can fetch their own EC2 tags.

eightbitraptor commented 10 years ago

Closing this for now as I'm messed up the branch. Will clean up and re-open.

andytinycat commented 10 years ago

This seems totally reasonable - if you submit another PR I'll merge it.

eightbitraptor commented 10 years ago

thanks. Resubmitted as https://github.com/forward3d/cap-ec2/pull/29