ironfan 6.1.6 → 6.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  bash <<'EOF' || echo "Chef bootstrap failed!"
2
2
 
3
- # This is the RHEL 6 bootstrap script from infochimps' ironfan. It is
3
+ # This is the ubuntu natty bootstrap script from infochimps' ironfan. It is
4
4
  # based on opscode's bootstrap script, with the following important differences:
5
5
  #
6
6
  # * installs ruby 1.9.2 (not 1.8.7) from source
@@ -12,68 +12,88 @@ set -e
12
12
 
13
13
  <%= (@config[:verbosity].to_i > 1 ? 'set -v' : '') %>
14
14
 
15
- RUBY_VERSION=1.9.2-p290
16
- CHEF_VERSION=<%= bootstrap_version_string.gsub(/.*[\s=]/,"") %>
15
+ RUBY_VERSION=1.9.3-p545
16
+ CHEF_VERSION=11.12.4
17
17
 
18
18
  mkdir -p /tmp/knife-bootstrap
19
19
  chmod 700 /tmp/knife-bootstrap
20
20
  cd /tmp/knife-bootstrap
21
21
 
22
22
  <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
23
- cat /etc/redhat-release
24
-
25
23
  date > /etc/box_build_time
26
24
 
27
- echo -e "`date` \n\n**** \n**** yum upgrade:\n****\n"
28
- yum upgrade --assumeyes
29
-
30
- echo -e "`date` \n\n**** \n**** Installing base packages:\n****\n"
31
- yum install --assumeyes make wget
32
- yum install --assumeyes git rpm-build rpmdevtools gcc glibc-static zlib-devel libxml2-devel libxslt-devel openssl-devel telnet nc uuid-devel
33
- if [ ! -d runit-rpm ]; then git clone https://github.com/imeyer/runit-rpm.git; fi
34
- cd runit-rpm
35
- ./build.sh
36
- yum install --assumeyes /root/rpmbuild/RPMS/x86_64/runit-*.rpm || true # TODO: Remove this shim
37
- cd -
38
- yum remove --assumeyes prelink
25
+ function print_header() {
26
+ local message
27
+ message="$1"
28
+ echo -e "`date` \n\n**** \n**** ${message}\n****\n"
29
+ }
30
+
31
+ print_header "Creating infochimps yum repository"
32
+ cat >/etc/yum.repos.d/srp-rhel.repo <<EOP
33
+ [dev]
34
+ name=Infochimps Platform - dev
35
+ baseurl=https://s3.amazonaws.com/srp-rhel.chimpy.us/dev/
36
+ gpgcheck=0
37
+ EOP
38
+
39
+ print_header "yum upgrade"
40
+ # Exclude the kernel, otherwise the initramfs will be replaced,
41
+ # which has a custom, partition-growing feature
42
+ yum upgrade --assumeyes --exclude kernel
43
+
44
+ print_header "Installing base packages"
45
+ yum install --assumeyes \
46
+ autoconf \
47
+ automake \
48
+ bison \
49
+ bzip2 \
50
+ gcc \
51
+ gcc-c++ \
52
+ git \
53
+ glibc \
54
+ glibc-static \
55
+ libffi-devel \
56
+ libtool \
57
+ libxml2-devel \
58
+ libxslt-devel \
59
+ libyaml-devel \
60
+ make \
61
+ openssl-devel \
62
+ patch \
63
+ qt-all \
64
+ readline \
65
+ readline-devel \
66
+ rpm-build \
67
+ rpmdevtools \
68
+ wget \
69
+ zlib \
70
+ zlib-devel
71
+
72
+ # Grr, prevent 'prelink' from mangling our binaries
73
+ # http://www.tsheffler.com/blog/?p=491
74
+ grep ruby /etc/prelink.conf || echo '-b /usr/bin/ruby*' >>/etc/prelink.conf
75
+
76
+ print_header "Installing ruby version ${RUBY_VERSION}"
77
+ yum install --assumeyes ruby-1.9.3.p545
78
+
39
79
  yum clean all
40
80
 
41
81
  if [ ! -f /usr/bin/chef-client ]; then
