boucher 0.1.1 → 0.1.2
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 +95 -19
- data/boucher.gemspec +1 -2
- data/lib/boucher/meals.rb +6 -3
- data/spec/boucher/meals_spec.rb +9 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -1,31 +1,57 @@
|
|
1
1
|
<img src="" alt="boucher logo" title="Boucher" align="right"/>
|
2
2
|
# Boucher
|
3
3
|
|
4
|
-
|
4
|
+
Boucher, pronounced [boo-shay], and meaning Butcher in French, is a suite of Rake tasks that simplfy your AWS
|
5
|
+
deployment strategy. It's built ontop of Chef and Fog giving your fingers the power to create new servers,
|
6
|
+
install required software, and deploy your system all in a single command.
|
7
|
+
|
8
|
+
It also helps manage your system with support for different environments and tasks to:
|
9
|
+
|
10
|
+
* list all your servers
|
11
|
+
* start/stop/terminate servers
|
12
|
+
* run chef on a given server
|
13
|
+
* easily ssh into a server
|
14
|
+
* attach volumes or elastic IPs to your servers
|
5
15
|
|
6
16
|
## Getting Started
|
7
17
|
|
18
|
+
Getting up and running with Boucher might take a little while depending your your familiarity with AWS and Linux.
|
19
|
+
Once you're up and running though, it'll save you countless hours in the long run.
|
20
|
+
|
21
|
+
### Creating your infrastructure project.
|
22
|
+
|
23
|
+
Boucher assumes a certain directory structure. Bummer I know, but c'est la vie. To help you out, we've provided a git repo
|
24
|
+
that'll get you off the ground. We recomend
|
25
|
+
|
26
|
+
git clone git://github.com/8thlight/boucher_template.git infrastructure
|
27
|
+
rm -rf infrastructure/.git
|
28
|
+
|
29
|
+
You'll probabaly want to create a repository for your own to track the work here.
|
30
|
+
|
31
|
+
Read config/env/shared.rb to get a feel for the configuration options. You'll fill in some of those values as your continue to get started below.
|
8
32
|
|
9
33
|
### Creating a base image
|
10
34
|
|
11
|
-
1
|
12
|
-
|
13
|
-
|
35
|
+
1) Launch new instance: Ubuntu Server 12.04.1 LTS
|
36
|
+
|
37
|
+
* Create a new key saved in your infrastructure project
|
38
|
+
* Be sure to add a security group that opens port 22 for SSH
|
39
|
+
|
40
|
+
2) Update config/env/shared.rb
|
14
41
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
* :aws_access_key_id and aws_secret_access_key - available in the AWS Management Console under Security Credentials
|
42
|
+
* :aws_key_filename - name of the .pem file you just created and saved in the project root
|
43
|
+
* :aws_region - which AWS region did you use?
|
44
|
+
* :aws_access_key_id and aws_secret_access_key - available in the AWS Management Console under Security Credentials
|
19
45
|
|
20
|
-
3
|
46
|
+
3) List servers
|
21
47
|
|
22
48
|
rake servers:list
|
23
49
|
|
24
|
-
4
|
50
|
+
4) SSH into new server. (:username config must be 'ubunutu' at this point)
|
25
51
|
|
26
52
|
rake servers:ssh[<instance id>]
|
27
53
|
|
28
|
-
5
|
54
|
+
5) Create new poweruser (unless you like 'unubutu' as your poweruser).
|
29
55
|
|
30
56
|
sudo adduser <username>
|
31
57
|
sudo adduser <username> sudo
|
@@ -33,28 +59,28 @@
|
|
33
59
|
sudo cp .ssh/authorized_keys /home/<username>/.ssh/
|
34
60
|
sudo chown -R <username>:<username> /home/<username>/.ssh
|
35
61
|
|
36
|
-
6
|
62
|
+
6) Logout. Update config :username. Log back in.
|
37
63
|
|
38
64
|
rake servers:ssh[<instance id>]
|
39
65
|
|
40
|
-
7
|
66
|
+
7) Delete the ubuntu user.
|
41
67
|
|
42
68
|
deluser ubuntu
|
43
69
|
|
44
|
-
8
|
70
|
+
8) Enable sudo without typing password
|
45
71
|
|
46
72
|
sudo visudo
|
47
73
|
# add the following line at the end of the file:
|
48
74
|
<username> ALL=(ALL) NOPASSWD: ALL
|
49
75
|
|
50
|
-
9
|
76
|
+
9) Install required pacakges and gems.
|
51
77
|
|
52
78
|
sudo apt-get update
|
53
79
|
sudo apt-get install ruby1.9.1 ruby1.9.1-dev git gcc make libxml2-dev libxslt1-dev
|
54
80
|
sudo apt-get upgrade
|
55
81
|
sudo gem install bundler chef
|
56
82
|
|
57
|
-
10
|
83
|
+
10) Checkout your infrstructure repo. (Yes. You should push your repo even in this early stage.)
|
58
84
|
If you use github, you'll have to generate ssh keys and add them to the github repo.
|
59
85
|
|
60
86
|
cd ~/.ssh
|
@@ -63,10 +89,12 @@ If you use github, you'll have to generate ssh keys and add them to the github r
|
|
63
89
|
cd ..
|
64
90
|
git clone git@github.com:<github account name>/<your infratructure project name>.git infrastructure
|
65
91
|
|
66
|
-
11
|
92
|
+
11) Customize to your liking.
|
67
93
|
|
68
|
-
|
69
|
-
|
94
|
+
* install your preferred vim dot files
|
95
|
+
* etc...
|
96
|
+
|
97
|
+
12) Create an AMI using the AWS Management console. Grab the AMI id and put it in config/env/shared.rb as the :default_image_id config value.
|
70
98
|
|
71
99
|
## Usage
|
72
100
|
|
@@ -74,6 +102,54 @@ Run rake to see the list of tasks provided.
|
|
74
102
|
|
75
103
|
rake -T
|
76
104
|
|
105
|
+
### Meals
|
106
|
+
|
107
|
+
We're sticking with the metephore here. A Meal is basically a set of recipes for a single server.
|
108
|
+
Boucher will expect meals to exist in the config directory. They are JSON files usable by chef-solo, and Boucher
|
109
|
+
allows you too add extra configuration information under the "Boucher": key. For example:
|
110
|
+
|
111
|
+
{
|
112
|
+
"run_list": [
|
113
|
+
"recipe[boucher::base]"
|
114
|
+
],
|
115
|
+
|
116
|
+
"boucher": {
|
117
|
+
"base_image_id": "ami-abcd1234", // overides :default_image_id config
|
118
|
+
"flavor_id": "t1.micro", // overides :default_flavor_id config
|
119
|
+
"groups": ["SSH"], // overides :default_groups config
|
120
|
+
"key_name": ["some_key"], // overides :aws_key_filename config
|
121
|
+
"elastic_ips": ["1.2.3.4"], // a list of elastic IPs that'll be attached to the server. Elastic IP's acquired via AWS management console.
|
122
|
+
"volumes": ["some_volume"] // a list of volume names that'll be attached to the server. Volumes acquired via AWS management console.
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
ERB: The "boucher": content can contain ERB. So you can use config params like so:
|
127
|
+
|
128
|
+
{
|
129
|
+
"run_list": ...
|
130
|
+
|
131
|
+
"boucher": {
|
132
|
+
"flavor_id": "<%= Boucher::Config[:customer_flavor_id] %>"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
### Environments
|
137
|
+
|
138
|
+
Enviroments are configured in config/env/<env_name>.rb. The project template we checked out earlier only provides one: dev.
|
139
|
+
You're welcome to create as many environments as you like. At the top of each environment config file, require the shared
|
140
|
+
config and then you can overide or add any configuration below.
|
141
|
+
|
142
|
+
|
143
|
+
Environment configuration is available in your chef recipes. Just require 'boucher/env' in any recipe and extract values like so:
|
144
|
+
|
145
|
+
Boucher::Config[:my_config_value]
|
146
|
+
|
147
|
+
### Recipes
|
148
|
+
|
149
|
+
We'll assume you're familiar with Chef. So you know, there are plany of open source cookbooks/recipes on the intertubes.
|
150
|
+
Convention is to grab the files, put them in your cookbooks folder and take ownership of them. There's a good chance you'll
|
151
|
+
want to change them.
|
152
|
+
|
77
153
|
## License
|
78
154
|
|
79
155
|
Copyright (c) 2012 8th Light, Inc.
|
data/boucher.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "boucher"
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
s.authors = ["'Micah Micah'"]
|
7
7
|
s.email = ["'micah@8thlight.com'"]
|
8
8
|
s.homepage = "http://github.com/8thlight/boucher"
|
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
s.executables = []
|
14
14
|
s.require_paths = ["lib"]
|
15
|
-
s.autorequire = 'boucher/tasks'
|
16
15
|
|
17
16
|
s.add_dependency('rake', '>= 0.9.2.2')
|
18
17
|
s.add_dependency('fog', '>= 1.6.0')
|
data/lib/boucher/meals.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'boucher/env'
|
2
2
|
require 'boucher/util'
|
3
|
+
require 'erb'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module Boucher
|
6
7
|
|
7
8
|
def self.json_to_meal(json)
|
9
|
+
template = ERB.new(json)
|
10
|
+
json = template.result(binding)
|
8
11
|
parser = JSON.parser.new(json, :symbolize_names => true)
|
9
12
|
config = parser.parse
|
10
13
|
config[:boucher] || {}
|
@@ -29,9 +32,9 @@ module Boucher
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def self.setup_meal(server, meal)
|
32
|
-
server.image_id = meal[:
|
33
|
-
server.flavor_id = meal[:flavor_id] || Boucher::Config[:
|
34
|
-
server.groups = meal[:groups] || Boucher::Config[:
|
35
|
+
server.image_id = meal[:image_id] || Boucher::Config[:default_image_id]
|
36
|
+
server.flavor_id = meal[:flavor_id] || Boucher::Config[:default_flavor_id]
|
37
|
+
server.groups = meal[:groups] || Boucher::Config[:default_groups]
|
35
38
|
server.key_name = meal[:key_name] || Boucher::Config[:aws_key_filename]
|
36
39
|
server.tags = {}
|
37
40
|
server.tags["Name"] = "#{meal[:meal_name] || "base"} #{Time.new.strftime("%Y%m%d%H%M%S")}"
|
data/spec/boucher/meals_spec.rb
CHANGED
@@ -17,14 +17,20 @@ describe "Boucher Server Meals" do
|
|
17
17
|
Boucher.json_to_meal(json).should == {}
|
18
18
|
end
|
19
19
|
|
20
|
+
it "meal config can have ERB content" do
|
21
|
+
Boucher::Config[:foo] = "FOOEY!"
|
22
|
+
json = "{\"boucher\": {\"foo\": \"<%= Boucher::Config[:foo] %>\"}}"
|
23
|
+
Boucher.json_to_meal(json).should == {:foo => "FOOEY!"}
|
24
|
+
end
|
25
|
+
|
20
26
|
it "can classify base server" do
|
21
27
|
some_class = {:meal_name => "base",
|
22
28
|
:meals => ["base"]}
|
23
|
-
Boucher::Config[:
|
24
|
-
Boucher::Config[:
|
29
|
+
Boucher::Config[:default_flavor_id] = 'm1.small'
|
30
|
+
Boucher::Config[:default_groups] = ["SSH"]
|
25
31
|
Boucher.setup_meal(@server, some_class)
|
26
32
|
|
27
|
-
@server.image_id.should == Boucher::Config[:
|
33
|
+
@server.image_id.should == Boucher::Config[:default_image_id]
|
28
34
|
@server.flavor_id.should == 'm1.small'
|
29
35
|
@server.groups.should == ["SSH"]
|
30
36
|
@server.key_name.should == "test_key"
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boucher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- ! '''Micah Micah'''
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-09-26 00:00:00.000000000 Z
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: 3778709773392559324
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|