builderator 1.0.0.pre.rc.11 → 1.0.0.pre.rc.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -13
- data/VERSION +1 -1
- data/docs/versioning.md +1 -1
- data/lib/builderator/interface/packer.rb +8 -1
- data/lib/builderator/tasks.rb +3 -1
- data/lib/builderator/tasks/packer.rb +108 -0
- data/lib/builderator/tasks/vagrant.rb +2 -0
- data/lib/builderator/util.rb +8 -4
- data/template/Vagrantfile.erb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2184d9659c752e4065a951a7595f97100ee3c2a
|
4
|
+
data.tar.gz: d9a1df4bacc66c29925fa806a09a60a2994aa848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cafe2ac4672a9a9abeca0512fd083993d0df5c7ab425bda592e25b1e3c3f930d1f2a48bc6be7dff90878a8a0b07d632314f7b5573114250fa3657880d85b17b
|
7
|
+
data.tar.gz: 316460b33e0eb304a4e974282e4305a0a1239b9b8e36d3c4cedb35fe37399b79a604c0ccf06428871a392dc9169a0259e18db610572c8e7d5cfc068a8c287f32
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
builderator (1.0.0.pre.rc.
|
4
|
+
builderator (1.0.0.pre.rc.11)
|
5
5
|
aws-sdk (~> 2.0)
|
6
6
|
berkshelf (~> 3.2)
|
7
7
|
chef (~> 12.0)
|
@@ -16,12 +16,12 @@ GEM
|
|
16
16
|
ast (2.1.0)
|
17
17
|
astrolabe (1.3.1)
|
18
18
|
parser (~> 2.2)
|
19
|
-
aws-sdk (2.2.
|
20
|
-
aws-sdk-resources (= 2.2.
|
21
|
-
aws-sdk-core (2.2.
|
19
|
+
aws-sdk (2.2.26)
|
20
|
+
aws-sdk-resources (= 2.2.26)
|
21
|
+
aws-sdk-core (2.2.26)
|
22
22
|
jmespath (~> 1.0)
|
23
|
-
aws-sdk-resources (2.2.
|
24
|
-
aws-sdk-core (= 2.2.
|
23
|
+
aws-sdk-resources (2.2.26)
|
24
|
+
aws-sdk-core (= 2.2.26)
|
25
25
|
berkshelf (3.3.0)
|
26
26
|
addressable (~> 2.3.4)
|
27
27
|
berkshelf-api-client (~> 1.2)
|
@@ -56,8 +56,9 @@ GEM
|
|
56
56
|
celluloid-io (0.16.2)
|
57
57
|
celluloid (>= 0.16.0)
|
58
58
|
nio4r (>= 1.1.0)
|
59
|
-
chef (12.
|
60
|
-
|
59
|
+
chef (12.8.1)
|
60
|
+
bundler (>= 1.10)
|
61
|
+
chef-config (= 12.8.1)
|
61
62
|
chef-zero (~> 4.5)
|
62
63
|
diff-lcs (~> 1.2, >= 1.2.4)
|
63
64
|
erubis (~> 2.7)
|
@@ -80,7 +81,7 @@ GEM
|
|
80
81
|
specinfra (~> 2.10)
|
81
82
|
syslog-logger (~> 1.6)
|
82
83
|
uuidtools (~> 2.1.5)
|
83
|
-
chef-config (12.
|
84
|
+
chef-config (12.8.1)
|
84
85
|
mixlib-config (~> 2.0)
|
85
86
|
mixlib-shellout (~> 2.0)
|
86
87
|
chef-zero (4.5.0)
|
@@ -136,7 +137,7 @@ GEM
|
|
136
137
|
nio4r (1.2.1)
|
137
138
|
octokit (3.8.0)
|
138
139
|
sawyer (~> 0.6.0, >= 0.5.3)
|
139
|
-
ohai (8.
|
140
|
+
ohai (8.12.0)
|
140
141
|
chef-config (>= 12.5.0.alpha.1, < 13)
|
141
142
|
ffi (~> 1.9)
|
142
143
|
ffi-yajl (~> 2.2)
|
@@ -145,6 +146,7 @@ GEM
|
|
145
146
|
mixlib-config (~> 2.0)
|
146
147
|
mixlib-log
|
147
148
|
mixlib-shellout (~> 2.0)
|
149
|
+
plist
|
148
150
|
rake (~> 10.1)
|
149
151
|
systemu (~> 2.6.4)
|
150
152
|
wmi-lite (~> 1.0)
|
@@ -206,16 +208,16 @@ GEM
|
|
206
208
|
addressable (~> 2.3.5)
|
207
209
|
faraday (~> 0.8, < 0.10)
|
208
210
|
semverse (1.2.1)
|
209
|
-
serverspec (2.
|
211
|
+
serverspec (2.31.0)
|
210
212
|
multi_json
|
211
213
|
rspec (~> 3.0)
|
212
214
|
rspec-its
|
213
|
-
specinfra (~> 2.
|
215
|
+
specinfra (~> 2.53)
|
214
216
|
sfl (2.2)
|
215
217
|
solve (1.2.1)
|
216
218
|
dep_selector (~> 1.0)
|
217
219
|
semverse (~> 1.1)
|
218
|
-
specinfra (2.53.
|
220
|
+
specinfra (2.53.1)
|
219
221
|
net-scp
|
220
222
|
net-ssh (>= 2.7, < 3.1)
|
221
223
|
net-telnet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0-rc.
|
1
|
+
1.0.0-rc.12
|
data/docs/versioning.md
CHANGED
@@ -53,7 +53,7 @@ SCM providers must extend the `Builderator::Control::Version::SCM` module, and m
|
|
53
53
|
- `:tags` `nil` or an array of semver strings
|
54
54
|
* `self.supported?` Return `true` if the provider supports the build environment (e.g. the `Git` provider checks that `pwd` is a git repository), else return `false`.
|
55
55
|
|
56
|
-
To enable a provider module, pass it to `SCM.register`. See [blob/auto-version/lib/builderator/control/version/git.rb
|
56
|
+
To enable a provider module, pass it to `SCM.register`. See [Builderator::Control::Version::Git](blob/auto-version/lib/builderator/control/version/git.rb) for an example.
|
57
57
|
|
58
58
|
## This looks like `thor-scmversion`
|
59
59
|
|
@@ -24,9 +24,16 @@ module Builderator
|
|
24
24
|
:provisioners => []
|
25
25
|
}.tap do |json|
|
26
26
|
Config.profile.current.packer.build.each do |_, build|
|
27
|
-
|
27
|
+
build_hash = build.to_hash.tap do |b|
|
28
28
|
b[:tags] = Config.profile.current.tags
|
29
29
|
end
|
30
|
+
|
31
|
+
## Support is missing for several regions in some versions of Packer
|
32
|
+
# Moving this functionality into a task until we can confirm that Packer
|
33
|
+
# has full support again.
|
34
|
+
build_hash.delete(:ami_regions)
|
35
|
+
|
36
|
+
json[:builders] << build_hash
|
30
37
|
end
|
31
38
|
|
32
39
|
## Initialize the staging directory
|
data/lib/builderator/tasks.rb
CHANGED
@@ -86,8 +86,10 @@ module Builderator
|
|
86
86
|
# Helper/utility commands
|
87
87
|
##
|
88
88
|
desc 'config', 'Print compiled configuration'
|
89
|
-
def config
|
89
|
+
def config(key = nil)
|
90
90
|
invoke Tasks::Version, :current, [], options
|
91
|
+
|
92
|
+
return puts Config.compiled.send(key).to_json unless key.nil?
|
91
93
|
puts Config.compiled.to_json
|
92
94
|
end
|
93
95
|
|
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'aws-sdk'
|
1
2
|
require 'thor'
|
2
3
|
|
4
|
+
require_relative '../control/data'
|
3
5
|
require_relative '../interface/packer'
|
4
6
|
require_relative '../patch/thor-actions'
|
5
7
|
|
@@ -20,6 +22,8 @@ module Builderator
|
|
20
22
|
desc 'configure [PROFILE=default]', 'Generate a packer configuration'
|
21
23
|
def configure(profile = :default)
|
22
24
|
Config.profile.use(profile)
|
25
|
+
|
26
|
+
invoke Tasks::Version, :current, [], options
|
23
27
|
puts Interface.packer.render if options['debug']
|
24
28
|
end
|
25
29
|
|
@@ -28,6 +32,110 @@ module Builderator
|
|
28
32
|
invoke :configure, [profile], options
|
29
33
|
run_with_input "#{Interface.packer.command} build - #{ args.join('') }", Interface.packer.render
|
30
34
|
end
|
35
|
+
|
36
|
+
desc 'copy PROFILE', 'Copy AMIs generated by packer to other regions'
|
37
|
+
def copy(profile)
|
38
|
+
invoke :configure, [profile], options
|
39
|
+
|
40
|
+
images.each do |image_name, (image, build)|
|
41
|
+
parameters = {
|
42
|
+
:source_region => Config.aws.region,
|
43
|
+
:source_image_id => image.image_id,
|
44
|
+
:name => image_name,
|
45
|
+
:description => image.description
|
46
|
+
}
|
47
|
+
|
48
|
+
build.ami_regions.each do |region|
|
49
|
+
say_status :copy, "image #{image_name} (#{image.image_id}) from #{Config.aws.region} to #{region}"
|
50
|
+
Util.ec2(region).copy_image(parameters)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
invoke :wait, [profile], options
|
55
|
+
invoke :tag, [profile], options
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'tag PROFILE', 'Tag AMIs in other regions'
|
59
|
+
def tag(profile)
|
60
|
+
invoke :configure, [profile], options
|
61
|
+
|
62
|
+
images.each do |image_name, (image, build)|
|
63
|
+
filters = [{
|
64
|
+
:name => 'name',
|
65
|
+
:values => [image_name]
|
66
|
+
}]
|
67
|
+
|
68
|
+
## Add some additional tags about the regional source
|
69
|
+
image.tags << {
|
70
|
+
:key => 'source_region',
|
71
|
+
:value => Config.aws.region
|
72
|
+
}
|
73
|
+
image.tags << {
|
74
|
+
:key => 'source_ami',
|
75
|
+
:value => image.image_id
|
76
|
+
}
|
77
|
+
|
78
|
+
build.ami_regions.each do |region|
|
79
|
+
regional_image = Util.ec2(region).describe_images(:filters => filters).images.first
|
80
|
+
|
81
|
+
say_status :tag, "AMI #{image_name} (#{regional_image.image_id}) in #{region}"
|
82
|
+
Util.ec2(region).create_tags(:resources => [regional_image.image_id], :tags => image.tags)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'wait PROFILE', 'Wait for copied AMIs to become available in another region'
|
88
|
+
def wait(profile)
|
89
|
+
invoke :configure, [profile], options
|
90
|
+
|
91
|
+
waiting = true
|
92
|
+
|
93
|
+
images.each do |image_name, (image, build)|
|
94
|
+
say_status :wait, "for #{image.image_id} (#{image_name}) to be available in #{build.ami_regions.join(', ')}", :yellow
|
95
|
+
end
|
96
|
+
|
97
|
+
while waiting
|
98
|
+
waiting = false
|
99
|
+
|
100
|
+
images.each do |image_name, (image, build)|
|
101
|
+
filters = [{
|
102
|
+
:name => 'name',
|
103
|
+
:values => [image_name]
|
104
|
+
}]
|
105
|
+
|
106
|
+
build.ami_regions.each do |region|
|
107
|
+
regional_image = Util.ec2(region).describe_images(:filters => filters).images.first
|
108
|
+
|
109
|
+
## It takes a few seconds for the new AMI to show up in the `describe_images` response-set
|
110
|
+
state = regional_image.nil? ? 'unknown' : regional_image.state
|
111
|
+
image_id = regional_image.nil? ? 'unknown' : regional_image.image_id
|
112
|
+
|
113
|
+
waiting = (state != 'available') || waiting
|
114
|
+
status_color = case state
|
115
|
+
when 'pending', 'unknown' then :yellow
|
116
|
+
when 'available' then :green
|
117
|
+
else :red
|
118
|
+
end
|
119
|
+
|
120
|
+
say_status :image, "#{image_id} (#{image.name}) is #{state} in #{region}", status_color
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
## If waiting == false, loop immediately to break
|
125
|
+
sleep(10) if waiting
|
126
|
+
end
|
127
|
+
|
128
|
+
say_status :complete, 'All copied images are available'
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
## Find details for generated images in current region
|
134
|
+
def images
|
135
|
+
@images ||= Config.profile.current.packer.build.each_with_object({}) do |(_, build), memo|
|
136
|
+
memo[build.ami_name] = [Control::Data.lookup(:image, :name => build.ami_name).first, build]
|
137
|
+
end
|
138
|
+
end
|
31
139
|
end
|
32
140
|
end
|
33
141
|
end
|
data/lib/builderator/util.rb
CHANGED
@@ -60,16 +60,20 @@ module Builderator
|
|
60
60
|
##
|
61
61
|
# AWS Clients
|
62
62
|
##
|
63
|
-
def ec2
|
64
|
-
|
63
|
+
def ec2(region = Config.aws.region)
|
64
|
+
clients["ec2-#{region}"] ||= Aws::EC2::Client.new(:region => region)
|
65
65
|
end
|
66
66
|
|
67
|
-
def asg
|
68
|
-
|
67
|
+
def asg(region = Config.aws.region)
|
68
|
+
clients["asg-#{region}"] ||= Aws::AutoScaling::Client.new(:region => region)
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
|
+
def clients
|
74
|
+
@clients ||= {}
|
75
|
+
end
|
76
|
+
|
73
77
|
def _filter_reduce(resource, filters)
|
74
78
|
filters.reduce(true) do |memo, (k, v)|
|
75
79
|
## Allow for negation with a leading `~`
|
data/template/Vagrantfile.erb
CHANGED
@@ -41,7 +41,8 @@ Vagrant.configure('2') do |config|
|
|
41
41
|
# Use the standard data directory for Chef
|
42
42
|
##
|
43
43
|
config.vm.provision :shell,
|
44
|
-
:inline =>
|
44
|
+
:inline => "sudo mkdir -p #{Config.chef.staging_directory}/cache && "\
|
45
|
+
"sudo chown $(whoami) -R #{Config.chef.staging_directory}",
|
45
46
|
:privileged => true
|
46
47
|
|
47
48
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: builderator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.rc.
|
4
|
+
version: 1.0.0.pre.rc.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|