42
- echo -e "`date` \n\n**** \n**** Installing ruby version ${RUBY_VERSION}:\n****\n"
43
-
44
- wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-${RUBY_VERSION}.tar.gz
45
- tar xzf ruby-${RUBY_VERSION}.tar.gz
46
- cd ruby-${RUBY_VERSION}
47
- ./configure --with-ruby-version=${RUBY_VERSION} --prefix=/usr --program-suffix=${RUBY_VERSION}
48
- make -j2
49
- make install
50
-
51
- alternatives \
52
- --install /usr/bin/ruby ruby /usr/bin/ruby${RUBY_VERSION} 400 \
53
- --slave /usr/bin/ri ri /usr/bin/ri${RUBY_VERSION} \
54
- --slave /usr/bin/irb irb /usr/bin/irb${RUBY_VERSION} \
55
- --slave /usr/bin/erb erb /usr/bin/erb${RUBY_VERSION} \
56
- --slave /usr/bin/gem gem /usr/bin/gem${RUBY_VERSION} \
57
- --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
58
- /usr/share/man/man1/ruby${RUBY_VERSION}.1
59
-
60
- echo -e "`date` \n\n**** \n**** Updating rubygems:\n****\n"
61
- gem install rubygems-update -v 1.8.5
62
-
63
- echo -e "`date` \n\n**** \n**** Installing chef:\n****\n"
64
- gem install net-ssh --no-rdoc --no-ri --version 2.2.2
65
- gem install net-ssh-gateway --no-rdoc --no-ri --version 1.1.0
66
- gem install net-ssh-multi --no-rdoc --no-ri --version 1.1
67
- gem install ohai --no-rdoc --no-ri --version 6.14.0
68
- gem install chef --no-rdoc --no-ri --version 10.16.4
82
+
83
+ print_header "Updating gems"
84
+ gem update --system
85
+
86
+ print_header "Installing chef"
87
+ gem install ohai --no-rdoc --no-ri
88
+ gem install chef --no-rdoc --no-ri --version "$CHEF_VERSION"
69
89
  # gems needed for the client.rb or so generically useful you want them at hand
70
90
  gem install --no-rdoc --no-ri extlib bundler json right_aws pry fog
71
91
 
72
92
  else # no chef-client
73
- echo -e "`date` \n\n**** \n**** Chef is present -- skipping apt/ruby/chef installation\n****\n"
93
+ print_header "Chef is present -- skipping apt/ruby/chef installation"
74
94
  fi # end ruby+chef install
75
95
 
76
- echo -e "`date` \n\n**** \n**** Knifing in the chef client config files:\n****\n"
96
+ print_header "Writing chef client config files"
77
97
  mkdir -p /etc/chef
78
98
 
79
99
  <%- if @config[:client_key] %>
@@ -102,12 +122,11 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
102
122
  rm /tmp/encrypted_data_bag_secret
103
123
  <% end -%>
104
124
 
105
- echo -e "`date` \n\n**** \n**** Nuking our temp files:\n****\n"
106
-
125
+ print_header "Deleting temp files"
107
126
  cd /tmp
108
127
  rm -rf /tmp/knife-bootstrap
109
128
 
110
- echo -e "`date` \n\n**** \n**** Creating chef client script:\n****\n"
129
+ print_header "Creating chef client script"
111
130
 
