ec2launcher 1.0.15 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.16
2
+
3
+ * Added support for custom paths to ruby, gem, chef-client and knife executables.
4
+
1
5
  ## 1.0.15
2
6
 
3
7
  * Fixed problem setting up ephemeral drives.
data/README.md CHANGED
@@ -10,3 +10,7 @@ All contributions are welcome: ideas, patches, documentation, bug reports, compl
10
10
 
11
11
  * If you think you found a bug, you probably did. Feel free to create an issue here on GitHub. Also, when filing, please make sure you're familiar with [necolas's guidelines](https://github.com/necolas/issue-guidelines). See https://github.com/StudyBlue/ec2launcher/issues to review existing issues or to create a new issue.
12
12
  * If you want to send patches, the best way is to fork this repo and send us a pull request.
13
+
14
+ # Support
15
+
16
+ [ec2launcher Google Groups](http://groups.google.com/group/ec2launcher-user)
data/lib/ec2launcher.rb CHANGED
@@ -430,6 +430,19 @@ module EC2Launcher
430
430
  dirs
431
431
  end
432
432
 
433
+ # Builds the path to an executable.
434
+ def build_path(instance_path, executable, default_path)
435
+ app_path = default_path
436
+ unless instance_path.nil?
437
+ if instance_path =~ /#{executable}$/
438
+ app_path = instance_path
439
+ else
440
+ app_path = File.join(instance_path, executable)
441
+ end
442
+ end
443
+ app_path
444
+ end
445
+
433
446
  # Searches for the most recent AMI matching the criteria.
434
447
  #
435
448
  # @param [String] arch system archicture, `i386` or `x86_64`
@@ -734,6 +747,11 @@ module EC2Launcher
734
747
  'gems' => gems,
735
748
  'packages' => packages
736
749
  }
750
+ setup_json["gem_path"] = build_path(@environment.gem_path, "gem", "/usr/bin/gem")
751
+ setup_json["ruby_path"] = build_path(@environment.ruby_path, "ruby", "/usr/bin/ruby")
752
+ setup_json["chef_path"] = build_path(@environment.chef_path, "chef-client", "/usr/bin/chef-client")
753
+ setup_json["knife_path"] = build_path(@environment.knife_path, "knife", "/usr/bin/knife")
754
+
737
755
  unless @application.block_devices.nil? || @application.block_devices.empty?
738
756
  setup_json['block_devices'] = @application.block_devices
739
757
  end
@@ -783,9 +801,9 @@ module EC2Launcher
783
801
  user_data += "\nchmod +x /tmp/setup.rb"
784
802
  # user_data += "\nrm -f /tmp/setup.rb.gz.base64"
785
803
 
786
- user_data += "\n/tmp/setup.rb -e #{@environment.name} -a #{@application.name} -h #{fqdn} /tmp/setup.json > /var/log/cloud-startup.log"
804
+ user_data += "\n#{setup_json['ruby_path']} /tmp/setup.rb -e #{@environment.name} -a #{@application.name} -h #{fqdn} /tmp/setup.json"
787
805
  user_data += " -c #{@options.clone_host}" unless @options.clone_host.nil?
788
- # user_data += "\nrm -f /tmp/runurl /tmp/setup.rb"
806
+ user_data += " 2>&1 > /var/log/cloud-startup.log"
789
807
 
790
808
  # Add extra requested commands to the launch sequence
791
809
  @options.commands.each {|extra_cmd| user_data += "\n#{extra_cmd}" }
@@ -3,7 +3,7 @@
3
3
  #
4
4
  module EC2Launcher
5
5
  module DSL
6
- class ConfigDSL
6
+ class ConfigDSL
7
7
  attr_reader :config
8
8
 
9
9
  def config(&block)
@@ -32,6 +32,11 @@ config do
32
32
  end
33
33
  }.gsub(/^ /, '')
34
34
 
35
+ def initialize()
36
+ @environments = []
37
+ @applications = []
38
+ end
39
+
35
40
  def environments(*environments)
36
41
  if environments.empty?
37
42
  @environments
@@ -73,6 +78,38 @@ end
73
78
  @config_manager = config_manager[0]
74
79
  end
75
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
76
113
  end
77
114
  end
78
115
  end
@@ -110,6 +110,38 @@ module EC2Launcher
110
110
  end
111
111
  end
112
112
 
113
+ def gem_path(*gem_path)
114
+ if gem_path.empty?
115
+ @gem_path
116
+ else
117
+ @gem_path = gem_path[0]
118
+ end
119
+ end
120
+
121
+ def ruby_path(*ruby_path)
122
+ if ruby_path.empty?
123
+ @ruby_path
124
+ else
125
+ @ruby_path = ruby_path[0]
126
+ end
127
+ end
128
+
129
+ def chef_path(*chef_path)
130
+ if chef_path.empty?
131
+ @chef_path
132
+ else
133
+ @chef_path = chef_path[0]
134
+ end
135
+ end
136
+
137
+ def knife_path(*knife_path)
138
+ if knife_path.empty?
139
+ @knife_path
140
+ else
141
+ @knife_path = knife_path[0]
142
+ end
143
+ end
144
+
113
145
  def inherit(*inherit_type)
