EC2 hostnames and tags.yml ERB

14 views
Skip to first unread message

Dave

unread,
Feb 11, 2010, 2:29:43 PM2/11/10
to AutomateIt
I'm trying to use AutomateIT with my EC2 environment. I'm running
into issues with the requirement for hostnames in the tags.yml. Since
I spin up instances in the cloud via the autoscaler, I don't and won't
know the hostnames. Hostnames don't mean much to me as my instances
might only live for a few hours when capacity is needed.

Here's my idea of how to solve this:

1. New EC2 instance is created
2. Host is renamed to "`hostname-s`-web" or "`hostname-s`-app" via a
script in user-data (EC2 feature)
3. AutomateIT runs and matches /^.*-web/ or /^.*-app/ in the tags.yml,
assigning the correct role

I see that I can use ERB statements within the tags.yml, but even a
simple test failed:

webserver:
<%= puts " - localhost" %>

Upon running pp tags.sort, webserver was not in the list.

Any ideas?

Thanks

Claus Divossen

unread,
Feb 12, 2010, 2:56:37 PM2/12/10
to autom...@googlegroups.com
Hello Dave,

Try:

<% hostname=`hostname`.chomp %>
webserver:
<% if hostname =~ /^.*-web$/ %>
- <%= hostname %>
<% end %>

Best Regards,
Claus

Reply all
Reply to author
Forward
0 new messages