112
131
  (
113
132
  cat <<'EOP'
@@ -126,8 +145,22 @@ EOP
126
145
  mkdir -p /etc/chef/ohai/hints/
127
146
  touch /etc/chef/ohai/hints/ec2.json
128
147
 
148
+ print_header "Misc chef-client preparation"
149
+ ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
150
+ mkdir -p /var/log/chef /var/chef /etc/service /etc/sv
129
151
 
130
- echo -e "`date` \n\n**** \n**** Adding chef client nonce script:\n****\n"
152
+ <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
153
+ print_header "First run of chef"
154
+ set -e
155
+ <%= start_chef %>
156
+ set +e
157
+ <%- end %>
158
+
159
+ print_header "Clean up"
160
+ # make locate work good
161
+ updatedb
162
+
163
+ print_header "Adding chef-client-nonce script"
131
164
 
132
165
  cat > /etc/init.d/chef-client-nonce <<'EOP'
133
166
  #! /bin/sh
@@ -159,21 +192,25 @@ esac
159
192
  EOP
160
193
 
161
194
  mkdir -p /var/log/chef
162
- mkdir -p /etc/sv
163
195
  chmod +x /etc/init.d/chef-client-nonce
164
- chkconfig --add chef-client-nonce
165
- chkconfig --del iptables
166
- chkconfig --del rh-cloud-firstboot
167
- chkconfig --add rh-cloud-firstboot
168
-
169
- rm /etc/sysconfig/rh-cloud-firstboot
170
-
171
- <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
172
- sudo /etc/init.d/chef-client-nonce start
173
- <%- end %>
174
-
175
-
176
-
177
- echo -e "`date` \n\n**** \n**** Cleanup:\n****\n"
178
- cd /
179
- rm -r /tmp/knife-bootstrap
196
+ chkconfig --level 2345 chef-client-nonce on
197
+
198
+ print_header "Ensure 'user' user has sudo"
199
+ sed -i -e 's/name: root/name: user/' \
200
+ -e '/name: user/a \
201
+ groups: [wheel] \
202
+ homedir: /local/home/user' /etc/cloud/cloud.cfg
203
+ sed -i -e 's/# \(%wheel.*NOPASSWD.*\)/\1/' /etc/sudoers
204
+ mkdir -p /local/home
205
+
206
+ print_header "Disable iptables and postfix"
207
+ for svc in iptables ip6tables postfix; do
208
+ service $svc stop
209
+ chkconfig --level 2345 $svc off
210
+ done
211
+
212
+ print_header "Disable SELinux"
213
+ sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
214
+
215
+ print_header "Cluster Chef client bootstrap complete"
216
+ EOF
@@ -0,0 +1,240 @@
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 computer 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.3-p545
16
+ CHEF_VERSION=11.12.4
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
+ date > /etc/box_build_time
24
+
25
+ function print_header() {
26
+ local message
27
+ message="$1"
28
+ echo -e "`date` \n\n**** \n**** ${message}\n****\n"
29
+ }
30
+
31
+ print_header "Subscribing instance to Red Hat subscription"
32
+ if [ -z "<%= Chef::Config[:rhel_subs_useremail] %>" ] \
33
+ || [ -z "<%= Chef::Config[:rhel_subs_password] %>" ] \
34
+ || [ -z "<%= Chef::Config[:rhel_subs_pool] %>" ]; then
35
+
36
+ echo "You must configure subscription values in knife-org.rb"
37
+ exit 1
38
+ fi
39
+
40
+ subscription-manager register \
41
+ --user=<%= Chef::Config[:rhel_subs_useremail] %> \
42
+ --pass=<%= Chef::Config[:rhel_subs_password] %> \
43
+ --auto-attach
44
+
45
+ subscription-manager attach --pool=<%= Chef::Config[:rhel_subs_pool] %>
46
+
47
+ subscription-manager repos --disable=*
48
+ subscription-manager repos --enable=rhel-6-server-rpms
49
+ subscription-manager repos --enable=rhel-6-server-optional-rpms
50
+ subscription-manager repos --enable=rhel-6-server-supplementary-rpms
51
+
52
+ print_header "Creating infochimps yum repository"
53
+ cat >/etc/yum.repos.d/srp-rhel.repo <<EOP
54
+ [dev]
55
+ name=Infochimps Platform - dev
56
+ baseurl=https://s3.amazonaws.com/srp-rhel.chimpy.us/dev/
57
+ gpgcheck=0
58
+ EOP
59
+
60
+ print_header "yum upgrade"
61
+ # Exclude the kernel, otherwise the initramfs will be replaced,
62
+ # which has a custom, partition-growing feature
63
+ yum upgrade --assumeyes --exclude kernel
64
+
65
+ print_header "Installing base packages"
66
+ yum install --assumeyes \
67
+ autoconf \
68
+ automake \
69
+ bison \
70
+ bzip2 \
71
+ gcc \
72
+ gcc-c++ \
73
+ git \
74
+ glibc \
75
+ glibc-static \
76
+ libffi-devel \
77
+ libtool \
78
+ libxml2-devel \
79
+ libxslt-devel \
80
+ libyaml-devel \
81
+ make \
82
+ openssl-devel \
83
+ patch \
84
+ qt-all \
85
+ readline \
86
+ readline-devel \
87
+ rpm-build \
88
+ rpmdevtools \
89
+ wget \
90
+ zlib \
91
+ zlib-devel
92
+
93
+ # Grr, prevent 'prelink' from mangling our binaries
94
+ # http://www.tsheffler.com/blog/?p=491
95
+ grep ruby /etc/prelink.conf || echo '-b /usr/bin/ruby*' >>/etc/prelink.conf
96
+
97
+ print_header "Installing ruby version ${RUBY_VERSION}"
98
+ yum install --assumeyes ruby-1.9.3.p545
99
+
100
+ yum clean all
101
+
102
+ if [ ! -f /usr/bin/chef-client ]; then
103
+
104
+ print_header "Updating gems"
105
+ gem update --system
106
+
107
+ print_header "Installing chef"
108
+ gem install ohai --no-rdoc --no-ri
109
+ gem install chef --no-rdoc --no-ri --version "$CHEF_VERSION"
110
+ # gems needed for the client.rb or so generically useful you want them at hand
111
+ gem install --no-rdoc --no-ri extlib bundler json right_aws pry fog
112
+
113
+ else # no chef-client
114
+ print_header "Chef is present -- skipping apt/ruby/chef installation"
115
+ fi # end ruby+chef install
116
+
117
+ print_header "Writing chef client config files"
118
+ mkdir -p /etc/chef
119
+
120
+ <%- if @config[:client_key] %>
121
+ (
122
+ cat <<'EOP'
123
+ <%= @config[:client_key] %>
124
+ EOP
125
+ ) > /tmp/knife-bootstrap/client.pem
126
+ awk NF /tmp/knife-bootstrap/client.pem > /etc/chef/client.pem
127
+ <%- else %>
128
+ (
129
+ cat <<'EOP'
130
+ <%= validation_key %>
131
+ EOP
132
+ ) > /tmp/knife-bootstrap/validation.pem
133
+ awk NF /tmp/knife-bootstrap/validation.pem > /etc/chef/validation.pem
134
+ <%- end %>
135
+
136
+ <% if @chef_config[:encrypted_data_bag_secret] -%>
137
+ (
138
+ cat <<'EOP'
139
+ <%= encrypted_data_bag_secret %>
140
+ EOP
141
+ ) > /tmp/encrypted_data_bag_secret
142
+ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
143
+ rm /tmp/encrypted_data_bag_secret
144
+ <% end -%>
145
+
146
+ print_header "Deleting temp files"
147
+ cd /tmp
148
+ rm -rf /tmp/knife-bootstrap
149
+
150
+ print_header "Creating chef client script"
151
+
152
+ (
153
+ cat <<'EOP'
154
+ <%= config_content %>
155
+ <%= @config[:computer].chef_client_script_content %>
156
+ EOP
157
+ ) > /etc/chef/client.rb
158
+
159
+ (
160
+ cat <<'EOP'
161
+ <%= { "run_list" => @run_list, "cluster_name" => @config[:server].cluster_name, "facet_name" => @config[:server].facet_name, "facet_index" => @config[:server].index }.to_json %>
162
+ EOP
163
+ ) > /etc/chef/first-boot.json
164
+
165
+ # Ensure that EC2 images are recognized even inside VPC
166
+ mkdir -p /etc/chef/ohai/hints/
167
+ touch /etc/chef/ohai/hints/ec2.json
168
+
169
+ print_header "Misc chef-client preparation"
170
+ ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
171
+ mkdir -p /var/log/chef /var/chef /etc/service /etc/sv
172
+
173
+ <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
174
+ print_header "First run of chef"
175
+ set -e
176
+ <%= start_chef %>
177
+ set +e
178
+ <%- end %>
179
+
180
+ print_header "Clean up"
181
+ # make locate work good
182
+ updatedb
183
+
184
+ print_header "Adding chef-client-nonce script"
185
+
186
+ cat > /etc/init.d/chef-client-nonce <<'EOP'
187
+ #! /bin/sh
188
+ ### BEGIN INIT INFO
189
+ # Provides: chef-client-nonce
190
+ # Required-Start: $remote_fs $network
191
+ # Required-Stop:
192
+ # Default-Start: 2 3 4 5
193
+ # Default-Stop: 0 1 6
194
+ # Short-Description: Start a single chef-client run.
195
+ ### END INIT INFO
196
+ #
197
+ # Copyright (c) 2009-2010 Opscode, Inc, <legal@opscode.com>
198
+ #
199
+ # chef-client Startup script for chef-client.
200
+ # chkconfig: - 99 02
201
+ # description: starts up chef-client once, at boot
202
+
203
+ case "$1" in
204
+ start)
205
+ /usr/bin/chef-client -L /var/log/chef/client.log
206
+ exit $?
207
+ ;;
208
+ *)
209
+ echo "Usage: /etc/init.d/chef-client-nonce start" >&2
210
+ exit 1
211
+ ;;
212
+ esac
213
+ EOP
214
+
215
+ mkdir -p /var/log/chef
216
+ chmod +x /etc/init.d/chef-client-nonce
217
+ chkconfig --level 2345 chef-client-nonce on
218
+
219
+ print_header "Ensure 'user' user has sudo"
220
+ sed -i -e 's/name: root/name: user/' \
221
+ -e '/name: user/a \
222
+ groups: [wheel] \
223
+ homedir: /local/home/user' /etc/cloud/cloud.cfg
224
+ sed -i -e 's/# \(%wheel.*NOPASSWD.*\)/\1/' /etc/sudoers
225
+ mkdir -p /local/home
226
+
227
+ print_header "Disable iptables and postfix"
228
+ for svc in iptables ip6tables postfix; do
229
+ service $svc stop
230
+ chkconfig --level 2345 $svc off
231
+ done
232
+
233
+ print_header "Disable SELinux"
234
+ sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
235
+
236
+ print_header "Unregistering instance from Red Hat subscription"
237
+ subscription-manager unregister
238
+
239
+ print_header "Cluster Chef client bootstrap complete"
240
+ EOF
@@ -13,14 +13,29 @@ module Ironfan
13
13
  field :name, String
