ec2launcher 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,7 @@ module EC2Launcher
47
47
  # @param [Array<EC2Launcher::BlockDevice>] block_devices list of block devices to create.
48
48
  #
49
49
  def build_ebs_volumes(hostname, short_hostname, environment_name, block_devices)
50
+ return if block_devices.nil?
50
51
  base_device_name = "sdf"
51
52
  block_devices.each do |block_device|
52
53
  build_block_devices(block_device.count, base_device_name) do |device_name, index|
@@ -8,12 +8,16 @@ module EC2Launcher
8
8
  include EmailNotifications
9
9
 
10
10
  attr_reader :name
11
+ attr_reader :precommands
12
+ attr_reader :postcommands
11
13
 
12
14
  def initialize()
13
15
  @aliases = []
14
16
  @email_notifications = nil
15
17
  @gems = []
16
18
  @packages = []
19
+ @precommands = []
20
+ @postcommands = []
17
21
  end
18
22
 
19
23
  def environment(name)
@@ -119,6 +123,14 @@ module EC2Launcher
119
123
  end
120
124
  end
121
125
 
126
+ def precommand(*command)
127
+ @precommands << command[0]
128
+ end
129
+
130
+ def postcommand(*command)
131
+ @postcommands << command[0]
132
+ end
133
+
122
134
  def roles(*roles)
123
135
  if roles.empty?
124
136
  @roles
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2012 Sean Laurent
3
3
  #
4
4
  module Ec2launcher
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  end
data/lib/ec2launcher.rb CHANGED
@@ -292,7 +292,7 @@ module EC2Launcher
292
292
  'gems' => gems,
293
293
  'packages' => packages
294
294
  }
295
- unless @application.block_devices.empty?
295
+ unless @application.block_devices.nil? || @application.block_devices.empty?
296
296
  setup_json['block_devices'] = @application.block_devices
297
297
  end
298
298
  unless email_notifications.nil?
@@ -303,8 +303,16 @@ module EC2Launcher
303
303
  # Build launch command
304
304
  user_data = "#!/bin/sh
305
305
  export HOME=/root
306
- echo '#{setup_json.to_json}' > /tmp/setup.json
307
- curl http://bazaar.launchpad.net/~alestic/runurl/trunk/download/head:/runurl-20090817053347-o2e56z7xwq8m9tt6-1/runurl -o /tmp/runurl
306
+ echo '#{setup_json.to_json}' > /tmp/setup.json"
307
+
308
+ # pre-commands, if necessary
309
+ unless @environment.precommands.nil?
310
+ precommands = @environment.precommands.join("\n")
311
+ user_data += "\n" + precommands
312
+ end
313
+
314
+ # Primary setup script
315
+ user_data += "\ncurl http://bazaar.launchpad.net/~alestic/runurl/trunk/download/head:/runurl-20090817053347-o2e56z7xwq8m9tt6-1/runurl -o /tmp/runurl
308
316
  chmod +x /tmp/runurl
309
317
  /tmp/runurl https://raw.github.com/StudyBlue/ec2launcher/master/startup-scripts/setup.rb -e #{options.environ} -a #{options.application} -h #{hostname} /tmp/setup.json > /var/log/cloud-startup.log
310
318
  rm -f /tmp/runurl"
@@ -313,6 +321,12 @@ rm -f /tmp/runurl"
313
321
  # Add extra requested commands to the launch sequence
314
322
  options.commands.each {|extra_cmd| user_data += "\n#{extra_cmd}" }
315
323
 
324
+ # Post commands
325
+ unless @environment.postcommands.nil?
326
+ postcommands = @environment.postcommands.join("\n")
327
+ user_data += "\n" + postcommands
328
+ end
329
+
316
330
  ##############################
317
331
  puts
318
332
  puts "Availability zone: #{availability_zone}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: