ironfan 4.5.1 → 4.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v4.5.2:
2
+ * 'knife cluster launch --bootstrap' should ensure that Chef::Config[:environment] is set, just as 'knife cluster bootstrap' does
3
+ * Cleaning up knife commands to skip bogus servers (fixes #213)
4
+ * EXPERIMENTAL: Adding (cross-platform) ironfaned chef omnibus bootstrap
5
+
1
6
  # v4.5.1:
2
7
  * Clean up on 12.04 template - do dist-upgrade, include omnibus bin in $PATH, nicer first-boot.json
3
8
  * Removing superfluous raise on duplicate machines during load
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.5.1
1
+ 4.5.2
data/ironfan.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ironfan"
8
- s.version = "4.5.1"
8
+ s.version = "4.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
12
- s.date = "2012-11-14"
12
+ s.date = "2012-11-27"
13
13
  s.description = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
14
14
  s.email = "coders@infochimps.com"
15
15
  s.extra_rdoc_files = [
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  "config/ubuntu12.04-ironfan.erb",
39
39
  "ironfan.gemspec",
40
40
  "lib/chef/knife/bootstrap/centos6.2-ironfan.erb",
41
+ "lib/chef/knife/bootstrap/chef-full-ironfan.erb",
41
42
  "lib/chef/knife/bootstrap/ubuntu10.04-ironfan.erb",
42
43
  "lib/chef/knife/bootstrap/ubuntu12.04-ironfan.erb",
43
44
  "lib/chef/knife/cluster_bootstrap.rb",
@@ -120,6 +121,7 @@ Gem::Specification.new do |s|
120
121
  "notes/walkthrough-hadoop.md",
121
122
  "notes/walkthrough-web.md",
122
123
  "spec/chef/cluster_bootstrap_spec.rb",
124
+ "spec/chef/cluster_launch_spec.rb",
123
125
  "spec/fixtures/ec2/elb/snakeoil.crt",
124
126
  "spec/fixtures/ec2/elb/snakeoil.key",
125
127
  "spec/fixtures/gunbai.rb",
@@ -127,7 +129,6 @@ Gem::Specification.new do |s|
127
129
  "spec/integration/minimal-chef-repo/chefignore",
128
130
  "spec/integration/minimal-chef-repo/environments/_default.json",
129
131
  "spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb",
130
- "spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb",
131
132
  "spec/integration/minimal-chef-repo/knife/knife.rb",
132
133
  "spec/integration/minimal-chef-repo/roles/systemwide.rb",
133
134
  "spec/integration/spec/elb_build_spec.rb",
@@ -148,7 +149,7 @@ Gem::Specification.new do |s|
148
149
  s.require_paths = ["lib"]
149
150
  s.rubygems_version = "1.8.24"
150
151
  s.summary = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
151
- s.test_files = ["spec/spec_helper/dummy_chef.rb", "spec/integration/spec_helper/launch_cluster.rb", "spec/integration/minimal-chef-repo/roles/systemwide.rb", "spec/integration/minimal-chef-repo/environments/_default.json", "spec/integration/minimal-chef-repo/chefignore", "spec/integration/minimal-chef-repo/knife/knife.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb", "spec/integration/spec/simple_cluster_spec.rb", "spec/integration/spec/elb_build_spec.rb", "spec/integration/spec_helper.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/ec2/cloud_provider_spec.rb", "spec/ironfan/ec2/elb_spec.rb", "spec/ironfan/ec2/security_group_spec.rb", "spec/chef/cluster_bootstrap_spec.rb", "spec/fixtures/gunbai_slice.json", "spec/fixtures/ec2/elb/snakeoil.key", "spec/fixtures/ec2/elb/snakeoil.crt", "spec/fixtures/gunbai.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
152
+ s.test_files = ["spec/spec_helper/dummy_chef.rb", "spec/integration/spec_helper/launch_cluster.rb", "spec/integration/minimal-chef-repo/roles/systemwide.rb", "spec/integration/minimal-chef-repo/environments/_default.json", "spec/integration/minimal-chef-repo/chefignore", "spec/integration/minimal-chef-repo/knife/knife.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb", "spec/integration/spec/simple_cluster_spec.rb", "spec/integration/spec/elb_build_spec.rb", "spec/integration/spec_helper.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/ec2/cloud_provider_spec.rb", "spec/ironfan/ec2/elb_spec.rb", "spec/ironfan/ec2/security_group_spec.rb", "spec/chef/cluster_launch_spec.rb", "spec/chef/cluster_bootstrap_spec.rb", "spec/fixtures/gunbai_slice.json", "spec/fixtures/ec2/elb/snakeoil.key", "spec/fixtures/ec2/elb/snakeoil.crt", "spec/fixtures/gunbai.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
152
153
 
153
154
  if s.respond_to? :specification_version then
154
155
  s.specification_version = 3
@@ -0,0 +1,97 @@
1
+ bash -c '
2
+
3
+ ##
4
+ # EXPERIMENTAL
5
+ ##
6
+ # This code was submitted as an alternative to the per-distribution scripts, just after a new bootstrap
7
+ # (Ubuntu 12.04) was put into production at Infochimps; therefore, we have had no time to validate it
8
+ # internally. Please exercise caution in applying it.
9
+ #
10
+ # Submitter: Ryan Schlesinger (https://github.com/ryansch)
11
+ # Source: https://github.com/infochimps-labs/ironfan/pull/212
12
+ #
13
+
14
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
15
+
16
+ exists() {
17
+ if command -v $1 &>/dev/null
18
+ then
19
+ return 0
20
+ else
21
+ return 1
22
+ fi
23
+ }
24
+
25
+ install_sh="http://opscode.com/chef/install.sh"
26
+ version_string="-v <%= chef_version %>"
27
+
28
+ if ! exists /usr/bin/chef-client; then
29
+ if exists wget; then
30
+ bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -) ${version_string}
31
+ else
32
+ if exists curl; then
33
+ bash <(curl -L <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh}) ${version_string}
34
+ fi
35
+ fi
36
+ fi
37
+
38
+ mkdir -p /etc/chef
39
+
40
+ <%- if @config[:client_key] %>
41
+ (
42
+ cat <<'EOP'
43
+ <%= @config[:client_key] %>
44
+ EOP
45
+ ) > /tmp/client.pem
46
+ awk NF /tmp/client.pem > /etc/chef/client.pem
47
+ rm /tmp/client.pem
48
+ chmod 0600 /etc/chef/client.pem
49
+ <%- else %>
50
+ (
51
+ cat <<'EOP'
52
+ <%= validation_key %>
53
+ EOP
54
+ ) > /tmp/validation.pem
55
+ awk NF /tmp/validation.pem > /etc/chef/validation.pem
56
+ rm /tmp/validation.pem
57
+ chmod 0600 /etc/chef/validation.pem
58
+ <% end -%>
59
+
60
+ <% if @chef_config[:encrypted_data_bag_secret] -%>
61
+ (
62
+ cat <<'EOP'
63
+ <%= encrypted_data_bag_secret %>
64
+ EOP
65
+ ) > /tmp/encrypted_data_bag_secret
66
+ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
67
+ rm /tmp/encrypted_data_bag_secret
68
+ chmod 0600 /etc/chef/encrypted_data_bag_secret
69
+ <% end -%>
70
+
71
+ <%# Generate Ohai Hints -%>
72
+ <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
73
+ mkdir -p /etc/chef/ohai/hints
74
+
75
+ <% @chef_config[:knife][:hints].each do |name, hash| -%>
76
+ (
77
+ cat <<'EOP'
78
+ <%= hash.to_json %>
79
+ EOP
80
+ ) > /etc/chef/ohai/hints/<%= name %>.json
81
+ <% end -%>
82
+ <% end -%>
83
+
84
+ (
85
+ cat <<'EOP'
86
+ <%= config_content %>
87
+ <%= @config[:computer].chef_client_script_content %>
88
+ EOP
89
+ ) > /etc/chef/client.rb
90
+
91
+ (
92
+ cat <<'EOP'
93
+ <%= { "run_list" => @run_list, "cluster_name" => @config[:server].cluster_name, "facet_name" => @config[:server].facet_name, "facet_index" => @config[:server].index }.to_json %>
94
+ EOP
95
+ ) > /etc/chef/first-boot.json
96
+
97
+ <%= start_chef %>'
@@ -59,7 +59,7 @@ class Chef
59
59
  end
60
60
 
61
61
  def perform_execution(target)
62
- reconcile_chef_config(target)
62
+ ensure_common_environment(target)
63
63
  # Execute across all servers in parallel
64
64
  Ironfan.parallel(target.values) {|computer| run_bootstrap(computer)}
65
65
  # threads = target.servers.map{ |server| Thread.new(server) { |svr| run_bootstrap(svr, svr.public_hostname) } }
@@ -70,18 +70,6 @@ class Chef
70
70
  confirm_or_exit("Are you absolutely certain that you want to perform this action? (Type 'Yes' to confirm) ", 'Yes')
71
71
  end
72
72
 
73
- protected
74
-
75
- def reconcile_chef_config(target)
76
- environments = target.environments
77
- if environments.length > 1
78
- ui.error "You cannot bootstrap machines in multiple chef environments: got #{environments.inspect} from #{target.map(&:name)}"
79
- ui.error "Re-run this command on each subgroup of machines that share an environment"
80
- raise StandardError, "Cannot bootstrap multiple chef environments"
81
- end
82
- Chef::Config[:environment] = environments.first
83
- end
84
-
85
73
  end
86
74
  end
87
75
  end
@@ -71,6 +71,13 @@ class Chef
71
71
 
72
72
  die("", "#{ui.color("All computers are running -- not launching any.",:blue)}", "", 1) if target.empty?
73
73
 
74
+ # If a bootstrap was requested, ensure that we will be able to perform the
75
+ # bootstrap *before* trying to launch all of the servers in target. This
76
+ # will save the user a lot of time if they've made a configuration mistake
77
+ if config[:bootstrap]
78
+ ensure_common_environment(target)
79
+ end
80
+
74
81
  # Pre-populate information in chef
75
82
  section("Syncing to chef")
76
83
  target.save :providers => :chef
@@ -50,6 +50,7 @@ class Chef
50
50
  # config[:identity_file] ||= target.ssh_identity_file
51
51
 
52
52
  # @action_nodes = target.chef_nodes
53
+ target = target.select {|t| not t.bogus? }
53
54
  addresses = target.map {|c| c.machine.public_hostname }.compact
54
55
 
55
56
  (ui.fatal("No nodes returned from search!"); exit 10) if addresses.nil? || addresses.length == 0
@@ -41,11 +41,9 @@ class Chef
41
41
 
42
42
 
43
43
  def relevant?(computer)
44
- if config[:sync_all]
45
- not computer.bogus?
46
- else
47
- computer.created? or computer.node?
48
- end
44
+ return false if computer.bogus?
45
+ return true if config[:sync_all]
46
+ computer.created? or computer.node?
49
47
  end
50
48
 
51
49
  def perform_execution(target)
@@ -236,5 +236,18 @@ module Ironfan
236
236
  extend ClassMethods
237
237
  end
238
238
  end
239
+
240
+ protected
241
+
242
+ def ensure_common_environment(target)
243
+ environments = target.environments
244
+ if environments.length > 1
245
+ ui.error "You cannot bootstrap machines in multiple chef environments: got #{environments.inspect} from #{target.map(&:name)}"
246
+ ui.error "Re-run this command on each subgroup of machines that share an environment"
247
+ raise StandardError, "Cannot bootstrap multiple chef environments"
248
+ end
249
+ Chef::Config[:environment] = environments.first
250
+ end
251
+
239
252
  end
240
253
  end
@@ -301,7 +301,7 @@ module Ironfan
301
301
  def aggregate
302
302
  computers = self
303
303
  provider_keys = values.map {|c| c.chosen_providers({ :providers => :iaas})}.flatten.uniq
304
- providers = provider_keys.map { |pk| values.map { |c| c.providers[pk] } }.flatten.uniq
304
+ providers = provider_keys.map { |pk| values.map { |c| c.providers[pk] } }.flatten.compact.uniq
305
305
  providers.each { |p| p.aggregate! computers }
306
306
  end
307
307
 
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ ironfan_go!
4
+ require 'chef/knife/cluster_launch'
5
+
6
+ describe Chef::Knife::ClusterLaunch do
7
+ let(:cluster) do
8
+ Ironfan.load_cluster(:gunbai)
9
+ end
10
+
11
+ let(:target) do
12
+ Ironfan.broker.discover!(cluster)
13
+ end
14
+
15
+ let(:computers) do
16
+ Ironfan::Broker::Computers.receive(
17
+ MultiJson.load(
18
+ File.open(Pathname.path_to(:fixtures, 'gunbai_slice.json'))))
19
+ end
20
+
21
+ subject do
22
+ described_class.new(slice)
23
+ end
24
+
25
+ context 'getting slice' do
26
+ before do
27
+ subject.stub(:relevant?){ true }
28
+ subject.config[:yes] = true
29
+ subject.config[:bootstrap] = true
30
+ end
31
+ context 'full slice' do
32
+ let(:slice){ ['gunbai'] }
33
+ it 'fails if there are multiple environments' do
34
+ expect{ subject.run }.to raise_error("Cannot bootstrap multiple chef environments")
35
+ end
36
+ end
37
+
38
+ end
39
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 4.5.1
5
+ version: 4.5.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Infochimps
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-11-14 00:00:00 Z
13
+ date: 2012-11-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chef
@@ -164,6 +164,7 @@ files:
164
164
  - config/ubuntu12.04-ironfan.erb
165
165
  - ironfan.gemspec
166
166
  - lib/chef/knife/bootstrap/centos6.2-ironfan.erb
167
+ - lib/chef/knife/bootstrap/chef-full-ironfan.erb
167
168
  - lib/chef/knife/bootstrap/ubuntu10.04-ironfan.erb
168
169
  - lib/chef/knife/bootstrap/ubuntu12.04-ironfan.erb
169
170
  - lib/chef/knife/cluster_bootstrap.rb
@@ -246,6 +247,7 @@ files:
246
247
  - notes/walkthrough-hadoop.md
247
248
  - notes/walkthrough-web.md
248
249
  - spec/chef/cluster_bootstrap_spec.rb
250
+ - spec/chef/cluster_launch_spec.rb
249
251
  - spec/fixtures/ec2/elb/snakeoil.crt
250
252
  - spec/fixtures/ec2/elb/snakeoil.key
251
253
  - spec/fixtures/gunbai.rb
@@ -253,7 +255,6 @@ files:
253
255
  - spec/integration/minimal-chef-repo/chefignore
254
256
  - spec/integration/minimal-chef-repo/environments/_default.json
255
257
  - spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb
256
- - spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb
257
258
  - spec/integration/minimal-chef-repo/knife/knife.rb
258
259
  - spec/integration/minimal-chef-repo/roles/systemwide.rb
259
260
  - spec/integration/spec/elb_build_spec.rb
@@ -281,7 +282,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
282
  requirements:
282
283
  - - ">="
283
284
  - !ruby/object:Gem::Version
284
- hash: -4226427612594670863
285
+ hash: -2019769305702491484
285
286
  segments:
286
287
  - 0
287
288
  version: "0"
@@ -305,7 +306,6 @@ test_files:
305
306
  - spec/integration/minimal-chef-repo/environments/_default.json
306
307
  - spec/integration/minimal-chef-repo/chefignore
307
308
  - spec/integration/minimal-chef-repo/knife/knife.rb
308
- - spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb
309
309
  - spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb
310
310
  - spec/integration/spec/simple_cluster_spec.rb
311
311
  - spec/integration/spec/elb_build_spec.rb
@@ -314,6 +314,7 @@ test_files:
314
314
  - spec/ironfan/ec2/cloud_provider_spec.rb
315
315
  - spec/ironfan/ec2/elb_spec.rb
316
316
  - spec/ironfan/ec2/security_group_spec.rb
317
+ - spec/chef/cluster_launch_spec.rb
317
318
  - spec/chef/cluster_bootstrap_spec.rb
318
319
  - spec/fixtures/gunbai_slice.json
319
320
  - spec/fixtures/ec2/elb/snakeoil.key
@@ -1,9 +0,0 @@
1
- Chef::Config.instance_eval do
2
- organization "infochimps_test"
3
- chef_server_url "https://api.opscode.com/organizations/#{organization}"
4
- knife[:aws_account_id] = "346633265723"
5
-
6
- knife[:aws_access_key_id] = "AKIAIFPVHWHGTQDXOF6Q"
7
- knife[:aws_secret_access_key] = "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"
8
- end
9
-