14
14
  field :bogus, Array, :default => []
15
15
 
16
+ def lookup_snapshot_id(region, snapshot_name)
17
+ keys = [region.to_s, snapshot_name.to_s]
18
+ return Chef::Config[:ec2_snapshot_info][ keys ][:snapshot_id] rescue nil
19
+ end
20
+
16
21
  def initialize(*args)
17
22
  super
18
23
  providers[:chef] ||= Ironfan::Provider::ChefServer
19
24
  return unless server
20
25
  providers[:iaas] = server.selected_cloud.provider
21
26
  volumes = server.volumes.values
27
+ puts server.selected_cloud
28
+ region = server.selected_cloud.region
29
+
30
+
31
+ # Turn snapshot names into snapshot ids corresponding to the server region
32
+ volumes.each do |vol|
33
+ vol.snapshot_id || vol.snapshot_id(lookup_snapshot_id(region, vol.snapshot_name))
34
+ end
35
+
22
36
  volumes += server.implied_volumes
23
37
  volumes.each{|vol| self.drive vol.name, :volume => vol }
38
+
24
39
  rescue StandardError => err ; err.polish("#{self.class} on '#{args.inspect}'") rescue nil ; raise
25
40
  end
26
41
 
@@ -365,7 +380,7 @@ module Ironfan
365
380
  select do |mach|
