stemcell 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a75498d7efc84297470587517941d2c008fb5e3c
4
- data.tar.gz: 78e9281f72c7cd72c03da98aa0041bb1969ac7b9
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzZkYjUzZGU4NDA1OTQwYTk4Y2Y1YmM3M2M0NmVhYzFmOTc1NWRhMQ==
5
+ data.tar.gz: !binary |-
6
+ ODZiYTA3ZjI3MTA3ZWM3YTI2NzUzOWYzMWZkYWMwOGU3NjA0M2UyNA==
5
7
  SHA512:
6
- metadata.gz: b0b8832be4df37d3599639f88bd093e1924e3ceada6bb0daec655276935fd3b63dd2d42e1df40404c5b867cc64bdacb50174231e85edef80d531c2cd5ee88dae
7
- data.tar.gz: c4df4499b664495dc4d94b0ad9188562aa030b0025783f1040fae4a3a21db5908f5dbb660e0286dd11c0bf31f14ca70b419c3b3a7e10a5037eea0e37ce2abb51
8
+ metadata.gz: !binary |-
9
+ YWE5MTJmMWI0NGMwYzFmZmU3YjkyYWVhMzEzY2YwNmEyZjM1NWVmYTk0ODRl
10
+ ZGEyMTQ4NDNiNDBhODUxZTRmNzlkNWNhNTI1MTg2Y2NiMmNhNzIzZWNlNmZk
11
+ ZDhiNjI1OTY1YjhjZTU5YjM0ZDE2ZWZiYTQ5ZTIyMGFjNTg2Yzg=
12
+ data.tar.gz: !binary |-
13
+ YWNhMDZhMTdhMjEyZjEyYTNmMzM2MjljMTJjOGFmYWFmN2M1NzI3N2Y0ZDll
14
+ ZGRhZmExN2YyYTlkN2ZhZWY1ZmNiODU0NWE1MjM4YzRkYjU2OGUzMTVlYTcy
15
+ YTQyNjZlNjZlNjE4Y2YzYzI0ZjRkZWJjOTUzNmE0M2NlNWVhODU=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.11.1
2
+ - update bootstrap.sh to support launched_by file, site-cookbooks, ohai_plugins, and retries if the initial converge fails
3
+ - include version in version string
4
+
1
5
  # 0.11.0
2
6
  - allow user to specify `contexts` to override certain attributes
3
7
 
@@ -8,7 +8,7 @@ module Stemcell
8
8
  attr_reader :chef_root
9
9
  attr_reader :chef_role
10
10
 
11
- VERSION_STRING = "Stemcell (c) 2012-2013 Airbnb."
11
+ VERSION_STRING = "Stemcell #{VERSION} (c) 2012-2016 Airbnb."
12
12
  BANNER_STRING = "Launch instances from metadata stored in roles!\n" \
13
13
  "Usage: stemcell [chef role] [options]"
14
14
 
@@ -1,12 +1,6 @@
1
1
  #!/bin/bash -e
2
2
  #
3
3
  # This script will bootstrap and run chef
4
- #
5
- # You need to specify a role, origin, git_key, branch name, and data
6
- # bag secret info below
7
- #
8
- # Martin Rhoads
9
-
10
4
 