114
146
  if inherit_type.empty?
115
147
  @inherit_type
@@ -198,11 +230,15 @@ module EC2Launcher
198
230
  @ami_name = other_env.ami_name unless other_env.ami_name.nil?
199
231
  @aws_keyfile = other_env.aws_keyfile unless other_env.aws_keyfile.nil?
200
232
  @availability_zone = other_env.availability_zone unless other_env.availability_zone.nil?
233
+ @chef_path = other_env.chef_path unless other_env.chef_path.nil?
201
234
  @chef_server_url = other_env.chef_server_url unless other_env.chef_server_url.nil?
202
235
  @chef_validation_pem_url = other_env.chef_validation_pem_url unless other_env.chef_validation_pem_url.nil?
203
236
  @domain_name = other_env.domain_name unless other_env.domain_name.nil?
204
237
  @email_notifications = other_env.email_notifications unless other_env.email_notifications.nil?
238
+ @gem_path = other_env.gem_path unless other_env.gem_path.nil?
205
239
  @key_name = other_env.key_name unless other_env.key_name.nil?
240
+ @knife_path = other_env.knife_path unless other_env.knife_path.nil?
241
+ @ruby_path = other_env.ruby_path unless other_env.ruby_path.nil?
206
242
  @subnet = other_env.subnet unless other_env.subnet.nil?
207
243
  @short_name = other_env.short_name unless other_env.short_name.nil?
208
244
  end
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2012 Sean Laurent
3
3
  #
4
4
  module EC2Launcher
5
- VERSION = "1.0.15"
5
+ VERSION = "1.0.16"
6
6
  end
@@ -82,14 +82,19 @@ setup_json_filename = ARGV[0]
82
82
  # Read the setup JSON file
83
83
  instance_data = JSON.parse(File.read(setup_json_filename))
84
84
 
85
+ # Path to executables
86
+ gem_path = instance_data["gem_path"]
87
+ ruby_path = instance_data["ruby_path"]
88
+ chef_path = instance_data["chef_path"]
89
+
85
90
  # Pre-install gems
86
91
  unless instance_data["gems"].nil?
87
- instance_data["gems"].each {|gem_name| puts `/usr/bin/gem install --no-rdoc --no-ri #{gem_name}` }
92
+ instance_data["gems"].each {|gem_name| puts `#{gem_path} install --no-rdoc --no-ri #{gem_name}` }
88
93
  end
89
94
 
90
95
  # Pre-install packages
91
96
  unless instance_data["packages"].nil?
92
- instance_data["packages"].each {|pkg_name| puts `yum install -y #{pkg_name}` }
97
+ puts `yum install #{instance_data["packages"].join(" ")} -y`
93
98
  end
94
99
 
95
100
 
@@ -143,12 +148,12 @@ File.open("/etc/chef/client.rb", 'a') { |f| f.write("node_name \"#{options.hostn
143
148
  # Setup Chef client
144
149
  puts "Connecting to Chef ..."
145
150
  `rm -f /etc/chef/client.pem`
146
- puts `chef-client`
151
+ puts `#{chef_path}`
147
152
 
148
153
  # Retrieve secondary setup script and run it
149
154
  puts "Getting role setup script ..."
150
155
  puts `s3curl.pl --id startup #{SETUP_SCRIPT_URL} > /tmp/#{SETUP_SCRIPT} && chmod +x /tmp/#{SETUP_SCRIPT}`
151
- command = "/tmp/#{SETUP_SCRIPT} -a #{options.application} -e #{options.environ} -h #{options.hostname} #{setup_json_filename}"
156
+ command = "#{ruby_path} /tmp/#{SETUP_SCRIPT} -a #{options.application} -e #{options.environ} -h #{options.hostname} #{setup_json_filename}"
152
157
  command += " -c #{options.clone_host}" unless options.clone_host.nil?
153
- command += " > /var/log/cloud-init.log"
158
+ command += " 2>&1 > /var/log/cloud-init.log"
154
159
  run_command(command)
@@ -283,6 +283,10 @@ end
283
283
  # CHEF SETUP
284
284
  ##############################
285
285
 
286
+ # Path to executables
287
+ chef_path = instance_data["chef_path"]
288
+ knife_path = instance_data["knife_path"]
289
+
286
290
  ##############################
287
291
  # Create knife configuration
288
292
  knife_config = <<EOF
@@ -306,14 +310,14 @@ end
306
310
  ##############################
307
311
  # Add roles
308
312
  instance_data["roles"].each do |role|
309
- cmd = "knife node run_list add #{options.hostname} \"role[#{role}]\""
313
+ cmd = "#{knife_path} node run_list add #{options.hostname} \"role[#{role}]\""
310
314
  puts cmd
311
315
  puts `#{cmd}`
312
316
  end
313
317
 
314
318
  ##############################
315
319
  # Launch Chef
316
- IO.popen("chef-client") do |f|
320
+ IO.popen(chef_path) do |f|
317
321
  while ! f.eof
318
322
  puts f.gets
319
323
  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.15
4
+ version: 1.0.16
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-01 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk