stemcell 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/stemcell/launcher.rb +2 -1
- data/lib/stemcell/metadata_source/configuration.rb +2 -2
- data/lib/stemcell/metadata_source.rb +6 -1
- data/lib/stemcell/templates/bootstrap.sh.erb +91 -20
- data/lib/stemcell/version.rb +1 -1
- data/spec/fixtures/chef_repo/stemcell-azs-missing.json +3 -1
- data/spec/fixtures/chef_repo/stemcell-backing-store-legacy.json +13 -0
- data/spec/fixtures/chef_repo/stemcell-cookbook-attribute.json +3 -1
- data/spec/fixtures/chef_repo/stemcell-defaults-missing.json +3 -1
- data/spec/fixtures/chef_repo/stemcell-options-parser.json +6 -2
- data/spec/fixtures/chef_repo/stemcell.json +3 -1
- data/spec/lib/stemcell/metadata_source/configuration_spec.rb +16 -3
- data/spec/lib/stemcell/metadata_source_spec.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0311d6f13f75e1e7e52496b9491eb5768c13eb35
|
4
|
+
data.tar.gz: 67d5f0c43c6fbc5a81139ff8773a82027bd4fd99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d0e45ae07c7c9995d1c11198b0c6ba9991bc1e71e38fcdc6abf5e460ba91abcb52c45b27142c31b3a282738a86b8e53a3522be13f89e71c4b8f22229b2c8cbf
|
7
|
+
data.tar.gz: 27fc12f639c4b446edd1439e28d82d3dd078c807bbb2206f21b49fd73af1809d4543b86f6d3477ceaa797d4c93b0ce68d02d7038416a9b462e022bd8a3ffab10
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.12.1
|
2
|
+
- Add support for Amazon Linux to the default bootstrap script
|
3
|
+
- Allow setting backing_store options per region
|
4
|
+
- Display private ip for launched instances
|
5
|
+
|
1
6
|
# 0.12.0
|
2
7
|
- Require Nokogiri ~> 1.8.2 due to vulnerability CVE-2017-15412
|
3
8
|
- Require ruby version >= 2.1 for Nokogiri compatibility
|
data/lib/stemcell/launcher.rb
CHANGED
@@ -258,7 +258,8 @@ module Stemcell
|
|
258
258
|
puts "\nhere is the info for what's launched:"
|
259
259
|
instances.each do |instance|
|
260
260
|
puts "\tinstance_id: #{instance.instance_id}"
|
261
|
-
puts "\tpublic ip: #{instance.public_ip_address}"
|
261
|
+
puts "\tpublic ip: #{instance.public_ip_address || 'none'}"
|
262
|
+
puts "\tprivate ip: #{instance.private_ip_address || 'none'}"
|
262
263
|
puts
|
263
264
|
end
|
264
265
|
puts "install logs will be in /var/log/init and /var/log/init.err"
|
@@ -21,10 +21,10 @@ module Stemcell
|
|
21
21
|
validate_configutation
|
22
22
|
end
|
23
23
|
|
24
|
-
def options_for_backing_store(backing_store)
|
24
|
+
def options_for_backing_store(backing_store, region)
|
25
25
|
options = backing_store_options[backing_store]
|
26
26
|
raise UnknownBackingStoreError.new(backing_store) if options.nil?
|
27
|
-
options
|
27
|
+
options.fetch(region, options)
|
28
28
|
end
|
29
29
|
|
30
30
|
def random_az_for_region(region)
|
@@ -84,9 +84,14 @@ module Stemcell
|
|
84
84
|
backing_store ||= config.default_options['backing_store']
|
85
85
|
backing_store ||= DEFAULT_BACKING_STORE
|
86
86
|
|
87
|
+
backing_store_region = override_options['region']
|
88
|
+
backing_store_region ||= role_options.to_hash['region'] if role_options
|
89
|
+
backing_store_region ||= config.default_options['region']
|
90
|
+
backing_store_region ||= DEFAULT_OPTIONS['region']
|
91
|
+
|
87
92
|
# Step 3: Retrieve the backing store options from the defaults.
|
88
93
|
|
89
|
-
backing_store_options = config.options_for_backing_store(backing_store)
|
94
|
+
backing_store_options = config.options_for_backing_store(backing_store, backing_store_region)
|
90
95
|
backing_store_options['backing_store'] = backing_store
|
91
96
|
|
92
97
|
# Step 4: Merge the options together in priority order.
|
@@ -54,16 +54,33 @@ encrypted_data_bag_secret_path='<%= opts['chef_data_bag_secret_path'].to_s %>'
|
|
54
54
|
##
|
55
55
|
|
56
56
|
update() {
|
57
|
-
echo updating
|
58
|
-
|
57
|
+
echo updating repository metadata
|
58
|
+
|
59
|
+
case $OS_PACKAGE_MANAGER in
|
60
|
+
apt)
|
61
|
+
apt-get update 1>&2
|
62
|
+
;;
|
63
|
+
yum)
|
64
|
+
# yum install will check if metadata needs to be updated
|
65
|
+
# so it's just for consistency with apt-based distros
|
66
|
+
yum check-update 1>&2 || true
|
67
|
+
;;
|
68
|
+
esac
|
59
69
|
}
|
60
70
|
|
61
71
|
install() {
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
case $OS_PACKAGE_MANAGER in
|
73
|
+
apt)
|
74
|
+
if ! (dpkg -l | awk '{print $2}' | grep -q ^$1$ ) ; then
|
75
|
+
echo installing $1...
|
76
|
+
export DEBIAN_FRONTEND=noninteractive
|
77
|
+
apt-get install -y $1 1>&2
|
78
|
+
fi
|
79
|
+
;;
|
80
|
+
yum)
|
81
|
+
rpm -q $1 2>&1 >/dev/null || yum install -y $1
|
82
|
+
;;
|
83
|
+
esac
|
67
84
|
}
|
68
85
|
|
69
86
|
set_hostname() {
|
@@ -86,22 +103,34 @@ set_hostname() {
|
|
86
103
|
echo "$local_ip $fqdn $hostname" >> /etc/hosts
|
87
104
|
}
|
88
105
|
|
106
|
+
download_chef_package() {
|
107
|
+
echo "Downloading chef from $1"
|
108
|
+
wget "$1" -O "$2" --progress=dot:mega --tries=15 --retry-connrefused --timeout=5 --wait=10 --random-wait --continue --no-dns-cache
|
109
|
+
}
|
110
|
+
|
89
111
|
install_chef() {
|
112
|
+
package_local="/tmp/chef_${chef_version}.${OS_PACKAGE_EXT}"
|
113
|
+
package_url="$(render_chef_url)"
|
114
|
+
|
90
115
|
# check to see if chef is already installed
|
91
116
|
if ! which chef-solo > /dev/null ; then
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
117
|
+
case $OS_PACKAGE_MANAGER in
|
118
|
+
apt)
|
119
|
+
download_chef_package "$package_url" "$package_local"
|
120
|
+
echo "Installing chef $chef_version"
|
121
|
+
dpkg -i $package_local
|
122
|
+
;;
|
123
|
+
yum)
|
124
|
+
download_chef_package "$package_url" "$package_local"
|
125
|
+
echo "Installing chef $chef_version"
|
126
|
+
rpm -ivh "$package_local"
|
127
|
+
;;
|
128
|
+
esac
|
102
129
|
else
|
103
130
|
echo chef is already installed
|
104
131
|
fi
|
132
|
+
|
133
|
+
rm -f $package_local
|
105
134
|
}
|
106
135
|
|
107
136
|
create_ohai_hint() {
|
@@ -154,7 +183,6 @@ cookbook_path ["#{repo_dir}/site-cookbooks", "#{repo_dir}/cookbooks"]
|
|
154
183
|
role_path "#{repo_dir}/roles"
|
155
184
|
data_bag_path "#{repo_dir}/data_bags"
|
156
185
|
ohai.plugin_path << "#{repo_dir}/ohai_plugins"
|
157
|
-
|
158
186
|
ssl_verify_mode :verify_peer
|
159
187
|
log_level :info
|
160
188
|
log_location STDOUT
|
@@ -199,7 +227,7 @@ git reset --hard origin/\${branch}
|
|
199
227
|
git clean -fdx
|
200
228
|
|
201
229
|
json="{\"role\": \"\${role}\", \"env\": \"\${env}\", \"branch\": \"\${branch}\"}"
|
202
|
-
json_file=\`
|
230
|
+
json_file=\`mktemp\`
|
203
231
|
echo \$json > \$json_file
|
204
232
|
trap "{ rm -f '\$json_file' ; }" EXIT
|
205
233
|
|
@@ -237,12 +265,55 @@ run_chef() {
|
|
237
265
|
set -e
|
238
266
|
}
|
239
267
|
|
268
|
+
render_chef_url() {
|
269
|
+
base_url="<%= opts['chef_package_source'] %>"
|
270
|
+
echo $base_url | sed \
|
271
|
+
-e "s/%{platform}/$OS_PLATFORM/g" \
|
272
|
+
-e "s/%{platform_version}/$OS_PLATFORM_VERSION/g" \
|
273
|
+
-e "s/%{chef_version}/$chef_version/g" \
|
274
|
+
-e "s/%{package_manager}/$OS_PACKAGE_MANAGER/g" \
|
275
|
+
-e "s/%{package_arch}/$OS_PACKAGE_ARCH/g" \
|
276
|
+
-e "s/%{package_ext}/$OS_PACKAGE_EXT/g"
|
277
|
+
}
|
278
|
+
|
279
|
+
check_os_version() {
|
280
|
+
NAME=unsupported
|
281
|
+
|
282
|
+
if [ -f /etc/os-release ]; then
|
283
|
+
. /etc/os-release
|
284
|
+
fi
|
285
|
+
|
286
|
+
case "$NAME" in
|
287
|
+
"Ubuntu")
|
288
|
+
OS_VERSION="$NAME $VERSION_ID"
|
289
|
+
OS_PLATFORM=ubuntu
|
290
|
+
OS_PLATFORM_VERSION=$VERSION_ID
|
291
|
+
OS_PACKAGE_MANAGER=apt
|
292
|
+
OS_PACKAGE_ARCH=$(dpkg --print-architecture)
|
293
|
+
OS_PACKAGE_EXT=deb
|
294
|
+
;;
|
295
|
+
"Amazon Linux")
|
296
|
+
OS_VERSION="$NAME $VERSION_ID"
|
297
|
+
OS_PLATFORM=amazon
|
298
|
+
OS_PLATFORM_VERSION=$VERSION_ID
|
299
|
+
OS_PACKAGE_MANAGER=yum
|
300
|
+
OS_PACKAGE_ARCH=$(uname -m)
|
301
|
+
OS_PACKAGE_EXT=rpm
|
302
|
+
;;
|
303
|
+
*)
|
304
|
+
echo "Unsupported operating system"
|
305
|
+
exit 1
|
306
|
+
;;
|
307
|
+
esac
|
308
|
+
}
|
240
309
|
|
241
310
|
##
|
242
311
|
## main
|
243
312
|
##
|
244
313
|
|
245
|
-
|
314
|
+
check_os_version
|
315
|
+
|
316
|
+
echo "starting chef bootstrapping on ${OS_VERSION}..."
|
246
317
|
update
|
247
318
|
install curl
|
248
319
|
install git
|
data/lib/stemcell/version.rb
CHANGED
@@ -32,7 +32,9 @@ describe Stemcell::MetadataSource::Configuration do
|
|
32
32
|
it "sets backing_store_options" do
|
33
33
|
expect(config.backing_store_options).to eql({
|
34
34
|
'instance_store' => {
|
35
|
-
'
|
35
|
+
'us-east-1' => {
|
36
|
+
'image_id' => 'ami-d9d6a6b0'
|
37
|
+
}
|
36
38
|
}
|
37
39
|
})
|
38
40
|
end
|
@@ -86,10 +88,11 @@ describe Stemcell::MetadataSource::Configuration do
|
|
86
88
|
|
87
89
|
describe '#options_for_backing_store' do
|
88
90
|
let(:backing_store) { 'instance_store' }
|
91
|
+
let(:region) { 'us-east-1' }
|
89
92
|
|
90
93
|
context "when the backing store definition exists" do
|
91
94
|
it "returns the options" do
|
92
|
-
expect(config.options_for_backing_store(backing_store)).to eql({
|
95
|
+
expect(config.options_for_backing_store(backing_store, region)).to eql({
|
93
96
|
'image_id' => 'ami-d9d6a6b0'
|
94
97
|
})
|
95
98
|
end
|
@@ -97,13 +100,23 @@ describe Stemcell::MetadataSource::Configuration do
|
|
97
100
|
|
98
101
|
context "when the backing store isn't defined" do
|
99
102
|
let(:backing_store) { 'nyanstore' }
|
103
|
+
let(:region) { 'us-east-1' }
|
100
104
|
it "raises" do
|
101
|
-
expect { config.options_for_backing_store(backing_store) }.to raise_error(
|
105
|
+
expect { config.options_for_backing_store(backing_store, region) }.to raise_error(
|
102
106
|
Stemcell::UnknownBackingStoreError
|
103
107
|
)
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
111
|
+
context "when the legacy backing store definition exists" do
|
112
|
+
let(:config_filename) { 'stemcell-backing-store-legacy.json' }
|
113
|
+
it "returns the options" do
|
114
|
+
expect(config.options_for_backing_store(backing_store, region)).to eql({
|
115
|
+
'image_id' => 'ami-d9d6a6b0'
|
116
|
+
})
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
107
120
|
end
|
108
121
|
|
109
122
|
describe '#random_az_in_region' do
|
@@ -161,7 +161,8 @@ describe Stemcell::MetadataSource do
|
|
161
161
|
it "calls the config object to retrieve the backing store options" do
|
162
162
|
backing_options.merge!('image_id' => 'ami-nyancat')
|
163
163
|
override_options.merge!('backing_store' => 'ebs')
|
164
|
-
|
164
|
+
override_options.merge!('region' => 'us-east-1')
|
165
|
+
expect(config).to receive(:options_for_backing_store).with('ebs', 'us-east-1') { backing_options }
|
165
166
|
expect(expansion['image_id']).to eql 'ami-nyancat'
|
166
167
|
end
|
167
168
|
|
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.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Rhoads
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: aws-sdk-v1
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- spec/fixtures/chef_repo/roles/unit-simple-override.rb
|
208
208
|
- spec/fixtures/chef_repo/stemcell-azs-missing.json
|
209
209
|
- spec/fixtures/chef_repo/stemcell-backing-store-empty.json
|
210
|
+
- spec/fixtures/chef_repo/stemcell-backing-store-legacy.json
|
210
211
|
- spec/fixtures/chef_repo/stemcell-backing-store-missing.json
|
211
212
|
- spec/fixtures/chef_repo/stemcell-cookbook-attribute.json
|
212
213
|
- spec/fixtures/chef_repo/stemcell-defaults-missing.json
|
@@ -241,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
242
|
version: '0'
|
242
243
|
requirements: []
|
243
244
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.5.2
|
245
|
+
rubygems_version: 2.5.2.3
|
245
246
|
signing_key:
|
246
247
|
specification_version: 4
|
247
248
|
summary: no summary
|
@@ -268,6 +269,7 @@ test_files:
|
|
268
269
|
- spec/fixtures/chef_repo/roles/unit-simple-override.rb
|
269
270
|
- spec/fixtures/chef_repo/stemcell-azs-missing.json
|
270
271
|
- spec/fixtures/chef_repo/stemcell-backing-store-empty.json
|
272
|
+
- spec/fixtures/chef_repo/stemcell-backing-store-legacy.json
|
271
273
|
- spec/fixtures/chef_repo/stemcell-backing-store-missing.json
|
272
274
|
- spec/fixtures/chef_repo/stemcell-cookbook-attribute.json
|
273
275
|
- spec/fixtures/chef_repo/stemcell-defaults-missing.json
|