caterer 0.11.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +34 -116
- data/Vagrantfile +4 -4
- data/lib/caterer.rb +3 -0
- data/lib/caterer/action.rb +1 -0
- data/lib/caterer/action/berkshelf/install.rb +3 -1
- data/lib/caterer/action/config/validate/provisioner.rb +16 -10
- data/lib/caterer/action/image.rb +9 -0
- data/lib/caterer/action/image/cleanup.rb +20 -0
- data/lib/caterer/action/image/prepare.rb +20 -0
- data/lib/caterer/action/image/run.rb +20 -0
- data/lib/caterer/action/provisioner.rb +0 -7
- data/lib/caterer/action/provisioner/cleanup.rb +19 -1
- data/lib/caterer/action/provisioner/prepare.rb +20 -2
- data/lib/caterer/action/provisioner/uninstall.rb +9 -1
- data/lib/caterer/action/server.rb +2 -1
- data/lib/caterer/action/{provisioner/install.rb → server/cleanup.rb} +5 -5
- data/lib/caterer/action/server/{reboot.rb → prepare.rb} +4 -2
- data/lib/caterer/actions.rb +8 -46
- data/lib/caterer/cli.rb +50 -4
- data/lib/caterer/command.rb +1 -4
- data/lib/caterer/command/base.rb +17 -108
- data/lib/caterer/command/berks.rb +5 -8
- data/lib/caterer/command/clean.rb +6 -4
- data/lib/caterer/command/lock.rb +5 -3
- data/lib/caterer/command/provision.rb +19 -4
- data/lib/caterer/command/server.rb +106 -0
- data/lib/caterer/command/unlock.rb +5 -3
- data/lib/caterer/commands.rb +0 -3
- data/lib/caterer/config.rb +0 -5
- data/lib/caterer/config/base.rb +5 -4
- data/lib/caterer/config/provisioner/chef_solo.rb +1 -2
- data/lib/caterer/group.rb +24 -0
- data/lib/caterer/image.rb +88 -0
- data/lib/caterer/member.rb +13 -0
- data/lib/caterer/provisioner.rb +1 -0
- data/lib/caterer/provisioner/base.rb +4 -3
- data/lib/caterer/provisioner/chef_solo.rb +58 -123
- data/lib/caterer/provisioner/shell.rb +83 -0
- data/lib/caterer/provisioners.rb +2 -1
- data/lib/caterer/server.rb +18 -36
- data/lib/caterer/version.rb +1 -1
- data/lib/templates/image/bin_wrapper.erb +8 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/debian.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/el.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/fedora.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/sles.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/smartos.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/suse.sh +0 -0
- data/lib/templates/provisioner/chef_solo/{bootstrap → install}/ubuntu.sh +0 -0
- data/lib/templates/provisioner/chef_solo/solo.erb +1 -1
- data/lib/templates/provisioner/shell/script.erb +3 -0
- metadata +24 -26
- data/lib/caterer/action/provisioner/bootstrap.rb +0 -14
- data/lib/caterer/action/provisioner/load.rb +0 -29
- data/lib/caterer/action/provisioner/provision.rb +0 -14
- data/lib/caterer/action/provisioner/validate.rb +0 -10
- data/lib/caterer/action/provisioner/validate/bootstrapped.rb +0 -22
- data/lib/caterer/action/provisioner/validate/engine.rb +0 -24
- data/lib/caterer/command/bootstrap.rb +0 -24
- data/lib/caterer/command/reboot.rb +0 -24
- data/lib/caterer/command/test.rb +0 -19
- data/lib/caterer/command/up.rb +0 -24
- data/lib/caterer/config/group.rb +0 -26
- data/lib/caterer/config/image.rb +0 -21
- data/lib/caterer/config/member.rb +0 -15
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'tilt'
|
3
|
+
require 'erubis'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
module Caterer
|
7
|
+
module Provisioner
|
8
|
+
class Shell < Base
|
9
|
+
|
10
|
+
attr_accessor :path, :inline, :args
|
11
|
+
|
12
|
+
def initialize(image, opts={})
|
13
|
+
@image = image
|
14
|
+
@path = opts[:path] if opts[:path]
|
15
|
+
@inline = opts[:inline] if opts[:inline]
|
16
|
+
@args = opts[:args] if opts[:args]
|
17
|
+
end
|
18
|
+
|
19
|
+
# config dsl
|
20
|
+
|
21
|
+
def path(path)
|
22
|
+
@path = path
|
23
|
+
end
|
24
|
+
|
25
|
+
def inline(inline)
|
26
|
+
@inline = inline
|
27
|
+
end
|
28
|
+
|
29
|
+
def args(args)
|
30
|
+
@args = args
|
31
|
+
end
|
32
|
+
|
33
|
+
def errors
|
34
|
+
errors = {}
|
35
|
+
|
36
|
+
if not @path and not @inline
|
37
|
+
errors[:action] = "cannot be determined. Please set 'inline' or 'script'"
|
38
|
+
end
|
39
|
+
|
40
|
+
if errors.length > 0
|
41
|
+
errors
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare(server)
|
47
|
+
# create lib dir
|
48
|
+
server.ssh.sudo "mkdir -p #{dest_lib_dir}", :stream => true
|
49
|
+
server.ssh.sudo "chown -R #{server.username} #{dest_lib_dir}", :stream => true
|
50
|
+
|
51
|
+
# create script
|
52
|
+
server.ui.info "Generating shell script..."
|
53
|
+
server.ssh.upload(StringIO.new(script_content), dest_script_path)
|
54
|
+
server.ssh.sudo "chmod +x #{dest_script_path}", :stream => true
|
55
|
+
end
|
56
|
+
|
57
|
+
def provision_cmd
|
58
|
+
"#{dest_script_path} #{@args}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def dest_lib_dir
|
62
|
+
"#{image.lib_dir}/shell"
|
63
|
+
end
|
64
|
+
|
65
|
+
def dest_script_path
|
66
|
+
"#{dest_lib_dir}/#{uuid}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def uuid
|
70
|
+
@uuid ||= ::Digest::MD5.hexdigest((@inline or @path))
|
71
|
+
end
|
72
|
+
|
73
|
+
def script_content
|
74
|
+
if @inline
|
75
|
+
Tilt.new(File.expand_path('../../../templates/provisioner/shell/script.erb', __FILE__)).render(self)
|
76
|
+
else
|
77
|
+
File.read @path
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/caterer/provisioners.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
Caterer.provisioners.register(:chef_solo) { Caterer::Provisioner::ChefSolo }
|
1
|
+
Caterer.provisioners.register(:chef_solo) { Caterer::Provisioner::ChefSolo }
|
2
|
+
Caterer.provisioners.register(:shell) { Caterer::Provisioner::Shell }
|
data/lib/caterer/server.rb
CHANGED
@@ -18,25 +18,12 @@ module Caterer
|
|
18
18
|
@key = opts[:key]
|
19
19
|
@images = opts[:images] || []
|
20
20
|
@data = opts[:data] || {}
|
21
|
-
@engine = opts[:engine]
|
22
21
|
|
23
22
|
@logger = Log4r::Logger.new("caterer::server")
|
24
23
|
|
25
24
|
@logger.info("Server: #{opts.inspect}")
|
26
25
|
end
|
27
26
|
|
28
|
-
def bootstrap(opts={})
|
29
|
-
if @images.length > 0
|
30
|
-
@images.each do |i|
|
31
|
-
ui.info "*** Bootstrapping image: #{i} ***"
|
32
|
-
run_action(:bootstrap, opts.merge({:image => i}))
|
33
|
-
end
|
34
|
-
else
|
35
|
-
ui.info "*** Bootstrapping ***"
|
36
|
-
run_action(:bootstrap, opts.merge({:engine => @engine}))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
27
|
def provision(opts={})
|
41
28
|
if @images.length > 0
|
42
29
|
@images.each do |i|
|
@@ -44,27 +31,10 @@ module Caterer
|
|
44
31
|
run_action(:provision, opts.merge({:image => i}))
|
45
32
|
end
|
46
33
|
else
|
47
|
-
ui.
|
48
|
-
run_action(:provision, opts.merge({:engine => @engine}))
|
34
|
+
ui.error "*** No image to provision ***"
|
49
35
|
end
|
50
36
|
end
|
51
37
|
|
52
|
-
def up(opts={})
|
53
|
-
if @images.length > 0
|
54
|
-
@images.each do |i|
|
55
|
-
ui.info "*** Up'ing image: #{i} ***"
|
56
|
-
run_action(:up, opts.merge({:image => i}))
|
57
|
-
end
|
58
|
-
else
|
59
|
-
ui.info "*** Up'ing ***"
|
60
|
-
run_action(:up, opts.merge({:engine => @engine}))
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def reboot(opts={})
|
65
|
-
run_action(:reboot, opts)
|
66
|
-
end
|
67
|
-
|
68
38
|
def lock(opts={})
|
69
39
|
ui.info "*** Locking ***"
|
70
40
|
run_action(:lock, opts)
|
@@ -80,11 +50,6 @@ module Caterer
|
|
80
50
|
run_action(:clean, opts)
|
81
51
|
end
|
82
52
|
|
83
|
-
def reboot!
|
84
|
-
ui.info "Rebooting..."
|
85
|
-
ssh.sudo "shutdown -r now", :stream => true
|
86
|
-
end
|
87
|
-
|
88
53
|
def lock!
|
89
54
|
ui.info "Locking..."
|
90
55
|
ssh.sudo "touch #{lock_path}"
|
@@ -100,6 +65,23 @@ module Caterer
|
|
100
65
|
res == 0 ? true : false
|
101
66
|
end
|
102
67
|
|
68
|
+
def prepare!
|
69
|
+
ui.info "Preparing server..."
|
70
|
+
ssh.sudo "mkdir -p #{config.dest_dir}", :stream => true
|
71
|
+
ssh.sudo "mkdir -p #{config.dest_dir}/lib", :stream => true
|
72
|
+
ssh.sudo "mkdir -p #{config.dest_dir}/bin", :stream => true
|
73
|
+
ssh.sudo "chown -R #{username} #{config.dest_dir}", :stream => true
|
74
|
+
end
|
75
|
+
|
76
|
+
def cleanup!
|
77
|
+
ui.info "Cleaning up server..."
|
78
|
+
ssh.sudo "rm -rf #{config.dest_dir}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def config
|
82
|
+
@config ||= Caterer.config
|
83
|
+
end
|
84
|
+
|
103
85
|
def ssh
|
104
86
|
@ssh ||= Communication::SSH.new(self)
|
105
87
|
end
|
data/lib/caterer/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caterer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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: 2013-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -191,21 +191,19 @@ files:
|
|
191
191
|
- lib/caterer/action/config/validate/provisioner.rb
|
192
192
|
- lib/caterer/action/environment.rb
|
193
193
|
- lib/caterer/action/environment/setup.rb
|
194
|
+
- lib/caterer/action/image.rb
|
195
|
+
- lib/caterer/action/image/cleanup.rb
|
196
|
+
- lib/caterer/action/image/prepare.rb
|
197
|
+
- lib/caterer/action/image/run.rb
|
194
198
|
- lib/caterer/action/provisioner.rb
|
195
|
-
- lib/caterer/action/provisioner/bootstrap.rb
|
196
199
|
- lib/caterer/action/provisioner/cleanup.rb
|
197
|
-
- lib/caterer/action/provisioner/install.rb
|
198
|
-
- lib/caterer/action/provisioner/load.rb
|
199
200
|
- lib/caterer/action/provisioner/prepare.rb
|
200
|
-
- lib/caterer/action/provisioner/provision.rb
|
201
201
|
- lib/caterer/action/provisioner/uninstall.rb
|
202
|
-
- lib/caterer/action/provisioner/validate.rb
|
203
|
-
- lib/caterer/action/provisioner/validate/bootstrapped.rb
|
204
|
-
- lib/caterer/action/provisioner/validate/engine.rb
|
205
202
|
- lib/caterer/action/server.rb
|
203
|
+
- lib/caterer/action/server/cleanup.rb
|
206
204
|
- lib/caterer/action/server/lock.rb
|
207
205
|
- lib/caterer/action/server/platform.rb
|
208
|
-
- lib/caterer/action/server/
|
206
|
+
- lib/caterer/action/server/prepare.rb
|
209
207
|
- lib/caterer/action/server/unlock.rb
|
210
208
|
- lib/caterer/action/server/validate.rb
|
211
209
|
- lib/caterer/action/server/validate/ssh.rb
|
@@ -216,14 +214,11 @@ files:
|
|
216
214
|
- lib/caterer/command.rb
|
217
215
|
- lib/caterer/command/base.rb
|
218
216
|
- lib/caterer/command/berks.rb
|
219
|
-
- lib/caterer/command/bootstrap.rb
|
220
217
|
- lib/caterer/command/clean.rb
|
221
218
|
- lib/caterer/command/lock.rb
|
222
219
|
- lib/caterer/command/provision.rb
|
223
|
-
- lib/caterer/command/
|
224
|
-
- lib/caterer/command/test.rb
|
220
|
+
- lib/caterer/command/server.rb
|
225
221
|
- lib/caterer/command/unlock.rb
|
226
|
-
- lib/caterer/command/up.rb
|
227
222
|
- lib/caterer/commands.rb
|
228
223
|
- lib/caterer/communication.rb
|
229
224
|
- lib/caterer/communication/rsync.rb
|
@@ -231,17 +226,18 @@ files:
|
|
231
226
|
- lib/caterer/config.rb
|
232
227
|
- lib/caterer/config/base.rb
|
233
228
|
- lib/caterer/config/berkshelf.rb
|
234
|
-
- lib/caterer/config/group.rb
|
235
|
-
- lib/caterer/config/image.rb
|
236
|
-
- lib/caterer/config/member.rb
|
237
229
|
- lib/caterer/config/provisioner.rb
|
238
230
|
- lib/caterer/config/provisioner/base.rb
|
239
231
|
- lib/caterer/config/provisioner/chef_solo.rb
|
240
232
|
- lib/caterer/environment.rb
|
233
|
+
- lib/caterer/group.rb
|
234
|
+
- lib/caterer/image.rb
|
241
235
|
- lib/caterer/logger.rb
|
236
|
+
- lib/caterer/member.rb
|
242
237
|
- lib/caterer/provisioner.rb
|
243
238
|
- lib/caterer/provisioner/base.rb
|
244
239
|
- lib/caterer/provisioner/chef_solo.rb
|
240
|
+
- lib/caterer/provisioner/shell.rb
|
245
241
|
- lib/caterer/provisioners.rb
|
246
242
|
- lib/caterer/server.rb
|
247
243
|
- lib/caterer/util.rb
|
@@ -249,15 +245,17 @@ files:
|
|
249
245
|
- lib/caterer/util/retryable.rb
|
250
246
|
- lib/caterer/util/shell.rb
|
251
247
|
- lib/caterer/version.rb
|
248
|
+
- lib/templates/image/bin_wrapper.erb
|
252
249
|
- lib/templates/provisioner/chef_solo/bootstrap.sh
|
253
|
-
- lib/templates/provisioner/chef_solo/
|
254
|
-
- lib/templates/provisioner/chef_solo/
|
255
|
-
- lib/templates/provisioner/chef_solo/
|
256
|
-
- lib/templates/provisioner/chef_solo/
|
257
|
-
- lib/templates/provisioner/chef_solo/
|
258
|
-
- lib/templates/provisioner/chef_solo/
|
259
|
-
- lib/templates/provisioner/chef_solo/
|
250
|
+
- lib/templates/provisioner/chef_solo/install/debian.sh
|
251
|
+
- lib/templates/provisioner/chef_solo/install/el.sh
|
252
|
+
- lib/templates/provisioner/chef_solo/install/fedora.sh
|
253
|
+
- lib/templates/provisioner/chef_solo/install/sles.sh
|
254
|
+
- lib/templates/provisioner/chef_solo/install/smartos.sh
|
255
|
+
- lib/templates/provisioner/chef_solo/install/suse.sh
|
256
|
+
- lib/templates/provisioner/chef_solo/install/ubuntu.sh
|
260
257
|
- lib/templates/provisioner/chef_solo/solo.erb
|
258
|
+
- lib/templates/provisioner/shell/script.erb
|
261
259
|
- lib/templates/server/platform.sh
|
262
260
|
homepage: ''
|
263
261
|
licenses: []
|
@@ -273,7 +271,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
273
271
|
version: '0'
|
274
272
|
segments:
|
275
273
|
- 0
|
276
|
-
hash:
|
274
|
+
hash: 141391927136989178
|
277
275
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
276
|
none: false
|
279
277
|
requirements:
|
@@ -282,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
280
|
version: '0'
|
283
281
|
segments:
|
284
282
|
- 0
|
285
|
-
hash:
|
283
|
+
hash: 141391927136989178
|
286
284
|
requirements: []
|
287
285
|
rubyforge_project:
|
288
286
|
rubygems_version: 1.8.23
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Caterer
|
2
|
-
module Action
|
3
|
-
module Provisioner
|
4
|
-
class Load < Base
|
5
|
-
|
6
|
-
def call(env)
|
7
|
-
|
8
|
-
env[:provisioner] = load_provisioner(env)
|
9
|
-
|
10
|
-
@app.call(env)
|
11
|
-
end
|
12
|
-
|
13
|
-
def load_provisioner(env)
|
14
|
-
|
15
|
-
if image = env[:image]
|
16
|
-
env[:config].images[image].provisioner
|
17
|
-
else
|
18
|
-
Caterer.provisioners.get(env[:engine] || default_engine).new
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def default_engine
|
23
|
-
Caterer.config.provisioner.default_engine
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Caterer
|
2
|
-
module Action
|
3
|
-
module Provisioner
|
4
|
-
module Validate
|
5
|
-
class Bootstrapped < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
|
9
|
-
if not env[:provisioner].bootstrapped?(env[:server])
|
10
|
-
env[:ui].error "Server not bootstrapped, cannot continue"
|
11
|
-
return
|
12
|
-
end
|
13
|
-
|
14
|
-
@app.call(env)
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Caterer
|
2
|
-
module Action
|
3
|
-
module Provisioner
|
4
|
-
module Validate
|
5
|
-
class Engine < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
|
9
|
-
if env[:engine]
|
10
|
-
if not Caterer.provisioners.get(env[:engine])
|
11
|
-
env[:ui].error "Unsupported provision engine #{env[:engine]}"
|
12
|
-
return
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
@app.call(env)
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|