11
5
  (
12
6
  echo 'Acquiring converge lock...'
@@ -16,14 +10,12 @@ echo 'Lock acquired!'
16
10
  set -o pipefail
17
11
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
18
12
 
19
-
20
13
  # ensure we were called by root
21
14
  if [ $UID != 0 ]; then
22
15
  echo "this script needs to be run as root. exiting..."
23
16
  exit 1
24
17
  fi
25
18
 
26
-
27
19
  # redirect stdout to /var/log/init
28
20
  exec >> /var/log/init
29
21
 
@@ -36,6 +28,14 @@ exec 2>> /var/log/init.err
36
28
  ##
37
29
 
38
30
  chef_dir=/etc/chef
31
+ repo_dir=${chef_dir}/src
32
+ keyfile=${chef_dir}/git_key
33
+ envfile=${chef_dir}/environment
34
+ launchedbyfile=${chef_dir}/launched_by
35
+ rolefile=${chef_dir}/role
36
+ branchfile=${chef_dir}/branch
37
+ originfile=${chef_dir}/origin
38
+ git_wrapper=${chef_dir}/git_wrapper
39
39
  converge=/usr/local/bin/first_converge
40
40
  role=<%= opts['chef_role'] %>
41
41
  environment=<%= opts['chef_environment'] %>
@@ -46,19 +46,18 @@ data_bag_secret='<%= opts["chef_data_bag_secret"] %>'
46
46
  hostname='<%= opts['instance_hostname'] %>'
47
47
  domain_name='<%= opts['instance_domain_name'] %>'
48
48
  chef_version='<%= opts['chef_version'] %>'
49
+ username='<%= opts.fetch('user', ENV['USER']) %>'
49
50
 
50
51
 
51
52
  ##
52
- ## common function
53
+ ## common functions
53
54
  ##
54
55
 
55
-
56
56
  update() {
57
57
  echo updating apt repo
58
58
  apt-get update 1>&2
59
59
  }
60
60
 
61
-
62
61
  install() {
63
62
  if ! (dpkg -l | awk '{print $2}' | grep -q ^$1$ ) ; then
64
63
  echo installing $1...
@@ -67,7 +66,6 @@ install() {
67
66
  fi
68
67
  }
69
68
 
70
-
71
69
  set_hostname() {
72
70
  instance_id=`curl --silent --retry 5 --retry-delay 5 169.254.169.254/latest/meta-data/instance-id` 1>&2
73
71
  local_ip=`curl --silent --retry 5 --retry-delay 5 169.254.169.254/latest/meta-data/local-ipv4` 1>&2
@@ -130,7 +128,6 @@ update_repo() {
130
128
  echo "done updating code"
131
129
  }
132
130
 
133
-
134
131
  configure_chef() {
135
132
  echo "saving current origin ($origin), branch ($branch), role ($role), and environment ($environment)"
136
133
  echo "$origin" > $originfile
@@ -145,16 +142,21 @@ configure_chef() {
145
142
  echo "$environment" > $envfile
146
143
  chmod 644 $envfile
147
144
 
145
+ echo "$username" > $launchedbyfile
146
+ chmod 644 $launchedbyfile
147
+
148
148
  echo "configuring chef solo..."
149
149
  cat<<EOF > ${chef_dir}/solo.rb
150
- repo_dir = "${repo_dir}"
151
- cookbook_path "#{repo_dir}/cookbooks"
152
- role_path "#{repo_dir}/roles"
150
+ repo_dir = "${repo_dir}"
151
+
152
+ cookbook_path ["#{repo_dir}/site-cookbooks", "#{repo_dir}/cookbooks"]
153
+ role_path "#{repo_dir}/roles"
153
154
  data_bag_path "#{repo_dir}/data_bags"
154
155
  ssl_verify_mode :verify_peer
156
+ log_level :info
157
+ log_location STDOUT
155
158
 
156
- log_level :info
157
- log_location STDOUT
159
+ Ohai::Config[:plugin_path] << "#{repo_dir}/ohai_plugins"
158
160
  EOF
159
161
 
160
162
  encrypted_data_bag_secret_file=${chef_dir}/encrypted_data_bag_secret
@@ -164,8 +166,7 @@ EOF
164
166
  echo "chef configured"
165
167
  }
166
168
 
167
-
168
- configure_converger() {
169
+ configure_converge() {
169
170
  cat<<EOF > $converge
170
171
  #!/bin/bash -eu
171
172
 
@@ -198,27 +199,28 @@ EOF
198
199
  chmod 544 $converge
199
200
  }
200
201
 
201
- configure_chef_daemon() {
202
- cat<<EOF > /etc/init/chef-solo.conf
203
- description "chef-solo"
204
- author "Martin Rhoads"
205
- start on networking
206
- script
207
- chef-solo --interval 600 --splay 600 | logger -t chef-solo 2>&1
208
- end script
209
- respawn
210
- EOF
211
- }
212
-
213
-
214
202
  run_chef() {
215
- echo "doing initial chef run..."
216
- $converge 1>&2
217
- echo "initial chef run complete"
218
- }
203
+ set +e # unset e to allow retries
204
+ converge_succeed=false
205
+ for atmpt in $(seq 1 3);
206
+ do
207
+ echo "doing initial chef run... (attempt $atmpt)"
208
+ $converge 1>&2
209
+ if [ $? -eq 0 ]; then
210
+ converge_succeed=true
211
+ break
212
+ fi
213
+ done
214
+
215
+ if [ $converge_succeed == true ]; then
216
+ echo "initial chef run completes successfully"
217
+ else
218
+ echo "****************************************"
219
+ echo "* WARNING: initial converge failed! *"
220
+ echo "****************************************"
221
+ fi
219
222
 
220
- start_chef_daemon() {
221
- start chef-solo
223
+ set -e
222
224
  }
223
225
 
224
226
 
@@ -226,17 +228,7 @@ start_chef_daemon() {
226
228
  ## main
227
229
  ##
228
230
 
229
- #some derived vars
230
- repo_dir=${chef_dir}/src
231
- keyfile=${chef_dir}/git_key
232
- envfile=${chef_dir}/environment
233
- rolefile=${chef_dir}/role
234
- branchfile=${chef_dir}/branch
235
- originfile=${chef_dir}/origin
236
- git_wrapper=${chef_dir}/git_wrapper
237
-
238
231
  echo "starting chef bootstrapping..."
239
- mkdir -p ${chef_dir}
240
232
  update
241
233
  install curl
242
234
  install git
@@ -245,17 +237,7 @@ install_chef
245
237
  create_ohai_hint
246
238
  update_repo
247
239
  configure_chef
248
- configure_converger
240
+ configure_converge
249
241
  run_chef
250
-
251
- configure_chef_daemon
252
- # start_chef_daemon
253
-
254
-
255
- ##
256
- ## exit
257
- ##
258
-
259
-
260
242
  echo "<%= last_bootstrap_line %>"
261
243
  ) 200> /var/run/converge.lock
@@ -1,3 +1,3 @@
1
1
  module Stemcell
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stemcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Rhoads
@@ -11,118 +11,124 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-14 00:00:00.000000000 Z
14
+ date: 2016-09-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: aws-sdk-v1
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: '1.63'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.63'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: net-ssh
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - ~>
35
35
  - !ruby/object:Gem::Version
36
36
  version: '2.9'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
43
  version: '2.9'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: chef
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - ! '>='
49
49
  - !ruby/object:Gem::Version
50
50
  version: 11.4.0
51
+ - - <
52
+ - !ruby/object:Gem::Version
53
+ version: 12.0.0
51
54
  type: :runtime
52
55
  prerelease: false
53
56
  version_requirements: !ruby/object:Gem::Requirement
54
57
  requirements:
55
- - - ">="
58
+ - - ! '>='
56
59
  - !ruby/object:Gem::Version
57
60
  version: 11.4.0
61
+ - - <
62
+ - !ruby/object:Gem::Version
63
+ version: 12.0.0
58
64
  - !ruby/object:Gem::Dependency
59
65
  name: rack
60
66
  requirement: !ruby/object:Gem::Requirement
61
67
  requirements:
62
- - - "<"
68
+ - - <
63
69
  - !ruby/object:Gem::Version
64
70
  version: 2.0.0
65
71
  type: :runtime
66
72
  prerelease: false
67
73
  version_requirements: !ruby/object:Gem::Requirement
68
74
  requirements:
69
- - - "<"
75
+ - - <
70
76
  - !ruby/object:Gem::Version
71
77
  version: 2.0.0
72
78
  - !ruby/object:Gem::Dependency
73
79
  name: trollop
74
80
  requirement: !ruby/object:Gem::Requirement
75
81
  requirements:
76
- - - "~>"
82
+ - - ~>
77
83
  - !ruby/object:Gem::Version
78
84
  version: '2.1'
79
85
  type: :runtime
80
86
  prerelease: false
81
87
  version_requirements: !ruby/object:Gem::Requirement
82
88
  requirements:
83
- - - "~>"
89
+ - - ~>
84
90
  - !ruby/object:Gem::Version
85
91
  version: '2.1'
86
92
  - !ruby/object:Gem::Dependency
87
93
  name: aws-creds
88
94
  requirement: !ruby/object:Gem::Requirement
89
95
  requirements:
90
- - - "~>"
96
+ - - ~>
91
97
  - !ruby/object:Gem::Version
92
98
  version: 0.2.3
93
99
  type: :runtime
94
100
  prerelease: false
95
101
  version_requirements: !ruby/object:Gem::Requirement
96
102
  requirements:
97
- - - "~>"
103
+ - - ~>
98
104
  - !ruby/object:Gem::Version
99
105
  version: 0.2.3
100
106
  - !ruby/object:Gem::Dependency
101
107
  name: colored
102
108
  requirement: !ruby/object:Gem::Requirement
103
109
  requirements:
104
- - - "~>"
110
+ - - ~>
105
111
  - !ruby/object:Gem::Version
106
112
  version: '1.2'
107
113
  type: :runtime
108
114
  prerelease: false
109
115
  version_requirements: !ruby/object:Gem::Requirement
110
116
  requirements:
111
- - - "~>"
117
+ - - ~>
112
118
  - !ruby/object:Gem::Version
113
119
  version: '1.2'
114
120
  - !ruby/object:Gem::Dependency
115
121
  name: json
116
122
  requirement: !ruby/object:Gem::Requirement
117
123
  requirements:
118
- - - "~>"
124
+ - - ~>
119
125
  - !ruby/object:Gem::Version
120
126
  version: 1.8.2
121
127
  type: :runtime
122
128
  prerelease: false
123
129
  version_requirements: !ruby/object:Gem::Requirement
124
130
  requirements:
125
- - - "~>"
131
+ - - ~>
126
132
  - !ruby/object:Gem::Version
127
133
  version: 1.8.2
128
134
  description: A tool for launching and bootstrapping EC2 instances
@@ -134,8 +140,8 @@ executables:
134
140
  extensions: []
135
141
  extra_rdoc_files: []
136
142
  files:
137
- - ".gitignore"
138
- - ".travis.yml"
143
+ - .gitignore
144
+ - .travis.yml
139
145
  - CHANGELOG.md
140
146
  - Gemfile
141
147
  - LICENSE.txt
@@ -196,17 +202,17 @@ require_paths:
196
202
  - lib
197
203
  required_ruby_version: !ruby/object:Gem::Requirement
198
204
  requirements:
199
- - - ">="
205
+ - - ! '>='
200
206
  - !ruby/object:Gem::Version
201
207
  version: '0'
202
208
  required_rubygems_version: !ruby/object:Gem::Requirement
203
209
  requirements:
204
- - - ">="
210
+ - - ! '>='
205
211
  - !ruby/object:Gem::Version
206
212
  version: '0'
207
213
  requirements: []
208
214
  rubyforge_project:
209
- rubygems_version: 2.4.8
215
+ rubygems_version: 2.4.1
210
216
  signing_key:
211
217
  specification_version: 4
212
218
  summary: no summary