Permalink
Browse files

[20284247] Added support for user-data

  • Loading branch information...
Petter Remen
Petter Remen committed Oct 28, 2011
1 parent 26b0d6b commit b17e3edcb21f7da541ffdb5a27a1c40dc9060688
Showing with 32 additions and 1 deletion.
  1. +27 −0 README.mdown
  2. +5 −1 lib/awsborn/server.rb
View
@@ -184,6 +184,33 @@ which does the following:
The `key_pair` is a temporary key pair that is used only for launching this cluster.
In case of a failed launch, the private key is available as `/tmp/temp_key_*`.
+### Supplying user-data
+
+Instances can be supplied user-data at launch, which can be used to integrate
+with e.g. cloud-init or similar. See http://docs.amazonwebservices.com/AWSEC2/2007-03-01/DeveloperGuide/AESDG-chapter-instancedata.html
+
+In Awsborn, you can supply user-data by defining a user_data instance method on the
+Server class which must return a string.
+
+ class LogServer < Awsborn::Server
+ instance_type :m1_small
+ image_id 'ami-2fc2e95b', :sudo_user => 'ubuntu'
+ security_group 'Basic web'
+ keys '../keys/*'
+ bootstrap_script 'chef-bootstrap.sh'
+ monitor true
+
+ cluster do
+ domain 'releware.net'
+ server :log_a, :zone => :eu_west_1a, :disk => {:sdf => "vol-a857b8c1"}, :ip => 'log-a'
+ server :log_b, :zone => :eu_west_1b, :disk => {:sdf => "vol-aa57b8c3"}, :ip => 'log-b'
+ end
+
+ def user_data
+ "hostname=#{name}"
+ end
+ end
+
## A bootstrapping script
This is what we use with the AMI above:
View
@@ -126,7 +126,8 @@ def launch_instance (key_pair)
:availability_zone => symbol_to_aws_zone(zone),
:key_name => key_pair.name,
:group_ids => security_group,
- :monitoring_enabled => monitor
+ :monitoring_enabled => monitor,
+ :user_data => user_data
)
logger.debug @launch_response
@@ -315,6 +316,9 @@ def cluster_name
def full_name
"#{self.class.name}/#{cluster_name}/#{name}"
end
+ def user_data
+ '' # Likely overridden in subclass
+ end
end
def logger

0 comments on commit b17e3ed

Please sign in to comment.