caterer 0.9.6 → 0.10.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/.gitignore +1 -1
- data/Vagrantfile +9 -14
- data/lib/caterer/action/berkshelf/install.rb +26 -6
- data/lib/caterer/action/environment/setup.rb +13 -0
- data/lib/caterer/action/environment.rb +7 -0
- data/lib/caterer/action.rb +1 -0
- data/lib/caterer/actions.rb +7 -0
- data/lib/caterer/version.rb +1 -1
- metadata +6 -5
- data/cookbooks/users/recipes/default.rb +0 -18
data/.gitignore
CHANGED
data/Vagrantfile
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'vagrant-vbguest' unless defined? VagrantVbguest::Config
|
3
|
+
Vagrant.configure("2") do |config|
|
5
4
|
|
6
|
-
|
5
|
+
# ubuntu
|
6
|
+
config.vm.box = 'precise'
|
7
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
7
8
|
|
8
|
-
|
9
|
+
config.vm.provider "virtualbox" do |v|
|
10
|
+
v.customize ["modifyvm", :id, "--cpus", "2", "--memory", "1024", "--cpuexecutioncap", "75"]
|
11
|
+
end
|
9
12
|
|
10
|
-
config.vm.
|
11
|
-
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
12
|
-
config.vm.customize ["modifyvm", :id, "--cpus", 1, "--memory", 512]
|
13
|
-
config.vm.network :hostonly, "33.33.33.10"
|
14
|
-
config.vm.share_folder("v-root", "/vagrant", ".")
|
15
|
-
config.vbguest.auto_update = true
|
13
|
+
config.vm.network :private_network, ip: "33.33.33.10"
|
16
14
|
|
17
|
-
config.
|
18
|
-
chef.cookbooks_path = ['cookbooks']
|
19
|
-
chef.add_recipe 'users'
|
20
|
-
end
|
15
|
+
config.ssh.forward_agent = true
|
21
16
|
|
22
17
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
1
3
|
module Caterer
|
2
4
|
module Action
|
3
5
|
module Berkshelf
|
@@ -5,12 +7,14 @@ module Caterer
|
|
5
7
|
|
6
8
|
attr_reader :shelf
|
7
9
|
attr_reader :berksfile
|
10
|
+
attr_reader :cachefile
|
8
11
|
|
9
12
|
def initialize(app, env)
|
10
13
|
super
|
11
14
|
|
12
15
|
@shelf = Caterer::Berkshelf.shelf_for(env)
|
13
16
|
@berksfile = ::Berkshelf::Berksfile.from_file(env[:config].berkshelf.berksfile_path)
|
17
|
+
@cachefile = "#{shelf}/.cache"
|
14
18
|
end
|
15
19
|
|
16
20
|
|
@@ -18,7 +22,13 @@ module Caterer
|
|
18
22
|
|
19
23
|
if env[:provisioner].is_a? Caterer::Provisioner::ChefSolo
|
20
24
|
configure_cookbooks_path(env[:provisioner])
|
21
|
-
|
25
|
+
if needs_update?
|
26
|
+
::Berkshelf.formatter.msg "installing cookbooks..."
|
27
|
+
install(env)
|
28
|
+
update_cache
|
29
|
+
else
|
30
|
+
::Berkshelf.formatter.msg "up-to-date"
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
@app.call(env)
|
@@ -26,12 +36,22 @@ module Caterer
|
|
26
36
|
|
27
37
|
protected
|
28
38
|
|
39
|
+
def shelf_digest
|
40
|
+
berks_content = ::File.read(berksfile.filepath) rescue nil
|
41
|
+
shelf_content = ::Dir.glob("#{shelf}/[^\.]*")
|
42
|
+
::Digest::MD5.hexdigest("#{berks_content}/#{shelf_content}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def needs_update?
|
46
|
+
!(::File.exists?(cachefile) and ::File.read(cachefile) == shelf_digest)
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_cache
|
50
|
+
::File.write(cachefile, shelf_digest)
|
51
|
+
end
|
52
|
+
|
29
53
|
def install(env)
|
30
|
-
|
31
|
-
opts = {
|
32
|
-
path: shelf
|
33
|
-
}.merge(env[:config].berkshelf.to_hash).symbolize_keys!
|
34
|
-
berksfile.install(opts)
|
54
|
+
berksfile.install({path: shelf}.merge(env[:config].berkshelf.to_hash).symbolize_keys!)
|
35
55
|
end
|
36
56
|
|
37
57
|
def configure_cookbooks_path(provisioner)
|
data/lib/caterer/action.rb
CHANGED
@@ -3,6 +3,7 @@ module Caterer
|
|
3
3
|
autoload :Base, 'caterer/action/base'
|
4
4
|
autoload :Berkshelf, 'caterer/action/berkshelf'
|
5
5
|
autoload :Config, 'caterer/action/config'
|
6
|
+
autoload :Environment, 'caterer/action/environment'
|
6
7
|
autoload :Runner, 'caterer/action/runner'
|
7
8
|
autoload :Provisioner, 'caterer/action/provisioner'
|
8
9
|
autoload :Server, 'caterer/action/server'
|
data/lib/caterer/actions.rb
CHANGED
@@ -11,6 +11,7 @@ end
|
|
11
11
|
|
12
12
|
Caterer.actions.register(:lock) do
|
13
13
|
Vli::Action::Builder.new do
|
14
|
+
use Caterer::Action::Environment::Setup
|
14
15
|
use Caterer::Action::Server::Validate::SSH
|
15
16
|
use Caterer::Action::Server::Lock
|
16
17
|
end
|
@@ -18,6 +19,7 @@ end
|
|
18
19
|
|
19
20
|
Caterer.actions.register(:unlock) do
|
20
21
|
Vli::Action::Builder.new do
|
22
|
+
use Caterer::Action::Environment::Setup
|
21
23
|
use Caterer::Action::Server::Validate::SSH
|
22
24
|
use Caterer::Action::Server::Unlock
|
23
25
|
end
|
@@ -25,6 +27,7 @@ end
|
|
25
27
|
|
26
28
|
Caterer.actions.register(:bootstrap) do
|
27
29
|
Vli::Action::Builder.new do
|
30
|
+
use Caterer::Action::Environment::Setup
|
28
31
|
use Caterer.actions.get(:validate)
|
29
32
|
use Caterer::Action::Provisioner::Load
|
30
33
|
use Caterer::Action::Provisioner::Prepare
|
@@ -38,6 +41,7 @@ end
|
|
38
41
|
|
39
42
|
Caterer.actions.register(:provision) do
|
40
43
|
Vli::Action::Builder.new do
|
44
|
+
use Caterer::Action::Environment::Setup
|
41
45
|
use Caterer.actions.get(:validate)
|
42
46
|
use Caterer::Action::Provisioner::Load
|
43
47
|
use Caterer::Action::Provisioner::Prepare
|
@@ -51,6 +55,7 @@ end
|
|
51
55
|
|
52
56
|
Caterer.actions.register(:up) do
|
53
57
|
Vli::Action::Builder.new do
|
58
|
+
use Caterer::Action::Environment::Setup
|
54
59
|
use Caterer.actions.get(:validate)
|
55
60
|
use Caterer::Action::Provisioner::Load
|
56
61
|
use Caterer::Action::Provisioner::Prepare
|
@@ -65,6 +70,7 @@ end
|
|
65
70
|
|
66
71
|
Caterer.actions.register(:reboot) do
|
67
72
|
Vli::Action::Builder.new do
|
73
|
+
use Caterer::Action::Environment::Setup
|
68
74
|
use Caterer::Action::Server::Validate::SSH
|
69
75
|
use Caterer::Action::Server::Reboot
|
70
76
|
end
|
@@ -72,6 +78,7 @@ end
|
|
72
78
|
|
73
79
|
Caterer.actions.register(:clean) do
|
74
80
|
Vli::Action::Builder.new do
|
81
|
+
use Caterer::Action::Environment::Setup
|
75
82
|
use Caterer.actions.get(:validate)
|
76
83
|
use Caterer::Action::Provisioner::Load
|
77
84
|
use Caterer::Action::Provisioner::Uninstall
|
data/lib/caterer/version.rb
CHANGED
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: 0.10.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-04-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -175,7 +175,6 @@ files:
|
|
175
175
|
- bin/cater
|
176
176
|
- caterer.gemspec
|
177
177
|
- config/default.rb
|
178
|
-
- cookbooks/users/recipes/default.rb
|
179
178
|
- example/Caterfile
|
180
179
|
- example/bootstrap.sh
|
181
180
|
- knife.rb
|
@@ -190,6 +189,8 @@ files:
|
|
190
189
|
- lib/caterer/action/config/validate.rb
|
191
190
|
- lib/caterer/action/config/validate/image.rb
|
192
191
|
- lib/caterer/action/config/validate/provisioner.rb
|
192
|
+
- lib/caterer/action/environment.rb
|
193
|
+
- lib/caterer/action/environment/setup.rb
|
193
194
|
- lib/caterer/action/provisioner.rb
|
194
195
|
- lib/caterer/action/provisioner/bootstrap.rb
|
195
196
|
- lib/caterer/action/provisioner/cleanup.rb
|
@@ -261,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
262
|
version: '0'
|
262
263
|
segments:
|
263
264
|
- 0
|
264
|
-
hash:
|
265
|
+
hash: -4253641693695072200
|
265
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
267
|
none: false
|
267
268
|
requirements:
|
@@ -270,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
271
|
version: '0'
|
271
272
|
segments:
|
272
273
|
- 0
|
273
|
-
hash:
|
274
|
+
hash: -4253641693695072200
|
274
275
|
requirements: []
|
275
276
|
rubyforge_project:
|
276
277
|
rubygems_version: 1.8.23
|
@@ -1,18 +0,0 @@
|
|
1
|
-
|
2
|
-
package "build-essential" do
|
3
|
-
action :nothing
|
4
|
-
end.run_action(:install)
|
5
|
-
|
6
|
-
package 'whois'
|
7
|
-
chef_gem 'ruby-shadow'
|
8
|
-
|
9
|
-
[['bert', 'password'], ['ernie', 'password'], ['tylerflint', 'password']].each do |u, pass|
|
10
|
-
user u do
|
11
|
-
supports :manage_home => true
|
12
|
-
home "/home/#{u}"
|
13
|
-
gid "admin"
|
14
|
-
shell "/bin/bash"
|
15
|
-
password `echo #{pass} | mkpasswd -s -m sha-512`.chomp
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|