366
381
  mach.bogus? || (
367
382
  # facet match, and index match (or no indexes specified)
368
- (mach.server.cluster_name == cluster_name) &&
383
+ (mach.server.cluster_name == cluster_name) &&
369
384
  (mach.server.facet_name == facet_name || facet_name.nil?) &&
370
385
  (slice_array.include?(mach.server.index) || slice_indexes.nil?))
371
386
  end
@@ -334,6 +334,11 @@ Chef::Config[:ec2_flavor_info].merge!({
334
334
  'c3.2xlarge' => { :price => 0.600, :bits => 64, :ram => 15360, :cores => 8, :core_size => 3.5, :inst_disks => 2, :inst_disk_size => 80, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm', :ebs_opizable => 1000 },
335
335
  'c3.4xlarge' => { :price => 1.200, :bits => 64, :ram => 30720, :cores => 16, :core_size => 3.4375, :inst_disks => 2, :inst_disk_size => 160, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm', :ebs_opizable => 1000 },
336
336
  'c3.8xlarge' => { :price => 2.400, :bits => 64, :ram => 61440, :cores => 32, :core_size => 3.375, :inst_disks => 2, :inst_disk_size => 320, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' },
337
+ 'r3.large' => { :price => 0.175, :bits => 64, :ram => 15360, :cores => 2, :core_size => 3.5, :inst_disks => 1, :inst_disk_size => 32, :ephemeral_volumes => 1, :virtualization => 'hvm' },
338
+ 'r3.xlarge' => { :price => 0.350, :bits => 64, :ram => 30720, :cores => 4, :core_size => 3.5, :inst_disks => 1, :inst_disk_size => 80, :ephemeral_volumes => 1, :virtualization => 'hvm', :ebs_opizable => 1000 },
339
+ 'r3.2xlarge' => { :price => 0.700, :bits => 64, :ram => 61440, :cores => 8, :core_size => 3.5, :inst_disks => 1, :inst_disk_size => 160, :ephemeral_volumes => 1, :virtualization => 'hvm', :ebs_opizable => 1000 },
340
+ 'r3.4xlarge' => { :price => 1.400, :bits => 64, :ram => 124928, :cores => 16, :core_size => 3.5, :inst_disks => 1, :inst_disk_size => 320, :ephemeral_volumes => 1, :virtualization => 'hvm', :ebs_opizable => 1000 },
341
+ 'r3.8xlarge' => { :price => 2.800, :bits => 64, :ram => 249856, :cores => 32, :core_size => 3.5, :inst_disks => 2, :inst_disk_size => 320, :ephemeral_volumes => 2, :virtualization => 'hvm' },
337
342
  'hs1.8xlarge' => { :price => 4.600, :bits => 64, :ram => 119808, :cores => 16, :core_size => 2.1875, :inst_disks => 24, :inst_disk_size => 2048, :ephemeral_volumes => 24, :placement_groupable => true, :virtualization => 'hvm' },
338
343
  'cr1.8xlarge' => { :price => 3.500, :bits => 64, :ram => 249856, :cores => 32, :core_size => 2.75, :inst_disks => 2, :inst_disk_size => 120, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' },
339
344
  'i2.xlarge' => { :price => 0.853, :bits => 64, :ram => 31232, :cores => 4, :core_size => 3.5, :inst_disks => 1, :inst_disk_size => 800, :ephemeral_volumes => 1, :placement_groupable => true, :virtualization => 'hvm', :ebs_optimized => 500 },
@@ -24,17 +24,6 @@ module Ironfan
24
24
  magic :snapshot_name, String
25
25
  magic :tags, Hash, :default => {}
26
26
 
27
- VOLUME_IDS ||= {}
28
- VOLUME_IDS.merge!({
29
- :blank_xfs => 'snap-d9c1edb1',
30
- :blank_xfs_tokyo => 'snap-049d1921',
31
- :blank_xfs_california => 'snap-514b5c5a', # us-west-1
32
- })
33
-
34
- def snapshot_id(*)
35
- Ironfan.todo("CODE SMELL: EBS specific information in Dsl::Volume::VOLUME_IDS")
36
- super || VOLUME_IDS[snapshot_name]
37
- end
38
27
  end
39
28
 
40
29
  class RaidGroup < Volume
@@ -213,6 +213,11 @@ module Ironfan
213
213
  # A Machine lives and dies with its Computer
214
214
  def self.shared?() false; end
215
215
 
216
+ # FIXME: users_groups only in 7.4, not 6.3 ... including
217
+ # this module breaks on our Ubuntu image (with cloud-init 6.3)
218
+ # note that in the sed statement in the bootcmd below,
219
+ # sed expects some characters to be escaped \(\) etc.
220
+ # then yaml needs \ inside double-quotes escaped as \x5c
216
221
  def self.cloud_init_user_data(computer)
217
222
  return <<EOF
218
223
  #cloud-config
@@ -225,18 +230,19 @@ output: {all: '| tee -a /var/log/cloud-init-output.log'}
225
230
  # Set our hostname
226
231
  manage_etc_hosts: True
227
232
 
228
- cloud_init_modules:
229
- - bootcmd
230
- - resizefs
231
- - set_hostname
232
- - update_hostname
233
- - update_etc_hosts
234
- - ca-certs
235
- - rsyslog
236
- - ssh
237
-
238
233
  fqdn: #{computer.server.fqdn}
239
234
 
235
+ cloud_init_modules:
236
+ - bootcmd
237
+ - resizefs
238
+ - set_hostname
239
+ - update_hostname
240
+ - update_etc_hosts
241
+ - ca-certs
242
+ - rsyslog
243
+ - users-groups
244
+ - ssh
245
+
240
246
  bootcmd:
241
247
  # note that writefiles is not supported on precise...
242
248
  - |
@@ -248,8 +254,13 @@ bootcmd:
248
254
  #{computer.private_key.split("\n").map {|l| " "+l}.join("\n")}
249
255
  EOF
250
256
  domainname #{computer.server.fqdn}
251
- IP=`curl 169.254.169.254/latest/meta-data/local-ipv4`;sed -i -e "s/127\.0\.1\.1/$IP/" /etc/cloud/templates/hosts.tmpl
252
-
257
+ IP=`curl 169.254.169.254/latest/meta-data/local-ipv4`
258
+ [ -f /etc/cloud/templates/hosts.tmpl ] && sed -i -e "s/127\x5c.0\x5c.1\x5c.1/$IP/" /etc/cloud/templates/hosts.tmpl
259
+ [ -f /etc/cloud/templates/hosts.debian.tmpl ] && sed -i -e "s/127\x5c.0\x5c.1\x5c.1/$IP/" /etc/cloud/templates/hosts.debian.tmpl
260
+ [ -f /etc/cloud/templates/hosts.redhat.tmpl ] && sed -i -e "/::1/d" -e "s/^[0-9]*\x5c.[0-9]*\x5c.[0-9]*\x5c.[0-9]*\x5c( .*fqdn.*\x5c)/$IP\x5c1/" /etc/cloud/templates/hosts.redhat.tmpl
261
+
262
+ # This is understood to fail gracefully during image creation (before
263
+ # knife cluster bootstrap burninator...) due to Chef not installed yet.
253
264
  chef:
254
265
  install_type: "packages"
255
266
  force_install: false
@@ -268,6 +279,7 @@ chef:
268
279
  We don't need no stinking validators.
269
280
  EOF
270
281
  end
282
+
271
283
  end
272
284
  end
273
285
  end
@@ -226,8 +226,13 @@ module Ironfan
226
226
  errors['Missing client'] = info unless computer.client?
227
227
  errors['Missing private_key'] = computer.client unless computer.private_key
228
228
  #
229
- all_asserted_regions = [Ec2.connection.region, cloud.region, Chef::Config[:knife][:region], Ironfan.chef_config[:region]].compact.uniq
230
- errors["mismatched region"] = all_asserted_regions unless all_asserted_regions.count == 1
229
+ asserted_regions = {
230
+ :ec2_connection => Ec2.connection.region,
231
+ :cloud => cloud.region,
232
+ :knife => Chef::Config[:knife][:region],
233
+ :chef_config => Ironfan.chef_config[:region]
234
+ }
235
+ errors["mismatched region"] = asserted_regions unless asserted_regions.values.compact.uniq.count == 1
231
236
  #
232
237
  errors
233
238
  end
@@ -1,3 +1,3 @@
1
1
  module Ironfan
2
- VERSION = '6.1.6'
2
+ VERSION = '6.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.6
4
+ version: 6.1.7
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: 2014-05-02 00:00:00.000000000 Z
12
+ date: 2014-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -183,9 +183,9 @@ files:
183
183
  - config/ubuntu12.04-ironfan.erb
184
184
  - ironfan.gemspec
185
185
  - lib/chef/cluster_knife.rb
186
- - lib/chef/knife/bootstrap/centos6.2-ironfan.erb
186
+ - lib/chef/knife/bootstrap/centos6.5-ironfan.erb
187
187
  - lib/chef/knife/bootstrap/chef-full-ironfan.erb
188
- - lib/chef/knife/bootstrap/rhel6.3-ironfan.erb
188
+ - lib/chef/knife/bootstrap/rhel6.5-ironfan.erb
189
189
  - lib/chef/knife/bootstrap/ubuntu10.04-ironfan.erb
190
190
  - lib/chef/knife/bootstrap/ubuntu12.04-ironfan.erb
191
191
  - lib/chef/knife/cluster_bootstrap.rb
@@ -322,7 +322,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
322
322
  version: '0'
323
323
  segments:
324
324
  - 0
325
- hash: 4249485048014092893
325
+ hash: 159548640143306131
326
326
  required_rubygems_version: !ruby/object:Gem::Requirement
327
327
  none: false
328
328
  requirements:
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  version: '0'
332
332
  segments:
333
333
  - 0
334
- hash: 4249485048014092893
334
+ hash: 159548640143306131
335
335
  requirements: []
336
336
  rubyforge_project:
337
337
  rubygems_version: 1.8.25
@@ -1,158 +0,0 @@
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 computer 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
- cat /etc/centos-release
24
-
25
- date > /etc/box_build_time
26
-
27
- echo -e "`date` \n\n**** \n**** yum upgrade:\n****\n"
28
- yum upgrade --assumeyes
29
-
30
- echo -e "`date` \n\n**** \n**** Installing base packages:\n****\n"
31
- yum install --assumeyes make wget
32
- yum install --assumeyes git rpm-build rpmdevtools gcc glibc-static zlib-devel libxml2-devel libxslt-devel openssl-devel
33
- if [ ! -d runit-rpm ]; then git clone https://github.com/imeyer/runit-rpm.git; fi
34
- cd runit-rpm
35
- ./build.sh
36
- yum install --assumeyes /root/rpmbuild/RPMS/x86_64/runit-*.rpm || true # TODO: Remove this shim
37
- cd -
38
-
39
- yum clean all
40
-
41
- if [ ! -f /usr/bin/chef-client ]; then
42
- echo -e "`date` \n\n**** \n**** Installing ruby version ${RUBY_VERSION}:\n****\n"
43
-
44
- wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-${RUBY_VERSION}.tar.gz
45
- tar xzf ruby-${RUBY_VERSION}.tar.gz
46
- cd ruby-${RUBY_VERSION}
47
- ./configure --with-ruby-version=${RUBY_VERSION} --prefix=/usr --program-suffix=${RUBY_VERSION}
48
- make -j2
49
- make install
50
-
51
- alternatives \
52
- --install /usr/bin/ruby ruby /usr/bin/ruby${RUBY_VERSION} 400 \
53
- --slave /usr/bin/ri ri /usr/bin/ri${RUBY_VERSION} \
54
- --slave /usr/bin/irb irb /usr/bin/irb${RUBY_VERSION} \
55
- --slave /usr/bin/erb erb /usr/bin/erb${RUBY_VERSION} \
56
- --slave /usr/bin/gem gem /usr/bin/gem${RUBY_VERSION} \
57
- --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
58
- /usr/share/man/man1/ruby${RUBY_VERSION}.1
59
-
60
- echo -e "`date` \n\n**** \n**** Updating rubygems:\n****\n"
61
- gem update --system
62
-
63
- echo -e "`date` \n\n**** \n**** Installing chef:\n****\n"
64
- gem install ohai --no-rdoc --no-ri
65
- gem install chef --no-rdoc --no-ri <%= bootstrap_version_string %>
66
- # gems needed for the client.rb or so generically useful you want them at hand
67
- gem install --no-rdoc --no-ri extlib bundler json right_aws pry fog
68
-
69
- else # no chef-client
70
- echo -e "`date` \n\n**** \n**** Chef is present -- skipping apt/ruby/chef installation\n****\n"
71
- fi # end ruby+chef install
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
- <% if @chef_config[:encrypted_data_bag_secret] -%>
93
- (
94
- cat <<'EOP'
95
- <%= encrypted_data_bag_secret %>
96
- EOP
97
- ) > /tmp/encrypted_data_bag_secret
98
- awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
99
- rm /tmp/encrypted_data_bag_secret
100
- <% end -%>
101
-
102
- echo -e "`date` \n\n**** \n**** Nuking our temp files:\n****\n"
103
-
104
- cd /tmp
105
- rm -rf /tmp/knife-bootstrap
106
-
107
- echo -e "`date` \n\n**** \n**** Creating chef client script:\n****\n"
108
-
109
- (
110
- cat <<'EOP'
111
- <%= config_content %>
112
- <%= @config[:computer].chef_client_script_content %>
113
- EOP
114
- ) > /etc/chef/client.rb
115
-
116
- (
117
- cat <<'EOP'
118
- <%= { "run_list" => @run_list, "cluster_name" => @config[:server].cluster_name, "facet_name" => @config[:server].facet_name, "facet_index" => @config[:server].index }.to_json %>
119
- EOP
120
- ) > /etc/chef/first-boot.json
121
-
122
- echo -e "`date` \n\n**** \n**** Adding chef client runit scripts:\n****\n"
123
- ( service chef-client stop >/dev/null 2>&1 ; sleep 1 ; killall chef-client 2>/dev/null ) || true
124
- mkdir -p /var/log/chef /var/chef /etc/service /etc/sv/chef-client/{log/main,supervise}
125
-
126
- cat > /etc/sv/chef-client/log/run <<'EOP'
127
- #!/bin/bash
128
- exec svlogd -tt ./main
129
- EOP
130
-
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
-
137
- chmod +x /etc/sv/chef-client/log/run /etc/sv/chef-client/run
138
- ln -nfs /sbin/sv /etc/init.d/chef-client
139
-
140
- service chef-client stop >/dev/null 2>&1 || true
141
-
142
- <%- if (@config[:bootstrap_runs_chef_client].to_s == 'true') || (@chef_config.knife[:bootstrap_runs_chef_client].to_s == 'true') %>
143
- echo -e "`date` \n\n**** \n**** First run of chef:\n****\n"
144
- set -e
145
- <%= start_chef %>
146
- set +e
147
- <%- end %>
148
-
149
- echo -e "`date` \n\n**** \n**** Cleanup:\n****\n"
150
- # make locate work good
151
- updatedb
152
-
153
- echo -e "`date` \n\n**** \n**** Enabling chef client service:\n****\n"
154
- ln -nfs /etc/sv/chef-client /etc/service/chef-client
155
- service chef-client start
156
-
157
- echo -e "`date` \n\n**** \n**** Cluster Chef client bootstrap complete\n****\n"
158
- EOF