ec2launcher 1.0.19 → 1.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/lib/ec2launcher.rb +40 -29
- data/lib/ec2launcher/dsl/config.rb +0 -32
- data/lib/ec2launcher/init_options.rb +11 -1
- data/lib/ec2launcher/version.rb +1 -1
- data/startup-scripts/setup_instance.rb +19 -5
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.0.20
|
2
|
+
|
3
|
+
* New command line option to show user-data.
|
4
|
+
* New command line option to skip the setup scripts.
|
5
|
+
* Changes to handling RAID array assembly from cloned EBS volumes. Specifically arrays created with mdadm < 3.1.2 that don't use version 1.2 superblocks.
|
6
|
+
* Fixed typo with cloning/mounting single volumes.
|
7
|
+
* Cleaned up launch output.
|
8
|
+
|
1
9
|
## 1.0.19
|
2
10
|
|
3
11
|
* Fixed typo in launch command.
|
data/lib/ec2launcher.rb
CHANGED
@@ -341,7 +341,16 @@ module EC2Launcher
|
|
341
341
|
end
|
342
342
|
|
343
343
|
# Quit if we're only displaying the defaults
|
344
|
-
|
344
|
+
if @options.show_defaults || @options.show_user_data
|
345
|
+
if @options.show_user_data
|
346
|
+
user_data = build_launch_command(fqdn_names[0], short_hostnames[0], roles, chef_validation_pem_url, aws_keyfile, gems, packages, email_notifications)
|
347
|
+
puts ""
|
348
|
+
puts "---user-data---"
|
349
|
+
puts user_data
|
350
|
+
puts "---user-data---"
|
351
|
+
end
|
352
|
+
exit 0
|
353
|
+
end
|
345
354
|
|
346
355
|
##############################
|
347
356
|
# Launch the new intance
|
@@ -362,9 +371,9 @@ module EC2Launcher
|
|
362
371
|
|
363
372
|
puts "********************"
|
364
373
|
fqdn_names.each_index do |i|
|
365
|
-
public_dns_name = instances[i].public_dns_name.nil? ? "
|
366
|
-
private_dns_name = instances[i].private_dns_name.nil? ? "
|
367
|
-
puts "
|
374
|
+
public_dns_name = instances[i].public_dns_name.nil? ? "n/a" : instances[i].public_dns_name
|
375
|
+
private_dns_name = instances[i].private_dns_name.nil? ? "n/a" : instances[i].private_dns_name
|
376
|
+
puts "** New instance: #{fqdn_names[i]} | #{instances[i].id} | #{public_dns_name} | #{private_dns_name} | #{instances[i].private_ip_address}"
|
368
377
|
end
|
369
378
|
|
370
379
|
##############################
|
@@ -808,37 +817,39 @@ module EC2Launcher
|
|
808
817
|
|
809
818
|
user_data += "\n"
|
810
819
|
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
820
|
+
unless @options.skip_setup
|
821
|
+
if @run_url_script_cache.nil?
|
822
|
+
puts "Downloading runurl script from #{RUN_URL_SCRIPT}"
|
823
|
+
@run_url_script_cache = `curl -s #{RUN_URL_SCRIPT} |gzip -f |base64`
|
824
|
+
end
|
815
825
|
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
826
|
+
if @setup_script_cache.nil?
|
827
|
+
puts "Downloading setup script from #{SETUP_SCRIPT}"
|
828
|
+
@setup_script_cache = `curl -s #{SETUP_SCRIPT} |gzip -f |base64`
|
829
|
+
end
|
820
830
|
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
831
|
+
# runurl script
|
832
|
+
user_data += "cat > /tmp/runurl.gz.base64 <<End-Of-Message\n"
|
833
|
+
user_data += @run_url_script_cache
|
834
|
+
user_data += "End-Of-Message"
|
825
835
|
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
836
|
+
# setup script
|
837
|
+
user_data += "\ncat > /tmp/setup.rb.gz.base64 <<End-Of-Message2\n"
|
838
|
+
user_data += @setup_script_cache
|
839
|
+
user_data += "End-Of-Message2"
|
830
840
|
|
831
|
-
|
832
|
-
|
833
|
-
|
841
|
+
user_data += "\nbase64 -d /tmp/runurl.gz.base64 | gunzip > /tmp/runurl"
|
842
|
+
user_data += "\nchmod +x /tmp/runurl"
|
843
|
+
# user_data += "\nrm -f /tmp/runurl.gz.base64"
|
834
844
|
|
835
|
-
|
836
|
-
|
837
|
-
|
845
|
+
user_data += "\nbase64 -d /tmp/setup.rb.gz.base64 | gunzip > /tmp/setup.rb"
|
846
|
+
user_data += "\nchmod +x /tmp/setup.rb"
|
847
|
+
# user_data += "\nrm -f /tmp/setup.rb.gz.base64"
|
838
848
|
|
839
|
-
|
840
|
-
|
841
|
-
|
849
|
+
user_data += "\n#{setup_json['ruby_path']} /tmp/setup.rb -e #{@environment.name} -a #{@application.name} -h #{fqdn} /tmp/setup.json"
|
850
|
+
user_data += " -c #{@options.clone_host}" unless @options.clone_host.nil?
|
851
|
+
user_data += " 2>&1 > /var/log/cloud-startup.log"
|
852
|
+
end
|
842
853
|
|
843
854
|
# Add extra requested commands to the launch sequence
|
844
855
|
unless @options.commands.nil?
|
@@ -78,38 +78,6 @@ end
|
|
78
78
|
@config_manager = config_manager[0]
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
82
|
-
def gem_path(*gem_path)
|
83
|
-
if gem_path.empty?
|
84
|
-
@gem_path
|
85
|
-
else
|
86
|
-
@gem_path = gem_path[0]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def ruby_path(*ruby_path)
|
91
|
-
if ruby_path.empty?
|
92
|
-
@ruby_path
|
93
|
-
else
|
94
|
-
@ruby_path = ruby_path[0]
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def chef_path(*chef_path)
|
99
|
-
if chef_path.empty?
|
100
|
-
@chef_path
|
101
|
-
else
|
102
|
-
@chef_path = chef_path[0]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def knife_path(*knife_path)
|
107
|
-
if knife_path.empty?
|
108
|
-
@knife_path
|
109
|
-
else
|
110
|
-
@knife_path = knife_path[0]
|
111
|
-
end
|
112
|
-
end
|
113
81
|
end
|
114
82
|
end
|
115
83
|
end
|
@@ -33,10 +33,14 @@ module EC2Launcher
|
|
33
33
|
@options.list = true
|
34
34
|
end
|
35
35
|
|
36
|
-
opts.on("-s", "--show-defaults", "Show settings, but do not launch any instances.") do
|
36
|
+
opts.on("-s", "--show-defaults", "Show settings, but do not launch any instances. Does not display user-data.") do
|
37
37
|
@options.show_defaults = true
|
38
38
|
end
|
39
39
|
|
40
|
+
opts.on("--show-user-data", "Show user-data, but do not launch any instances.") do
|
41
|
+
@options.show_user_data = true
|
42
|
+
end
|
43
|
+
|
40
44
|
opts.separator ""
|
41
45
|
opts.separator "Required Launch options:"
|
42
46
|
|
@@ -63,6 +67,10 @@ module EC2Launcher
|
|
63
67
|
@options.count = count
|
64
68
|
end
|
65
69
|
|
70
|
+
opts.on("--skip-setup", "Skip running the setup scripts. Still runs pre/post commands.") do
|
71
|
+
@options.skip_setup = true
|
72
|
+
end
|
73
|
+
|
66
74
|
opts.separator ""
|
67
75
|
opts.separator "Overrides:"
|
68
76
|
|
@@ -129,12 +137,14 @@ module EC2Launcher
|
|
129
137
|
@options = OpenStruct.new
|
130
138
|
@options.list = false
|
131
139
|
@options.show_defaults = false
|
140
|
+
@options.show_user_data = false
|
132
141
|
|
133
142
|
@options.environ = nil
|
134
143
|
@options.application = nil
|
135
144
|
@options.commands = []
|
136
145
|
@options.clone_host = nil
|
137
146
|
@options.count = 1
|
147
|
+
@options.skip_setup = false
|
138
148
|
|
139
149
|
@options.ami_id = nil
|
140
150
|
@options.hostname = nil
|
data/lib/ec2launcher/version.rb
CHANGED
@@ -213,11 +213,23 @@ def setup_attached_raid_array(system_arch, devices, raid_device = '/dev/md0', ra
|
|
213
213
|
# $ /sbin/mdadm --detail --scan
|
214
214
|
# mdadm: cannot open /dev/md/0_0: No such file or directory
|
215
215
|
# mdadm: cannot open /dev/md/1_0: No such file or directory
|
216
|
-
|
216
|
+
#
|
217
|
+
# This is tied to how the raid array was created, especially if the array was created with an older version of mdadm.
|
218
|
+
# See https://bugzilla.redhat.com/show_bug.cgi?id=606481 for a lengthy discussion. We should really be naming RAID
|
219
|
+
# arrays correctly and using the HOMEHOST setting to re-assemble it.
|
220
|
+
#
|
221
|
+
# As a stop-gap, try to use the specified raid_device name passed into this method.
|
222
|
+
raid_info = raid_device
|
223
|
+
|
224
|
+
# We need to manually retrieve the UUID of the array
|
225
|
+
array_uuid = `mdadm --detail #{raid_device}|grep UUID|awk '// { print $3; }'`.strip
|
226
|
+
|
227
|
+
# We have to manually update mdadm.conf as well
|
228
|
+
`echo ARRAY #{raid_device} level=raid#{raid_type.to_s} num-devices=#{devices.count.to_s} meta-data=0.90 UUID=#{array_uuid} |tee -a /etc/mdadm.conf`
|
217
229
|
else
|
218
|
-
raid_info = raid_scan_info.split("\n")[-1].split()
|
230
|
+
raid_info = raid_scan_info.split("\n")[-1].split()[1]
|
219
231
|
end
|
220
|
-
Pathname.new(raid_info
|
232
|
+
Pathname.new(raid_info).realpath.to_s
|
221
233
|
end
|
222
234
|
|
223
235
|
def build_block_devices(count, device = "xvdj", &block)
|
@@ -278,6 +290,7 @@ unless instance_data["block_devices"].nil?
|
|
278
290
|
end
|
279
291
|
puts `yum install mdadm -y` if raid_required
|
280
292
|
|
293
|
+
raid_array_count = 0
|
281
294
|
next_device_name = "xvdj"
|
282
295
|
instance_data["block_devices"].each do |block_device_json|
|
283
296
|
if block_device_json["raid_level"].nil?
|
@@ -286,7 +299,7 @@ unless instance_data["block_devices"].nil?
|
|
286
299
|
partition_devices([ "/dev/#{next_device_name}" ])
|
287
300
|
format_filesystem(system_arch, "/dev/#{next_device_name}1")
|
288
301
|
end
|
289
|
-
mount_device("
|
302
|
+
mount_device("/dev/#{next_device_name}1", block_device_json["mount_point"], block_device_json["owner"], block_device_json["group"], default_fs_type)
|
290
303
|
next_device_name.next!
|
291
304
|
else
|
292
305
|
raid_devices = []
|
@@ -294,8 +307,9 @@ unless instance_data["block_devices"].nil?
|
|
294
307
|
raid_devices << "/dev/#{device_name}"
|
295
308
|
next_device_name = device_name
|
296
309
|
end
|
297
|
-
raid_device_name = setup_attached_raid_array(system_arch, raid_devices, "/dev/
|
310
|
+
raid_device_name = setup_attached_raid_array(system_arch, raid_devices, "/dev/md#{(127 - raid_array_count).to_s}", block_device_json["raid_level"].to_i, ! options.clone_host.nil?)
|
298
311
|
mount_device(raid_device_name, block_device_json["mount_point"], block_device_json["owner"], block_device_json["group"], default_fs_type)
|
312
|
+
raid_array_count += 1
|
299
313
|
end
|
300
314
|
end
|
301
315
|
end
|
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.
|
4
|
+
version: 1.0.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|