forward3d/cap-ec2 — pull request #29 by eightbitraptor (2014-08-11 09:35:07+00:00)
Title: Provide access to EC2 server tags in Capistrano recipes

Cleaned up and resubmitted based on https://github.com/forward3d/cap-ec2/pull/28

---

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.