elzar 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +44 -27
- data/Rakefile +7 -0
- data/lib/elzar/assistant.rb +2 -2
- data/{chef → lib/elzar/templates}/.chef/knife.rb +0 -0
- data/lib/elzar/templates/README.md +26 -0
- data/lib/elzar/version.rb +1 -1
- data/spec/chef_dna_spec.rb +58 -0
- data/spec/spec_helper.rb +10 -0
- metadata +9 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,45 +1,62 @@
|
|
1
|
-
|
1
|
+
## Description
|
2
|
+
This gem enables a Rails app to define custom Chef recipes while still using an awesome default set
|
3
|
+
of Chef recipes. Best used in conjunction with relevance\_rails and slushy. Includes recipes for
|
4
|
+
ruby 1.9, ree, mysql, postgresql and nginx/passenger.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
To use Elzar with your Rails app, just use (relevance_rails)[https://github.com/relevance/relevance_rails].
|
9
|
+
|
10
|
+
But if you'd like to manually do it:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# Creates a provision/ directory to define app-specific cookbooks
|
14
|
+
Elzar.create_provision_directory 'provision'
|
15
|
+
|
16
|
+
# To combine Elzar's cookbooks with your app's cookbooks
|
17
|
+
dir = Elzar.merge_and_create_temp_directory 'provision'
|
18
|
+
# You now have a directory you can put on a chef node
|
19
|
+
```
|
20
|
+
|
21
|
+
## Local Development
|
22
|
+
|
23
|
+
If you'd like to try these Chef cookbooks with Vagrant:
|
24
|
+
|
25
|
+
```sh
|
26
|
+
$ git clone git@github.com:relevance/elzar.git
|
27
|
+
$ cd elzar
|
28
|
+
$ gem install bundler
|
29
|
+
# creates provision/ for local vagrant use
|
30
|
+
$ rake bam
|
31
|
+
$ cd provision
|
32
|
+
$ bundle install
|
33
|
+
|
34
|
+
## Using Vagrant
|
2
35
|
|
3
36
|
Download and install VirtualBox (as instructed in the Vagrant
|
4
37
|
[Getting Started guide](http://vagrantup.com/docs/getting-started/index.html)). Then set up
|
5
38
|
your bundle and grab the Ubuntu Lucid VM image.
|
6
39
|
|
7
|
-
gem install bundler
|
8
|
-
# creates provision/ for local vagrant use
|
9
|
-
rake bam
|
10
|
-
cd provision
|
11
|
-
bundle install
|
12
40
|
vagrant box add lucid64 http://files.vagrantup.com/lucid64.box
|
13
41
|
|
42
|
+
```sh
|
14
43
|
## Spin up a new VM
|
15
|
-
|
16
|
-
vagrant up
|
44
|
+
$ vagrant up
|
17
45
|
|
18
46
|
## SSH into the VM
|
19
|
-
|
20
|
-
vagrant ssh
|
47
|
+
$ vagrant ssh
|
21
48
|
|
22
49
|
## Destroy the VM
|
23
|
-
|
24
|
-
vagrant destroy
|
50
|
+
$ vagrant destroy
|
25
51
|
|
26
52
|
## Re-run Chef recipes on the VM
|
27
|
-
|
28
|
-
vagrant provision
|
53
|
+
$ vagrant provision
|
29
54
|
|
30
55
|
## Stop/Start the VM
|
56
|
+
$ vagrant suspend
|
57
|
+
$ vagrant resume
|
58
|
+
```
|
31
59
|
|
32
|
-
|
33
|
-
vagrant resume
|
34
|
-
|
35
|
-
# Install additional cookbooks
|
36
|
-
|
37
|
-
This script (and the knife extension it invokes) automatically creates a
|
38
|
-
vendor branch for tracking upstream git sources, merges the cookbook into the
|
39
|
-
cookbooks/ directory, and makes it easy to update these cookbook as needed in
|
40
|
-
the future.
|
41
|
-
|
42
|
-
To use this script, the cookbook must be in its own git repository, like those
|
43
|
-
at https://github.com/cookbooks/.
|
60
|
+
## Issues
|
44
61
|
|
45
|
-
|
62
|
+
Please file issues [on github](https://github.com/relevance/elzar/issues).
|
data/Rakefile
CHANGED
data/lib/elzar/assistant.rb
CHANGED
@@ -26,8 +26,10 @@ module Elzar
|
|
26
26
|
cp "#{Elzar.templates_dir}/Gemfile", dest
|
27
27
|
cp "#{Elzar.templates_dir}/upgrade-chef.sh", dest
|
28
28
|
cp "#{Elzar.templates_dir}/.rvmrc", dest
|
29
|
+
cp "#{Elzar.templates_dir}/README.md", dest
|
29
30
|
cp_r "#{Elzar.templates_dir}/data_bags", dest
|
30
31
|
cp_r "#{Elzar.templates_dir}/script", dest
|
32
|
+
cp_r "#{Elzar.templates_dir}/.chef", dest
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.merge_and_create_temp_directory(user_dir)
|
@@ -39,7 +41,6 @@ module Elzar
|
|
39
41
|
cp_r Elzar::ROLES_DIR, dest
|
40
42
|
cp_r "#{Elzar::CHEF_DIR}/cookbooks", elzar_dir
|
41
43
|
cp_r "#{Elzar::CHEF_DIR}/site-cookbooks", elzar_dir
|
42
|
-
cp_r "#{Elzar::CHEF_DIR}/.chef", dest
|
43
44
|
# merges user provision with elzar's provision
|
44
45
|
cp_r "#{user_dir}/.", dest
|
45
46
|
dest
|
@@ -52,7 +53,6 @@ module Elzar
|
|
52
53
|
cp_r Elzar::ROLES_DIR, dest
|
53
54
|
cp_r "#{Elzar::CHEF_DIR}/cookbooks", dest
|
54
55
|
cp_r "#{Elzar::CHEF_DIR}/site-cookbooks", dest
|
55
|
-
cp_r "#{Elzar::CHEF_DIR}/.chef", dest
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.generate_user_files(dest, options={})
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
## Description
|
2
|
+
Use this directory to define your app's Chef cookbooks. If you're using relevance\_rails,
|
3
|
+
your app automatically bundles (Elzar's recipes)[http://github.com/relevance/elzar].
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
First, setup this directory: `cd provision && bundle install`.
|
8
|
+
|
9
|
+
To create new cookbooks or install [existing ones](https://github.com/cookbooks):
|
10
|
+
|
11
|
+
```sh
|
12
|
+
# Create a new cookbook
|
13
|
+
$ script/new_cookbook my_cookbook
|
14
|
+
|
15
|
+
# Install any cookbook on github by user/name
|
16
|
+
$ script/install_cookbook cookbooks/mysql
|
17
|
+
```
|
18
|
+
|
19
|
+
Once you've added a cookbook you need to add the recipe name to the "run_list" key of dna.json.
|
20
|
+
|
21
|
+
## Elzar Cookbooks
|
22
|
+
Although Elzar's cookbooks and roles are automatically bundled, you can override them in cookbooks or
|
23
|
+
site_cookbooks.
|
24
|
+
|
25
|
+
## Vagrant
|
26
|
+
To provision using Vagrant [see these detailed instructions](https://github.com/relevance/elzar#using-vagrant).
|
data/lib/elzar/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Elzar::ChefDNA do
|
4
|
+
let(:database) { 'mysql' }
|
5
|
+
let(:json) {
|
6
|
+
{
|
7
|
+
"run_list" => ["role[plumbing]", "mysql::server", "role[enterprise_appstack]", "rails_app"],
|
8
|
+
'ruby' => {'url' => '', 'version' => '', 'gems_version' => ''},
|
9
|
+
'ruby_enterprise' => {'url' => '', 'version' => '', 'gems_version' => ''}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
let(:run_list) { json['run_list'] }
|
13
|
+
|
14
|
+
def splice(database = nil)
|
15
|
+
Elzar::ChefDNA.gene_splice(json, database, ruby_version)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.gene_splice' do
|
19
|
+
context 'for mri ruby' do
|
20
|
+
let(:ruby_version) { 'ruby-1.9.3-p194' }
|
21
|
+
|
22
|
+
it "updates run_list correctly for mysql" do
|
23
|
+
splice 'mysql'
|
24
|
+
run_list[1].should == 'mysql::server'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "updates run_list correctly for mysql as default" do
|
28
|
+
splice nil
|
29
|
+
run_list[1].should == 'mysql::server'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "updates run_list correctly for postgresql" do
|
33
|
+
splice 'postgresql'
|
34
|
+
run_list[1].should == 'role[postgres_database]'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "updates ruby dna correctly" do
|
38
|
+
splice
|
39
|
+
json['ruby']['url'].should == "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz"
|
40
|
+
json['ruby']['version'].should == '1.9.3-p194'
|
41
|
+
json['ruby']['gems_version'].should == Gem::VERSION
|
42
|
+
run_list[2].should == 'role[ruby_appstack]'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'for ree' do
|
47
|
+
let(:ruby_version) { 'ree-1.8.7-2011.03' }
|
48
|
+
|
49
|
+
it "updates ree dna correctly" do
|
50
|
+
splice
|
51
|
+
json['ruby_enterprise']['url'].should == "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03"
|
52
|
+
json['ruby_enterprise']['version'].should == '1.8.7-2011.03'
|
53
|
+
json['ruby_enterprise']['gems_version'].should == Gem::VERSION
|
54
|
+
run_list[2].should == 'role[enterprise_appstack]'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'elzar'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.filter_run_excluding :disabled => true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
|
7
|
+
config.alias_example_to :fit, :focused => true
|
8
|
+
config.alias_example_to :xit, :disabled => true
|
9
|
+
config.alias_example_to :they
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elzar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -90,7 +90,6 @@ files:
|
|
90
90
|
- Gemfile.lock
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
|
-
- chef/.chef/knife.rb
|
94
93
|
- chef/cookbooks/.gitkeep
|
95
94
|
- chef/cookbooks/apt/README.md
|
96
95
|
- chef/cookbooks/apt/files/default/apt-cacher
|
@@ -227,8 +226,10 @@ files:
|
|
227
226
|
- lib/elzar/assistant.rb
|
228
227
|
- lib/elzar/chef_dna.rb
|
229
228
|
- lib/elzar/template.rb
|
229
|
+
- lib/elzar/templates/.chef/knife.rb
|
230
230
|
- lib/elzar/templates/.rvmrc
|
231
231
|
- lib/elzar/templates/Gemfile
|
232
|
+
- lib/elzar/templates/README.md
|
232
233
|
- lib/elzar/templates/Vagrantfile.erb
|
233
234
|
- lib/elzar/templates/data_bags/deploy/authorized_keys.json
|
234
235
|
- lib/elzar/templates/dna.json
|
@@ -237,6 +238,8 @@ files:
|
|
237
238
|
- lib/elzar/templates/solo.rb.erb
|
238
239
|
- lib/elzar/templates/upgrade-chef.sh
|
239
240
|
- lib/elzar/version.rb
|
241
|
+
- spec/chef_dna_spec.rb
|
242
|
+
- spec/spec_helper.rb
|
240
243
|
homepage: http://github.com/relevance/elzar
|
241
244
|
licenses: []
|
242
245
|
post_install_message:
|
@@ -261,4 +264,6 @@ rubygems_version: 1.8.21
|
|
261
264
|
signing_key:
|
262
265
|
specification_version: 3
|
263
266
|
summary: Chef cookbooks for Rails
|
264
|
-
test_files:
|
267
|
+
test_files:
|
268
|
+
- spec/chef_dna_spec.rb
|
269
|
+
- spec/spec_helper.rb
|