ironfan 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +51 -0
  2. data/.rspec +3 -0
  3. data/CHANGELOG.md +130 -0
  4. data/Gemfile +26 -0
  5. data/LICENSE.md +201 -0
  6. data/README.md +328 -0
  7. data/Rakefile +104 -0
  8. data/TODO.md +16 -0
  9. data/VERSION +1 -0
  10. data/chefignore +41 -0
  11. data/cluster_chef-knife.gemspec +123 -0
  12. data/cluster_chef.gemspec +111 -0
  13. data/config/client.rb +59 -0
  14. data/config/proxy.pac +12 -0
  15. data/config/ubuntu10.04-ironfan.erb +157 -0
  16. data/config/ubuntu11.10-ironfan.erb +145 -0
  17. data/ironfan.gemspec +121 -0
  18. data/lib/chef/knife/bootstrap/ubuntu10.04-ironfan.erb +157 -0
  19. data/lib/chef/knife/bootstrap/ubuntu11.10-ironfan.erb +145 -0
  20. data/lib/chef/knife/cluster_bootstrap.rb +74 -0
  21. data/lib/chef/knife/cluster_kick.rb +94 -0
  22. data/lib/chef/knife/cluster_kill.rb +73 -0
  23. data/lib/chef/knife/cluster_launch.rb +164 -0
  24. data/lib/chef/knife/cluster_list.rb +50 -0
  25. data/lib/chef/knife/cluster_proxy.rb +126 -0
  26. data/lib/chef/knife/cluster_show.rb +61 -0
  27. data/lib/chef/knife/cluster_ssh.rb +141 -0
  28. data/lib/chef/knife/cluster_start.rb +40 -0
  29. data/lib/chef/knife/cluster_stop.rb +43 -0
  30. data/lib/chef/knife/cluster_sync.rb +77 -0
  31. data/lib/chef/knife/generic_command.rb +66 -0
  32. data/lib/chef/knife/knife_common.rb +195 -0
  33. data/lib/ironfan.rb +143 -0
  34. data/lib/ironfan/chef_layer.rb +299 -0
  35. data/lib/ironfan/cloud.rb +412 -0
  36. data/lib/ironfan/cluster.rb +118 -0
  37. data/lib/ironfan/compute.rb +153 -0
  38. data/lib/ironfan/deprecated.rb +33 -0
  39. data/lib/ironfan/discovery.rb +177 -0
  40. data/lib/ironfan/dsl_object.rb +124 -0
  41. data/lib/ironfan/facet.rb +144 -0
  42. data/lib/ironfan/fog_layer.rb +150 -0
  43. data/lib/ironfan/private_key.rb +130 -0
  44. data/lib/ironfan/role_implications.rb +58 -0
  45. data/lib/ironfan/security_group.rb +119 -0
  46. data/lib/ironfan/server.rb +281 -0
  47. data/lib/ironfan/server_slice.rb +260 -0
  48. data/lib/ironfan/volume.rb +157 -0
  49. data/spec/ironfan/cluster_spec.rb +13 -0
  50. data/spec/ironfan/facet_spec.rb +69 -0
  51. data/spec/ironfan/server_slice_spec.rb +19 -0
  52. data/spec/ironfan/server_spec.rb +112 -0
  53. data/spec/ironfan_spec.rb +193 -0
  54. data/spec/spec_helper.rb +50 -0
  55. data/spec/spec_helper/dummy_chef.rb +25 -0
  56. data/spec/test_config.rb +20 -0
  57. data/tasks/chef_config.rake +38 -0
  58. data/tasks/jeweler_use_alt_branch.rake +53 -0
  59. metadata +217 -0
