caterer 0.11.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/README.md
CHANGED
@@ -1,73 +1,22 @@
|
|
1
|
-
|
1
|
+
## Caterer
|
2
2
|
|
3
|
-
|
3
|
+
Caterer is a tool for provisioning production environments.
|
4
4
|
|
5
|
-
|
5
|
+
### Getting Started
|
6
6
|
|
7
|
-
|
7
|
+
#### Install caterer:
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Caterer does not replace chef or puppet, but leverages them to provide a faster iterative approach to live infrastructures. If you're familiar with the vagrant workflow, imagine that your 'boxes' are remote servers and you'll feel right at home.
|
14
|
-
|
15
|
-
The goal of caterer is that an entire infrastructure definition lives within a git repo. An infrastructure developer can open the Caterfile and read the infrastructure like a map. All provisioning recipes or definitions will live within this repo, and infrastructure developers can interate repidly to provide a hot infrastructure.
|
16
|
-
|
17
|
-
## Installation
|
18
|
-
|
19
|
-
Add this line to your application's Gemfile:
|
20
|
-
|
21
|
-
gem 'caterer'
|
22
|
-
|
23
|
-
And then execute:
|
24
|
-
|
25
|
-
$ bundle
|
26
|
-
|
27
|
-
Or install it yourself as:
|
28
|
-
|
29
|
-
$ gem install caterer
|
30
|
-
|
31
|
-
## Usage
|
32
|
-
|
33
|
-
### Caterfile
|
34
|
-
|
35
|
-
Caterer loads a Caterfile from the current directory. A Caterfile defines your infrastructure in a centralized, familiar ruby dsl. A Caterfile essentially creates a library of images that can be aggregated and applied to live servers.
|
36
|
-
|
37
|
-
### Images
|
38
|
-
|
39
|
-
An image is a configuration construct that defines the end state of the machine after that image has been applied. An image requires a provisioner.
|
40
|
-
|
41
|
-
### Provisioner
|
42
|
-
|
43
|
-
A provisioner is the tool that will provision a server to meet the end requirements of an image. Currently only chef-solo is supported.
|
44
|
-
|
45
|
-
### Member
|
46
|
-
|
47
|
-
A member is an optional configuration for servers. Storing live server credentials in a version controlled repo is not suitable for many infrastructures, but is there for your convenience if you want it.
|
48
|
-
|
49
|
-
### Group
|
50
|
-
|
51
|
-
A group is a simply way of grouping images or members to provide agrregate funcionality in a simple, concise way.
|
52
|
-
|
53
|
-
## Example
|
9
|
+
```bash
|
10
|
+
gem install caterer
|
11
|
+
```
|
54
12
|
|
55
|
-
|
13
|
+
#### Define images in a Caterfile:
|
56
14
|
|
57
15
|
```ruby
|
58
16
|
Caterer.configure do |config|
|
59
17
|
|
60
|
-
config.image :basic do |image|
|
61
|
-
image.provision :chef_solo do |chef|
|
62
|
-
chef.cookbooks_path = ['cookbooks'] # default
|
63
|
-
chef.add_recipe 'ruby'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
18
|
config.image :rails do |image|
|
68
19
|
image.provision :chef_solo do |chef|
|
69
|
-
chef.bootstrap_script = 'script/bootstrap'
|
70
|
-
chef.cookbooks_path = ['cookbooks'] # default
|
71
20
|
chef.add_recipe 'ruby'
|
72
21
|
chef.add_recipe 'mysql::server'
|
73
22
|
chef.add_recipe 'mysql::client'
|
@@ -78,83 +27,52 @@ Caterer.configure do |config|
|
|
78
27
|
}
|
79
28
|
end
|
80
29
|
end
|
81
|
-
|
82
|
-
config.member :m1 do |member|
|
83
|
-
member.images = [:basic]
|
84
|
-
member.host = "192.168.1.101"
|
85
|
-
member.password = 'samIam'
|
86
|
-
end
|
87
|
-
|
88
|
-
config.group :oven do |group|
|
89
|
-
|
90
|
-
group.images = [:basic, :rails]
|
91
|
-
group.user = 'root' # optional
|
92
|
-
group.password = 'password' # optional
|
93
|
-
|
94
|
-
# optional member configuration
|
95
|
-
group.member :oven1 do |m|
|
96
|
-
m.host = "192.168.1.100"
|
97
|
-
end
|
98
|
-
|
99
|
-
group.member :oven2 do |m|
|
100
|
-
m.host = "192.168.1.101"
|
101
|
-
m.password = 'samIam'
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
30
|
end
|
107
31
|
```
|
108
32
|
|
109
|
-
|
110
|
-
|
111
|
-
Provision a server with a basic image (image defined in Caterfile)
|
33
|
+
#### Provision a server with the "rails" image:
|
112
34
|
|
113
35
|
```bash
|
114
|
-
cater provision -i
|
36
|
+
cater provision HOST -i rails
|
115
37
|
```
|
116
38
|
|
117
|
-
|
39
|
+
## Documentation
|
118
40
|
|
119
|
-
|
120
|
-
cater provision -i basic,rails HOST
|
121
|
-
```
|
41
|
+
The Caterer Wiki has lots of additional information about Caterer including many usage references, configuration examples, how-to articles, and answers to the most frequently asked questions.
|
122
42
|
|
123
|
-
|
43
|
+
You can view all of the available wiki pages [here](https://github.com/tylerflint/caterer/wiki/_pages).
|
124
44
|
|
125
|
-
|
126
|
-
cater provision -g oven HOST
|
127
|
-
```
|
45
|
+
### Getting started
|
128
46
|
|
129
|
-
|
47
|
+
Here is the basic information to get started: [Soup to Nuts](https://github.com/tylerflint/caterer/wiki/Soup-to-Nuts)
|
130
48
|
|
131
|
-
|
132
|
-
cater provision m1
|
133
|
-
```
|
49
|
+
For answers to the most frequently asked questions: [FAQ](https://github.com/tylerflint/caterer/wiki/FAQ)
|
134
50
|
|
135
|
-
|
51
|
+
Some definitions to help you through the rest of the guides: [Definitions](https://github.com/tylerflint/caterer/wiki/Definitions)
|
136
52
|
|
137
|
-
|
138
|
-
cater provision oven::oven1
|
139
|
-
```
|
53
|
+
A few cli usage examples: [cli examples](https://github.com/tylerflint/caterer/wiki/cli-examples)
|
140
54
|
|
141
|
-
|
55
|
+
### Configuration
|
142
56
|
|
143
|
-
|
144
|
-
|
145
|
-
|
57
|
+
* [general](https://github.com/tylerflint/caterer/wiki/Config:-General)
|
58
|
+
* [images](https://github.com/tylerflint/caterer/wiki/Config:-Images)
|
59
|
+
* [members](https://github.com/tylerflint/caterer/wiki/Config:-Members)
|
60
|
+
* [groups](https://github.com/tylerflint/caterer/wiki/Config:-Groups)
|
146
61
|
|
147
|
-
|
62
|
+
#### Provisioners
|
63
|
+
* [shell](https://github.com/tylerflint/caterer/wiki/Config:-Provisioners:-Shell)
|
64
|
+
* [chef-solo](https://github.com/tylerflint/caterer/wiki/Config:-Provisioners:-chef-solo)
|
148
65
|
|
149
|
-
|
150
|
-
cater bootstrap -i basic HOST
|
151
|
-
```
|
66
|
+
### How To...
|
152
67
|
|
153
|
-
|
68
|
+
Use berkshelf for cookbook dependencies: [Howto: Berkshelf](https://github.com/tylerflint/caterer/wiki/Howto:-Berkshelf)
|
69
|
+
|
70
|
+
Display verbose output: [Howto: Verbose Logging](https://github.com/tylerflint/caterer/wiki/Howto:-Verbose-Logging)
|
71
|
+
|
72
|
+
Structure a large project: [Howto: Large Projects](https://github.com/tylerflint/caterer/wiki/Howto:-Large-Projects)
|
73
|
+
|
74
|
+
Limit chef runlist for iterative provisioning: [Howto: Runlist Override]()
|
154
75
|
|
155
|
-
```bash
|
156
|
-
cater up -i basic HOST
|
157
|
-
```
|
158
76
|
|
159
77
|
## Contributing
|
160
78
|
|
data/Vagrantfile
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
Vagrant.configure("2") do |config|
|
4
4
|
|
5
5
|
# ubuntu
|
6
|
-
|
7
|
-
|
6
|
+
config.vm.box = 'precise'
|
7
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
8
8
|
|
9
9
|
# centos
|
10
|
-
config.vm.box = 'pagoda_cent6_minimal'
|
11
|
-
config.vm.box_url = 'https://s3.amazonaws.com/vagrant.pagodabox.com/boxes/centos-6.4-x86_64-minimal.box'
|
10
|
+
# config.vm.box = 'pagoda_cent6_minimal'
|
11
|
+
# config.vm.box_url = 'https://s3.amazonaws.com/vagrant.pagodabox.com/boxes/centos-6.4-x86_64-minimal.box'
|
12
12
|
|
13
13
|
config.vm.provider "virtualbox" do |v|
|
14
14
|
v.customize ["modifyvm", :id, "--cpus", "2", "--memory", "1024", "--cpuexecutioncap", "75"]
|
data/lib/caterer.rb
CHANGED
@@ -10,6 +10,9 @@ module Caterer
|
|
10
10
|
autoload :Communication, 'caterer/communication'
|
11
11
|
autoload :Config, 'caterer/config'
|
12
12
|
autoload :Environment, 'caterer/environment'
|
13
|
+
autoload :Group, 'caterer/group'
|
14
|
+
autoload :Image, 'caterer/image'
|
15
|
+
autoload :Member, 'caterer/member'
|
13
16
|
autoload :Provisioner, 'caterer/provisioner'
|
14
17
|
autoload :Server, 'caterer/server'
|
15
18
|
autoload :Util, 'caterer/util'
|
data/lib/caterer/action.rb
CHANGED
@@ -4,6 +4,7 @@ module Caterer
|
|
4
4
|
autoload :Berkshelf, 'caterer/action/berkshelf'
|
5
5
|
autoload :Config, 'caterer/action/config'
|
6
6
|
autoload :Environment, 'caterer/action/environment'
|
7
|
+
autoload :Image, 'caterer/action/image'
|
7
8
|
autoload :Runner, 'caterer/action/runner'
|
8
9
|
autoload :Provisioner, 'caterer/action/provisioner'
|
9
10
|
autoload :Server, 'caterer/action/server'
|
@@ -44,8 +44,10 @@ module Caterer
|
|
44
44
|
::Digest::MD5.hexdigest("#{berks_content}/#{lock_content}/#{shelf_content}")
|
45
45
|
end
|
46
46
|
|
47
|
+
# default to true for time being...
|
47
48
|
def needs_update?
|
48
|
-
!(::File.exists?(cachefile) and ::File.read(cachefile) == shelf_digest)
|
49
|
+
# !(::File.exists?(cachefile) and ::File.read(cachefile) == shelf_digest)
|
50
|
+
true
|
49
51
|
end
|
50
52
|
|
51
53
|
def update_cache
|
@@ -7,19 +7,25 @@ module Caterer
|
|
7
7
|
def call(env)
|
8
8
|
|
9
9
|
if env[:image]
|
10
|
-
provisioner = env[:config].images[env[:image]].provisioner
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
provisioners = env[:config].images[env[:image]].provisioners
|
12
|
+
|
13
|
+
if provisioners.empty?
|
14
|
+
env[:ui].error "image ':#{env[:image]}' does not have a provisioner"
|
14
15
|
return
|
15
16
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
|
18
|
+
provisioners.each do |provisioner|
|
19
|
+
|
20
|
+
if errors = provisioner.errors
|
21
|
+
errors.each do |key, val|
|
22
|
+
env[:ui].error "image :#{env[:image]} provisioner error -> #{key} #{val}"
|
23
|
+
end
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
23
29
|
end
|
24
30
|
|
25
31
|
@app.call(env)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Caterer
|
2
|
+
module Action
|
3
|
+
module Image
|
4
|
+
class Cleanup < Base
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.cleanup(server) if env[:ghost_mode]
|
13
|
+
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Caterer
|
2
|
+
module Action
|
3
|
+
module Image
|
4
|
+
class Prepare < Base
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.prepare(server)
|
13
|
+
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Caterer
|
2
|
+
module Action
|
3
|
+
module Image
|
4
|
+
class Run < Base
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.run(server) if not env[:dry_run]
|
13
|
+
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,16 +1,9 @@
|
|
1
1
|
module Caterer
|
2
2
|
module Action
|
3
3
|
module Provisioner
|
4
|
-
autoload :Bootstrap, 'caterer/action/provisioner/bootstrap'
|
5
4
|
autoload :Cleanup, 'caterer/action/provisioner/cleanup'
|
6
|
-
autoload :Install, 'caterer/action/provisioner/install'
|
7
|
-
autoload :Load, 'caterer/action/provisioner/load'
|
8
|
-
autoload :Lock, 'caterer/action/provisioner/lock'
|
9
5
|
autoload :Prepare, 'caterer/action/provisioner/prepare'
|
10
|
-
autoload :Provision, 'caterer/action/provisioner/provision'
|
11
6
|
autoload :Uninstall, 'caterer/action/provisioner/uninstall'
|
12
|
-
autoload :Unlock, 'caterer/action/provisioner/unlock'
|
13
|
-
autoload :Validate, 'caterer/action/provisioner/validate'
|
14
7
|
end
|
15
8
|
end
|
16
9
|
end
|
@@ -4,10 +4,28 @@ module Caterer
|
|
4
4
|
class Cleanup < Base
|
5
5
|
|
6
6
|
def call(env)
|
7
|
-
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.provisioners.each do |provisioner|
|
13
|
+
%w( cleanup uninstall ).each do |action|
|
14
|
+
send action.to_sym, server, provisioner
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
@app.call(env)
|
9
19
|
end
|
10
20
|
|
21
|
+
def cleanup(server, provisioner)
|
22
|
+
provisioner.cleanup(server)
|
23
|
+
end
|
24
|
+
|
25
|
+
def uninstall(server, provisioner)
|
26
|
+
provisioner.uninstall(server) if @env[:ghost_mode]
|
27
|
+
end
|
28
|
+
|
11
29
|
end
|
12
30
|
end
|
13
31
|
end
|
@@ -4,11 +4,29 @@ module Caterer
|
|
4
4
|
class Prepare < Base
|
5
5
|
|
6
6
|
def call(env)
|
7
|
-
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.provisioners.each do |provisioner|
|
13
|
+
%w( install prepare ).each do |action|
|
14
|
+
send action.to_sym, server, provisioner
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
@app.call(env)
|
9
19
|
end
|
20
|
+
|
21
|
+
def install(server, provisioner)
|
22
|
+
provisioner.install server if not provisioner.installed? server
|
23
|
+
end
|
24
|
+
|
25
|
+
def prepare(server, provisioner)
|
26
|
+
provisioner.prepare server
|
27
|
+
end
|
10
28
|
|
11
|
-
end
|
29
|
+
end
|
12
30
|
end
|
13
31
|
end
|
14
32
|
end
|
@@ -4,7 +4,15 @@ module Caterer
|
|
4
4
|
class Uninstall < Base
|
5
5
|
|
6
6
|
def call(env)
|
7
|
-
|
7
|
+
|
8
|
+
config = env[:config]
|
9
|
+
server = env[:server]
|
10
|
+
image = config.images[env[:image]]
|
11
|
+
|
12
|
+
image.provisioners.each do |provisioner|
|
13
|
+
provisioner.uninstall(server)
|
14
|
+
end
|
15
|
+
|
8
16
|
@app.call(env)
|
9
17
|
end
|
10
18
|
|