cluster_chef-knife 3.0.12 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -2
- data/README.md +5 -1
- data/Rakefile +11 -4
- data/VERSION +1 -1
- data/cluster_chef-knife.gemspec +8 -6
- data/config/ubuntu10.04-cluster_chef.erb +157 -0
- data/config/ubuntu11.10-cluster_chef.erb +145 -0
- data/ironfan.gemspec +123 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-cluster_chef.erb +40 -22
- data/lib/chef/knife/bootstrap/ubuntu11.10-cluster_chef.erb +26 -14
- data/lib/chef/knife/cluster_kick.rb +8 -0
- data/lib/chef/knife/cluster_kill.rb +2 -2
- data/lib/chef/knife/cluster_proxy.rb +16 -10
- data/lib/chef/knife/cluster_show.rb +5 -0
- data/lib/chef/knife/cluster_ssh.rb +49 -2
- data/lib/chef/knife/cluster_start.rb +8 -0
- data/lib/chef/knife/cluster_stop.rb +7 -1
- data/lib/chef/knife/cluster_sync.rb +2 -2
- data/lib/chef/knife/knife_common.rb +3 -6
- metadata +83 -82
- data/clusters/website_demo.rb +0 -65
- data/lib/chef/knife/bootstrap/ubuntu10.04-basic.erb +0 -78
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## v3.0.14:
|
2
|
+
|
3
|
+
Big important change:
|
4
|
+
|
5
|
+
# ClusterChef is now Ironfan
|
6
|
+
|
7
|
+
Due to a polite request from outside, we are changing this project's name to not include the word 'Chef'.
|
8
|
+
|
9
|
+
It's now 'Ironfan', after Princess Iron Fan from the legend of Sun Wukong (Voyage to the West). The monkey hero Sun Wukong could not reach his destination without the help of the Princess's Iron Fan. The project helps you fan out across big iron in the sky -- and "You Can't Do B.I. without a Big Ironfan".
|
10
|
+
|
11
|
+
This weekend (2/18) everything in the cluster_chef family of everything will get regex-replaced as ironfan. We'll track both gems for the next push or so, but new versions of the gem will not be released after Feb 2012.
|
12
|
+
|
13
|
+
Other improvements/fixes:
|
14
|
+
|
15
|
+
* knife cluster proxy now accepts additional hosts to direct to proxy -- set Chef::Config[:cluster_proxy_patterns] to an array of additional glob-style strings. Use this with the route53 support for fun and profit - if your machines look like foo-server-0-internal.whatupchimpy.com, add Chef::Config[:cluster_proxy_patterns] = '*internal.whatupchimpy.com*' to your knife-org.rb -- now you can browse securely to the private interface of any machine your target can.
|
16
|
+
* FIX #76 -- `knife cluster kick` runs chef-client if the service is stopped. Fixes #76 . Also knife ssh will at its end show a bright red list of machines whose commands exited with a non-zero exit code -- useful when 1 out of 30 machines fails a knife cluster kick.
|
17
|
+
* A limited number of commands (ssh, show, kill) now run with no requirement of cloud anything (Relates to #28). Also worked around an annoying incompatibility with chef 0.10.8 (clients have a 'name') vs 0.10.40-and-prev (clients have a 'clientname'.
|
18
|
+
* examples all live in `ironfan-homebase` now.
|
19
|
+
* When you `knife cluster stop` a node, it sets `node[:state]` to
|
20
|
+
* the cookbook linter now has its own project: [ironfan-scrubby](https://github.com/infochimps-labs/ironfan-scrubby). Along the way,
|
21
|
+
- some ability to cycle comments from the attributes file into node attribute docs in the `metadata.rb`.
|
22
|
+
- added helpful links to the `README.md` template
|
23
|
+
* minor fix to the new `authorized_by` calls
|
24
|
+
|
1
25
|
## v3.0.11: We Raid at Dawn
|
2
26
|
|
3
27
|
* You can now assemble raid groups in the cluster definition:
|
data/Gemfile
CHANGED
@@ -14,9 +14,10 @@ group :development do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
group :test do
|
17
|
-
gem 'spork', "
|
17
|
+
gem 'spork', ">= 0.9.0", :platform => :mri
|
18
|
+
gem 'rcov', ">= 0.9.9", :platform => :ruby_18
|
19
|
+
gem 'simplecov', ">= 0.5", :platform => :ruby_19
|
18
20
|
gem 'watchr', "~> 0.7"
|
19
|
-
gem 'rcov', ">= 0.9.9"
|
20
21
|
end
|
21
22
|
|
22
23
|
group :support do
|
data/README.md
CHANGED
@@ -215,7 +215,8 @@ to the chef server. (see below for details).
|
|
215
215
|
Hooray! You're ready to launch a cluster:
|
216
216
|
|
217
217
|
```ruby
|
218
|
-
knife cluster launch demosimple homebase --bootstrap
|
218
|
+
knife cluster launch demosimple homebase --bootstrap
|
219
|
+
```
|
219
220
|
|
220
221
|
It will kick off a node and then bootstrap it. You'll see it install a whole bunch of things. Yay.
|
221
222
|
|
@@ -263,6 +264,9 @@ If you already have a working chef installation you can skip this section.
|
|
263
264
|
|
264
265
|
To get started with knife and chef, follow the "Chef Quickstart,":http://wiki.opscode.com/display/chef/Quick+Start We use the hosted chef service and are very happy, but there are instructions on the wiki to set up a chef server too. Stop when you get to "Bootstrap the Ubuntu system" -- cluster chef is going to make that much easier.
|
265
266
|
|
267
|
+
* [Launch Cloud Instances with Knife](http://wiki.opscode.com/display/chef/Launch+Cloud+Instances+with+Knife)
|
268
|
+
* [EC2 Bootstrap Fast Start Guide](http://wiki.opscode.com/display/chef/EC2+Bootstrap+Fast+Start+Guide)
|
269
|
+
|
266
270
|
#### Cloud setup
|
267
271
|
|
268
272
|
Next,
|
data/Rakefile
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
+
DEPRECATED_NAME = "!! This gem has been renamed 'ironfan' (from cluster_chef). \n It will not be updated after Feb. 2012. \n Sorry for the inconvenience."
|
22
|
+
|
21
23
|
require 'rubygems' unless defined?(Gem)
|
22
24
|
require 'bundler'
|
23
25
|
begin
|
@@ -41,13 +43,14 @@ Dir[File.join('tasks', '*.rake')].sort.each{|f| load(f) }
|
|
41
43
|
# Jeweler -- release cluster_chef as a gem
|
42
44
|
#
|
43
45
|
|
44
|
-
%w[ cluster_chef cluster_chef-knife ]
|
46
|
+
gems_to_release = ENV['GEMS_TO_RELEASE'] ? ENV['GEMS_TO_RELEASE'].split : %w[ cluster_chef cluster_chef-knife ]
|
47
|
+
gems_to_release.each do |gem_name|
|
45
48
|
Jeweler::Tasks.new do |gem|
|
46
49
|
gem.name = gem_name
|
47
50
|
gem.homepage = "http://infochimps.com/labs"
|
48
51
|
gem.license = NEW_COOKBOOK_LICENSE.to_s
|
49
|
-
gem.summary = %Q{
|
50
|
-
gem.description = %Q{
|
52
|
+
gem.summary = %Q{#{gem_name} 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.}
|
53
|
+
gem.description = %Q{#{gem_name} 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.}
|
51
54
|
gem.email = SSL_EMAIL_ADDRESS
|
52
55
|
gem.authors = ["Infochimps"]
|
53
56
|
|
@@ -63,8 +66,12 @@ Dir[File.join('tasks', '*.rake')].sort.each{|f| load(f) }
|
|
63
66
|
if gem.name == 'cluster_chef'
|
64
67
|
gem.files.reject!{|f| f =~ %r{^(cluster_chef-knife.gemspec|lib/chef/knife/)} }
|
65
68
|
gem.add_runtime_dependency 'cluster_chef-knife', "= #{File.read('VERSION').strip}"
|
69
|
+
gem.post_install_message = DEPRECATED_NAME
|
66
70
|
elsif gem.name == 'cluster_chef-knife'
|
67
71
|
gem.files.reject!{|f| f =~ %r{^(cluster_chef.gemspec|lib/cluster_chef)} }
|
72
|
+
gem.post_install_message = DEPRECATED_NAME
|
73
|
+
elsif gem.name == 'ironfan'
|
74
|
+
true # pass
|
68
75
|
else
|
69
76
|
raise "Don't know what to include for gem #{gem.name}"
|
70
77
|
end
|
@@ -83,7 +90,7 @@ end
|
|
83
90
|
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
84
91
|
spec.pattern = 'spec/**/*_spec.rb'
|
85
92
|
spec.rcov = true
|
86
|
-
spec.rcov_opts = %w[ --exclude .rvm --no-comments --text-summary]
|
93
|
+
spec.rcov_opts = %w[ --exclude .rvm --no-comments --text-summary ]
|
87
94
|
end
|
88
95
|
|
89
96
|
# ---------------------------------------------------------------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.14
|
data/cluster_chef-knife.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cluster_chef-knife"
|
8
|
-
s.version = "3.0.
|
8
|
+
s.version = "3.0.14"
|
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-
|
13
|
-
s.description = "cluster_chef 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."
|
12
|
+
s.date = "2012-02-15"
|
13
|
+
s.description = "cluster_chef-knife 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 = [
|
16
16
|
"LICENSE",
|
@@ -28,10 +28,11 @@ Gem::Specification.new do |s|
|
|
28
28
|
"VERSION",
|
29
29
|
"chefignore",
|
30
30
|
"cluster_chef-knife.gemspec",
|
31
|
-
"clusters/website_demo.rb",
|
32
31
|
"config/client.rb",
|
33
32
|
"config/proxy.pac",
|
34
|
-
"
|
33
|
+
"config/ubuntu10.04-cluster_chef.erb",
|
34
|
+
"config/ubuntu11.10-cluster_chef.erb",
|
35
|
+
"ironfan.gemspec",
|
35
36
|
"lib/chef/knife/bootstrap/ubuntu10.04-cluster_chef.erb",
|
36
37
|
"lib/chef/knife/bootstrap/ubuntu11.10-cluster_chef.erb",
|
37
38
|
"lib/chef/knife/cluster_bootstrap.rb",
|
@@ -62,9 +63,10 @@ Gem::Specification.new do |s|
|
|
62
63
|
]
|
63
64
|
s.homepage = "http://infochimps.com/labs"
|
64
65
|
s.licenses = ["apachev2"]
|
66
|
+
s.post_install_message = "!! This gem has been renamed 'ironfan' (from cluster_chef). \n It will not be updated after Feb. 2012. \n Sorry for the inconvenience."
|
65
67
|
s.require_paths = ["lib"]
|
66
68
|
s.rubygems_version = "1.8.15"
|
67
|
-
s.summary = "cluster_chef 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."
|
69
|
+
s.summary = "cluster_chef-knife 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."
|
68
70
|
s.test_files = ["spec/cluster_chef/cluster_spec.rb", "spec/cluster_chef/facet_spec.rb", "spec/cluster_chef/server_slice_spec.rb", "spec/cluster_chef/server_spec.rb", "spec/cluster_chef_spec.rb", "spec/spec_helper/dummy_chef.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
|
69
71
|
|
70
72
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,157 @@
|
|
1
|
+
bash <<EOF || echo "Chef bootstrap failed!"
|
2
|
+
|
3
|
+
# This is the ubuntu natty bootstrap script from infochimps' cluster_chef. 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' cluster_chef. 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
|