data/config/proxy.pac ADDED
@@ -0,0 +1,12 @@
1
+ function FindProxyForURL(url, host) {
2
+ if ((shExpMatch(host, "*ec2*.amazonaws.com" )) ||
3
+ (shExpMatch(host, "*ec2.internal*" )) ||
4
+ (shExpMatch(host, "*compute-*.amazonaws.com" )) ||
5
+ (shExpMatch(host, "*compute-*.internal*" )) ||
6
+ (shExpMatch(host, "*domu*.internal*" )) ||
7
+ (shExpMatch(host, "10.*" ))
8
+ ) {
9
+ return "SOCKS5 localhost:6666";
10
+ }
11
+ return "DIRECT";
12
+ }
@@ -0,0 +1,157 @@
1
+ bash <<EOF || echo "Chef bootstrap failed!"
2
+
3
+ # This is the ubuntu natty bootstrap script from infochimps' ironfan. It is
4
+ # based on opscode's bootstrap script, with the following important differences:
5
+ #
6
+ # * installs ruby 1.9.2 (not 1.8.7) from source
7
+ # * upgrades rubygems rather than installing from source
8
+ # * pushes the node identity into the first-boot.json
9
+ # * installs the chef-client service and kicks off the first run of chef
10
+
11
+ set -e
12
+
13
+ <%= (@config[:verbosity].to_i > 1 ? 'set -v' : '') %>
14
+
15
+ RUBY_VERSION=1.9.2-p290
16
+ CHEF_VERSION=<%= bootstrap_version_string.gsub(/.*[\s=]/,"") %>
17
+
18
+ mkdir -p /tmp/knife-bootstrap
19
+ chmod 700 /tmp/knife-bootstrap
20
+ cd /tmp/knife-bootstrap
21
+
22
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
23
+ eval `cat /etc/lsb-release `
24
+ export DEBIAN_FRONTEND=noninteractive
25
+
26
+ date > /etc/box_build_time
27
+
28
+ echo -e "`date` \n\n**** \n**** apt update:\n****\n"
29
+ apt-get -y update
30
+ apt-get -y upgrade
31
+
32
+ echo -e "`date` \n\n**** \n**** Installing base packages:\n****\n"
33
+ apt-get -y install build-essential make wget curl runit zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libxml2-dev libxslt-dev libyaml-dev libreadline6 libreadline6-dev
34
+ apt-get -y install runit-services
35
+ apt-get clean
36
+
37
+ if [ ! -f /usr/bin/chef-client ]; then
38
+ echo -e "`date` \n\n**** \n**** Installing ruby version ${RUBY_VERSION}:\n****\n"
39
+
40
+ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-${RUBY_VERSION}.tar.gz
41
+ tar xzf ruby-${RUBY_VERSION}.tar.gz
42
+ cd ruby-${RUBY_VERSION}
43
+ ./configure --with-ruby-version=${RUBY_VERSION} --prefix=/usr --program-suffix=${RUBY_VERSION}
44
+ make -j2
45
+ make install
46
+
47
+ sudo update-alternatives --remove-all gem && true
48
+ update-alternatives \
49
+ --install /usr/bin/ruby ruby /usr/bin/ruby${RUBY_VERSION} 400 \
50
+ --slave /usr/bin/ri ri /usr/bin/ri${RUBY_VERSION} \
51
+ --slave /usr/bin/irb irb /usr/bin/irb${RUBY_VERSION} \
52
+ --slave /usr/bin/erb erb /usr/bin/erb${RUBY_VERSION} \
53
+ --slave /usr/bin/gem gem /usr/bin/gem${RUBY_VERSION} \
54
+ --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
55
+ /usr/share/man/man1/ruby${RUBY_VERSION}.1
56
+
57
+ if ruby -e "exit(%x{gem --version} < \"1.6.2\" ? 0 : -1 )" ; then
58
+ echo -e "`date` \n\n**** \n**** Updating rubygems:\n****\n"
59
+ # screw you Debian
60
+ REALLY_GEM_UPDATE_SYSTEM=1 gem update --system
61
+ # screw you rubygems
62
+ for foo in /usr/lib/ruby/site_ruby/*/rubygems/deprecate.rb ; do
63
+ # Don't have to be any such deprecations, in which case $foo won't exist
64
+ [ -f "$foo" ] && sudo sed -i.bak 's!@skip ||= false!true!' "$foo"
65
+ done
66
+ fi
67
+
68
+ echo -e "`date` \n\n**** \n**** Installing chef:\n****\n"
69
+ gem install ohai --no-rdoc --no-ri
70
+ gem install chef --no-rdoc --no-ri <%= bootstrap_version_string %>
71
+ # gems needed for the client.rb or so generically useful you want them at hand
72
+ gem install --no-rdoc --no-ri extlib bundler json right_aws pry
73
+
74
+ else # no chef-client
75
+ echo -e "`date` \n\n**** \n**** Chef is present -- skipping apt/ruby/chef installation\n****\n"
76
+ fi # end ruby+chef install
77
+
78
+ # fix a bug in chef that prevents debugging template errors
79
+ # will not work with --prerelease but that's OK hopefully opscode patches this crap soon
80
+ bad_template_file="/usr/lib/ruby/gems/${RUBY_VERSION}/gems/chef-${CHEF_VERSION}/lib/chef/mixin/template.rb"
81
+ if echo "0505c482b8b0b333ac71bbc8a1795d19 $bad_template_file" | md5sum -c - 2>/dev/null ; then
82
+ curl https://github.com/mrflip/chef/commit/655a1967253a8759afb54f30b818bbcb7c309198.patch | sudo patch $bad_template_file
83
+ fi
84
+
85
+ echo -e "`date` \n\n**** \n**** Knifing in the chef client config files:\n****\n"
86
+ mkdir -p /etc/chef
87
+
88
+ <%- if @config[:client_key] %>
89
+ (
90
+ cat <<'EOP'
91
+ <%= @config[:client_key] %>
92
+ EOP
93
+ ) > /tmp/knife-bootstrap/client.pem
94
+ awk NF /tmp/knife-bootstrap/client.pem > /etc/chef/client.pem
95
+ <%- else %>
96
+ (
97
+ cat <<'EOP'
98
+ <%= validation_key %>
99
+ EOP
100
+ ) > /tmp/knife-bootstrap/validation.pem
101
+ awk NF /tmp/knife-bootstrap/validation.pem > /etc/chef/validation.pem
102
+ <%- end %>
103
+
104
+ echo -e "`date` \n\n**** \n**** Nuking our temp files:\n****\n"
105
+
106
+ cd /tmp
107
+ rm -rf /tmp/knife-bootstrap
108
+
109
+ echo -e "`date` \n\n**** \n**** Creating chef client script:\n****\n"
110
+
111
+ (
112
+ cat <<'EOP'
113
+ <%= config_content %>
114
+ <%= @config[:node].chef_client_script_content %>
115
+ EOP
116
+ ) > /etc/chef/client.rb
117
+
118
+ (
119
+ cat <<'EOP'
120
+ <%= { "run_list" => @run_list, "cluster_name" => @config[:node].cluster_name, "facet_name" => @config[:node].facet_name, "facet_index" => @config[:node].facet_index }.to_json %>
121
+ EOP
122
+ ) > /etc/chef/first-boot.json
123
+
124
+ echo -e "`date` \n\n**** \n**** Adding chef client runit scripts:\n****\n"
125
+ ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
126
+ mkdir -p /var/log/chef /var/chef /etc/service /etc/sv/chef-client/{log/main,supervise}
127
+ cat > /etc/sv/chef-client/log/run <<EOP
128
+ #!/bin/bash
129
+ exec svlogd -tt ./main
130
+ EOP
131
+ cat > /etc/sv/chef-client/run <<EOP
132
+ #!/bin/bash
133
+ exec 2>&1
134
+ exec /usr/bin/env chef-client -i 43200 -s 20 -L /var/log/chef/client.log
135
+ EOP
136
+ chmod +x /etc/sv/chef-client/log/run /etc/sv/chef-client/run
137
+ ln -nfs /usr/bin/sv /etc/init.d/chef-client
138
+
139
+ service chef-client stop >/dev/null 2>&1 || true
140
+
141
+ <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
142
+ echo -e "`date` \n\n**** \n**** First run of chef:\n****\n"
143
+ set -e
144
+ <%= start_chef %>
145
+ set +e
146
+ <%- end %>
147
+
148
+ echo -e "`date` \n\n**** \n**** Cleanup:\n****\n"
149
+ # make locate work good
150
+ updatedb
151
+
152
+ echo -e "`date` \n\n**** \n**** Enabling chef client service:\n****\n"
153
+ ln -nfs /etc/sv/chef-client /etc/service/chef-client
154
+ service chef-client start
155
+
156
+ echo -e "`date` \n\n**** \n**** Cluster Chef client bootstrap complete\n****\n"
157
+ EOF
@@ -0,0 +1,145 @@
1
+ bash <<EOF || echo "Chef bootstrap failed!"
2
+
3
+ # This is the ubuntu oneiric bootstrap script from infochimps' ironfan. It is
4
+ # based on the opscode bootstrap script, with the important differences being it:
5
+ #
6
+ # * installs ruby 1.9.2 (not 1.8.7) using the system ruby
7
+ # * upgrades rubygems rather than installing from source
8
+ # * pushes the node identity into the first-boot.json
9
+ # * installs the chef-client service and kicks off the first run of chef
10
+
11
+ set -e
12
+
13
+ <%= (@config[:verbosity].to_i > 1 ? 'set -v' : '') %>
14
+
15
+ RUBY_VERSION=1.9.1
16
+ CHEF_VERSION=<%= bootstrap_version_string.gsub(/.*[\s=]/,"") %>
17
+
18
+ mkdir -p /tmp/knife-bootstrap
19
+ chmod 700 /tmp/knife-bootstrap
20
+ cd /tmp/knife-bootstrap
21
+
22
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
23
+ eval `cat /etc/lsb-release `
24
+ export DEBIAN_FRONTEND=noninteractive
25
+
26
+ date > /etc/box_build_time
27
+
28
+ # source for sun java if you want to install it later
29
+ apt-get install -y python-software-properties
30
+ add-apt-repository -y ppa:ferramroberto/java
31
+
32
+ echo -e "`date` \n\n**** \n**** apt update:\n****\n"
33
+ apt-get -y update
34
+ apt-get -y upgrade
35
+
36
+ echo -e "`date` \n\n**** \n**** Installing base packages:\n****\n"
37
+ apt-get -y install build-essential make wget curl runit zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libxml2-dev libxslt-dev libyaml-dev libreadline6 libreadline6-dev
38
+ apt-get clean
39
+
40
+ if [ ! -f /usr/bin/chef-client ]; then
41
+ echo -e "`date` \n\n**** \n**** Installing ruby version ${RUBY_VERSION}:\n****\n"
42
+
43
+ apt-get install -y ruby1.9.1 ruby1.9.1-dev
44
+
45
+ if ruby -e "exit(%x{gem --version} < \"1.6.2\" ? 0 : -1 )" ; then
46
+ echo -e "`date` \n\n**** \n**** Updating rubygems:\n****\n"
47
+ # screw you Debian
48
+ REALLY_GEM_UPDATE_SYSTEM=1 gem update --system
49
+ # screw you rubygems
50
+ for foo in /usr/lib/ruby/site_ruby/*/rubygems/deprecate.rb ; do
51
+ # Don't have to be any such deprecations, in which case $foo won't exist
52
+ [ -f "$foo" ] && sudo sed -i.bak 's!@skip ||= false!true!' "$foo"
53
+ done
54
+ fi
55
+
56
+ echo -e "`date` \n\n**** \n**** Installing chef:\n****\n"
57
+ gem install ohai --no-rdoc --no-ri
58
+ gem install chef --no-rdoc --no-ri <%= bootstrap_version_string %>
59
+ # gems needed for the client.rb or so generically useful you want them at hand
60
+ gem install --no-rdoc --no-ri extlib bundler json right_aws pry
61
+
62
+ else # no chef-client
63
+ echo -e "`date` \n\n**** \n**** Chef is present -- skipping apt/ruby/chef installation\n****\n"
64
+ fi # end ruby+chef install
65
+
66
+ # fix a bug in chef that prevents debugging template errors
67
+ # will not work with --prerelease but that's OK hopefully opscode patches this crap soon
68
+ bad_template_file="/usr/lib/ruby/gems/${RUBY_VERSION}/gems/chef-${CHEF_VERSION}/lib/chef/mixin/template.rb"
69
+ if echo "0505c482b8b0b333ac71bbc8a1795d19 $bad_template_file" | md5sum -c - 2>/dev/null ; then
70
+ curl https://github.com/mrflip/chef/commit/655a1967253a8759afb54f30b818bbcb7c309198.patch | sudo patch $bad_template_file
71
+ fi
72
+
73
+ echo -e "`date` \n\n**** \n**** Knifing in the chef client config files:\n****\n"
74
+ mkdir -p /etc/chef
75
+
76
+ <%- if @config[:client_key] %>
77
+ (
78
+ cat <<'EOP'
79
+ <%= @config[:client_key] %>
80
+ EOP
81
+ ) > /tmp/knife-bootstrap/client.pem
82
+ awk NF /tmp/knife-bootstrap/client.pem > /etc/chef/client.pem
83
+ <%- else %>
84
+ (
85
+ cat <<'EOP'
86
+ <%= validation_key %>
87
+ EOP
88
+ ) > /tmp/knife-bootstrap/validation.pem
89
+ awk NF /tmp/knife-bootstrap/validation.pem > /etc/chef/validation.pem
90
+ <%- end %>
91
+
92
+ echo -e "`date` \n\n**** \n**** Nuking our temp files:\n****\n"
93
+
94
+ cd /tmp
95
+ rm -rf /tmp/knife-bootstrap
96
+
97
+ echo -e "`date` \n\n**** \n**** Creating chef client script:\n****\n"
98
+
99
+ (
100
+ cat <<'EOP'
101
+ <%= config_content %>
102
+ <%= @config[:node].chef_client_script_content %>
103
+ EOP
104
+ ) > /etc/chef/client.rb
105
+
106
+ (
107
+ cat <<'EOP'
108
+ <%= { "run_list" => @run_list, "cluster_name" => @config[:node].cluster_name, "facet_name" => @config[:node].facet_name, "facet_index" => @config[:node].facet_index }.to_json %>
109
+ EOP
110
+ ) > /etc/chef/first-boot.json
111
+
112
+ echo -e "`date` \n\n**** \n**** Adding chef client runit scripts:\n****\n"
113
+ ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
114
+ mkdir -p /var/log/chef /var/chef /etc/service /etc/sv/chef-client/{log/main,supervise}
115
+ cat > /etc/sv/chef-client/log/run <<EOP
116
+ #!/bin/bash
117
+ exec svlogd -tt ./main
118
+ EOP
119
+ cat > /etc/sv/chef-client/run <<EOP
120
+ #!/bin/bash
121
+ exec 2>&1
122
+ exec /usr/bin/env chef-client -i 43200 -s 20 -L /var/log/chef/client.log
123
+ EOP
124
+ chmod +x /etc/sv/chef-client/log/run /etc/sv/chef-client/run
125
+ ln -nfs /usr/bin/sv /etc/init.d/chef-client
126
+
127
+ service chef-client stop >/dev/null 2>&1 || true
128
+
129
+ <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
130
+ echo -e "`date` \n\n**** \n**** First run of chef:\n****\n"
131
+ set -e
132
+ <%= start_chef %>
133
+ set +e
134
+ <%- end %>
135
+
136
+ echo -e "`date` \n\n**** \n**** Cleanup:\n****\n"
137
+ # make locate work good
138
+ updatedb
139
+
140
+ echo -e "`date` \n\n**** \n**** Enabling chef client service:\n****\n"
141
+ ln -nfs /etc/sv/chef-client /etc/service/chef-client
142
+ service chef-client start
143
+
144
+ echo -e "`date` \n\n**** \n**** Cluster Chef client bootstrap complete\n****\n"
145
+ EOF
data/ironfan.gemspec ADDED
@@ -0,0 +1,121 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ironfan"
8
+ s.version = "3.1.0.rc1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Infochimps"]
12
+ s.date = "2012-02-18"
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
+ s.email = "coders@infochimps.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.md",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ ".rspec",
22
+ "CHANGELOG.md",
23
+ "Gemfile",
24
+ "LICENSE.md",
25
+ "README.md",
26
+ "Rakefile",
27
+ "TODO.md",
28
+ "VERSION",
29
+ "chefignore",
30
+ "cluster_chef-knife.gemspec",
31
+ "cluster_chef.gemspec",
32
+ "config/client.rb",
33
+ "config/proxy.pac",
34
+ "config/ubuntu10.04-ironfan.erb",
35
+ "config/ubuntu11.10-ironfan.erb",
36
+ "ironfan.gemspec",
37
+ "lib/chef/knife/bootstrap/ubuntu10.04-ironfan.erb",
38
+ "lib/chef/knife/bootstrap/ubuntu11.10-ironfan.erb",
39
+ "lib/chef/knife/cluster_bootstrap.rb",
40
+ "lib/chef/knife/cluster_kick.rb",
41
+ "lib/chef/knife/cluster_kill.rb",
42
+ "lib/chef/knife/cluster_launch.rb",
43
+ "lib/chef/knife/cluster_list.rb",
44
+ "lib/chef/knife/cluster_proxy.rb",
45
+ "lib/chef/knife/cluster_show.rb",
46
+ "lib/chef/knife/cluster_ssh.rb",
47
+ "lib/chef/knife/cluster_start.rb",
48
+ "lib/chef/knife/cluster_stop.rb",
49
+ "lib/chef/knife/cluster_sync.rb",
50
+ "lib/chef/knife/generic_command.rb",
51
+ "lib/chef/knife/knife_common.rb",
52
+ "lib/ironfan.rb",
53
+ "lib/ironfan/chef_layer.rb",
54
+ "lib/ironfan/cloud.rb",
55
+ "lib/ironfan/cluster.rb",
56
+ "lib/ironfan/compute.rb",
57
+ "lib/ironfan/deprecated.rb",
58
+ "lib/ironfan/discovery.rb",
59
+ "lib/ironfan/dsl_object.rb",
60
+ "lib/ironfan/facet.rb",
61
+ "lib/ironfan/fog_layer.rb",
62
+ "lib/ironfan/private_key.rb",
63
+ "lib/ironfan/role_implications.rb",
64
+ "lib/ironfan/security_group.rb",
65
+ "lib/ironfan/server.rb",
66
+ "lib/ironfan/server_slice.rb",
67
+ "lib/ironfan/volume.rb",
68
+ "spec/ironfan/cluster_spec.rb",
69
+ "spec/ironfan/facet_spec.rb",
70
+ "spec/ironfan/server_slice_spec.rb",
71
+ "spec/ironfan/server_spec.rb",
72
+ "spec/ironfan_spec.rb",
73
+ "spec/spec_helper.rb",
74
+ "spec/spec_helper/dummy_chef.rb",
75
+ "spec/test_config.rb",
76
+ "tasks/chef_config.rake",
77
+ "tasks/jeweler_use_alt_branch.rake"
78
+ ]
79
+ s.homepage = "http://infochimps.com/labs"
80
+ s.licenses = ["apachev2"]
81
+ s.require_paths = ["lib"]
82
+ s.rubygems_version = "1.8.15"
83
+ 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."
84
+ s.test_files = ["spec/ironfan/cluster_spec.rb", "spec/ironfan/facet_spec.rb", "spec/ironfan/server_slice_spec.rb", "spec/ironfan/server_spec.rb", "spec/ironfan_spec.rb", "spec/spec_helper/dummy_chef.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
85
+
86
+ if s.respond_to? :specification_version then
87
+ s.specification_version = 3
88
+
89
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
90
+ s.add_runtime_dependency(%q<chef>, ["~> 0.10.4"])
91
+ s.add_runtime_dependency(%q<fog>, ["~> 1.1.1"])
92
+ s.add_runtime_dependency(%q<formatador>, ["~> 0.2.1"])
93
+ s.add_runtime_dependency(%q<gorillib>, ["~> 0.1.7"])
94
+ s.add_development_dependency(%q<bundler>, ["~> 1"])
95
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
96
+ s.add_development_dependency(%q<rspec>, ["~> 2.5"])
97
+ s.add_development_dependency(%q<yard>, ["~> 0.6"])
98
+ s.add_development_dependency(%q<configliere>, ["~> 0.4.8"])
99
+ else
100
+ s.add_dependency(%q<chef>, ["~> 0.10.4"])
101
+ s.add_dependency(%q<fog>, ["~> 1.1.1"])
102
+ s.add_dependency(%q<formatador>, ["~> 0.2.1"])
103
+ s.add_dependency(%q<gorillib>, ["~> 0.1.7"])
104
+ s.add_dependency(%q<bundler>, ["~> 1"])
105
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
106
+ s.add_dependency(%q<rspec>, ["~> 2.5"])
107
+ s.add_dependency(%q<yard>, ["~> 0.6"])
108
+ s.add_dependency(%q<configliere>, ["~> 0.4.8"])
109
+ end
110
+ else
111
+ s.add_dependency(%q<chef>, ["~> 0.10.4"])
112
+ s.add_dependency(%q<fog>, ["~> 1.1.1"])
113
+ s.add_dependency(%q<formatador>, ["~> 0.2.1"])
114
+ s.add_dependency(%q<gorillib>, ["~> 0.1.7"])
115
+ s.add_dependency(%q<bundler>, ["~> 1"])
116
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
117
+ s.add_dependency(%q<rspec>, ["~> 2.5"])
118
+ s.add_dependency(%q<yard>, ["~> 0.6"])
119
+ s.add_dependency(%q<configliere>, ["~> 0.4.8"])
120
+ end
121
+ end
@@ -0,0 +1,157 @@
1
+ bash <<EOF || echo "Chef bootstrap failed!"
2
+
3
+ # This is the ubuntu natty bootstrap script from infochimps' ironfan. It is
4
+ # based on opscode's bootstrap script, with the following important differences:
5
+ #
6
+ # * installs ruby 1.9.2 (not 1.8.7) from source
7
+ # * upgrades rubygems rather than installing from source
8
+ # * pushes the node identity into the first-boot.json
9
+ # * installs the chef-client service and kicks off the first run of chef
10
+
11
+ set -e
12
+
13
+ <%= (@config[:verbosity].to_i > 1 ? 'set -v' : '') %>
14
+
15
+ RUBY_VERSION=1.9.2-p290
16
+ CHEF_VERSION=<%= bootstrap_version_string.gsub(/.*[\s=]/,"") %>
17
+
18
+ mkdir -p /tmp/knife-bootstrap
19
+ chmod 700 /tmp/knife-bootstrap
20
+ cd /tmp/knife-bootstrap
21
+
22
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
23
+ eval `cat /etc/lsb-release `
24
+ export DEBIAN_FRONTEND=noninteractive
25
+
26
+ date > /etc/box_build_time
27
+
28
+ echo -e "`date` \n\n**** \n**** apt update:\n****\n"
29
+ apt-get -y update
30
+ apt-get -y upgrade
31
+
32
+ echo -e "`date` \n\n**** \n**** Installing base packages:\n****\n"
33
+ apt-get -y install build-essential make wget curl runit zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libxml2-dev libxslt-dev libyaml-dev libreadline6 libreadline6-dev
34
+ apt-get -y install runit-services
35
+ apt-get clean
36
+
37
+ if [ ! -f /usr/bin/chef-client ]; then
38
+ echo -e "`date` \n\n**** \n**** Installing ruby version ${RUBY_VERSION}:\n****\n"
39
+
40
+ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-${RUBY_VERSION}.tar.gz
41
+ tar xzf ruby-${RUBY_VERSION}.tar.gz
42
+ cd ruby-${RUBY_VERSION}
43
+ ./configure --with-ruby-version=${RUBY_VERSION} --prefix=/usr --program-suffix=${RUBY_VERSION}
44
+ make -j2
45
+ make install
46
+
47
+ sudo update-alternatives --remove-all gem && true
48
+ update-alternatives \
49
+ --install /usr/bin/ruby ruby /usr/bin/ruby${RUBY_VERSION} 400 \
50
+ --slave /usr/bin/ri ri /usr/bin/ri${RUBY_VERSION} \
51
+ --slave /usr/bin/irb irb /usr/bin/irb${RUBY_VERSION} \
52
+ --slave /usr/bin/erb erb /usr/bin/erb${RUBY_VERSION} \
53
+ --slave /usr/bin/gem gem /usr/bin/gem${RUBY_VERSION} \
54
+ --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
55
+ /usr/share/man/man1/ruby${RUBY_VERSION}.1
56
+
57
+ if ruby -e "exit(%x{gem --version} < \"1.6.2\" ? 0 : -1 )" ; then
58
+ echo -e "`date` \n\n**** \n**** Updating rubygems:\n****\n"
59
+ # screw you Debian
60
+ REALLY_GEM_UPDATE_SYSTEM=1 gem update --system
61
+ # screw you rubygems
62
+ for foo in /usr/lib/ruby/site_ruby/*/rubygems/deprecate.rb ; do
63
+ # Don't have to be any such deprecations, in which case $foo won't exist
64
+ [ -f "$foo" ] && sudo sed -i.bak 's!@skip ||= false!true!' "$foo"
65
+ done
66
+ fi
67
+
68
+ echo -e "`date` \n\n**** \n**** Installing chef:\n****\n"
69
+ gem install ohai --no-rdoc --no-ri
70
+ gem install chef --no-rdoc --no-ri <%= bootstrap_version_string %>
71
+ # gems needed for the client.rb or so generically useful you want them at hand
72
+ gem install --no-rdoc --no-ri extlib bundler json right_aws pry
73
+
74
+ else # no chef-client
75
+ echo -e "`date` \n\n**** \n**** Chef is present -- skipping apt/ruby/chef installation\n****\n"
76
+ fi # end ruby+chef install
77
+
78
+ # fix a bug in chef that prevents debugging template errors
79
+ # will not work with --prerelease but that's OK hopefully opscode patches this crap soon
80
+ bad_template_file="/usr/lib/ruby/gems/${RUBY_VERSION}/gems/chef-${CHEF_VERSION}/lib/chef/mixin/template.rb"
81
+ if echo "0505c482b8b0b333ac71bbc8a1795d19 $bad_template_file" | md5sum -c - 2>/dev/null ; then
82
+ curl https://github.com/mrflip/chef/commit/655a1967253a8759afb54f30b818bbcb7c309198.patch | sudo patch $bad_template_file
83
+ fi
84
+
85
+ echo -e "`date` \n\n**** \n**** Knifing in the chef client config files:\n****\n"
86
+ mkdir -p /etc/chef
87
+
88
+ <%- if @config[:client_key] %>
89
+ (
90
+ cat <<'EOP'
91
+ <%= @config[:client_key] %>
92
+ EOP
93
+ ) > /tmp/knife-bootstrap/client.pem
94
+ awk NF /tmp/knife-bootstrap/client.pem > /etc/chef/client.pem
95
+ <%- else %>
96
+ (
97
+ cat <<'EOP'
98
+ <%= validation_key %>
99
+ EOP
100
+ ) > /tmp/knife-bootstrap/validation.pem
101
+ awk NF /tmp/knife-bootstrap/validation.pem > /etc/chef/validation.pem
102
+ <%- end %>
103
+
104
+ echo -e "`date` \n\n**** \n**** Nuking our temp files:\n****\n"
105
+
106
+ cd /tmp
107
+ rm -rf /tmp/knife-bootstrap
108
+
109
+ echo -e "`date` \n\n**** \n**** Creating chef client script:\n****\n"
110
+
111
+ (
112
+ cat <<'EOP'
113
+ <%= config_content %>
114
+ <%= @config[:node].chef_client_script_content %>
115
+ EOP
116
+ ) > /etc/chef/client.rb
117
+
118
+ (
119
+ cat <<'EOP'
120
+ <%= { "run_list" => @run_list, "cluster_name" => @config[:node].cluster_name, "facet_name" => @config[:node].facet_name, "facet_index" => @config[:node].facet_index }.to_json %>
121
+ EOP
122
+ ) > /etc/chef/first-boot.json
123
+
124
+ echo -e "`date` \n\n**** \n**** Adding chef client runit scripts:\n****\n"
125
+ ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
126
+ mkdir -p /var/log/chef /var/chef /etc/service /etc/sv/chef-client/{log/main,supervise}
127
+ cat > /etc/sv/chef-client/log/run <<EOP
128
+ #!/bin/bash
129
+ exec svlogd -tt ./main
130
+ EOP
131
+ cat > /etc/sv/chef-client/run <<EOP
132
+ #!/bin/bash
133
+ exec 2>&1
134
+ exec /usr/bin/env chef-client -i 43200 -s 20 -L /var/log/chef/client.log
135
+ EOP
136
+ chmod +x /etc/sv/chef-client/log/run /etc/sv/chef-client/run
137
+ ln -nfs /usr/bin/sv /etc/init.d/chef-client
138
+
139
+ service chef-client stop >/dev/null 2>&1 || true
140
+
141
+ <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
142
+ echo -e "`date` \n\n**** \n**** First run of chef:\n****\n"
143
+ set -e
144
+ <%= start_chef %>
145
+ set +e
146
+ <%- end %>
147
+
148
+ echo -e "`date` \n\n**** \n**** Cleanup:\n****\n"
149
+ # make locate work good
150
+ updatedb
151
+
152
+ echo -e "`date` \n\n**** \n**** Enabling chef client service:\n****\n"
153
+ ln -nfs /etc/sv/chef-client /etc/service/chef-client
154
+ service chef-client start
155
+
156
+ echo -e "`date` \n\n**** \n**** Cluster Chef client bootstrap complete\n****\n"
157
+ EOF