chef_cap 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/Capfile +16 -0
- data/Gemfile +2 -1
- data/README.rdoc +1 -3
- data/Rakefile +3 -0
- data/chef/node.json +41 -0
- data/lib/chef_cap/version.rb +1 -1
- data/lib/chef_cap.rb +1 -1
- data/recipes/chef_cap.rb +4 -1
- data/recipes/lib/chef_cap_helper.rb +17 -1
- data/spec/chef_cap_helper_spec.rb +31 -0
- data/spec/chef_cap_spec.rb +2 -1
- metadata +5 -4
- data/Gemfile.lock +0 -37
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm 1.9.2-
|
1
|
+
rvm 1.9.2-p136@chef_cap
|
data/Capfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
gemfile = File.expand_path('Gemfile', __FILE__)
|
5
|
+
begin
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::GemNotFound => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
12
|
+
exit!
|
13
|
+
end if File.exist?(gemfile)
|
14
|
+
require File.join(File.dirname(__FILE__), "lib/chef_cap")
|
15
|
+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
16
|
+
::ChefCap::Capistrano.load_recipes(self)
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
data/chef/node.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"application": {
|
3
|
+
"name": "your-app-name",
|
4
|
+
"repository": "your-repo"
|
5
|
+
},
|
6
|
+
"upload": [
|
7
|
+
],
|
8
|
+
"environments": {
|
9
|
+
"defaults": {
|
10
|
+
"user": "deploy",
|
11
|
+
"branch": "master"
|
12
|
+
},
|
13
|
+
"production": {
|
14
|
+
"rails_env": "production",
|
15
|
+
"database": {
|
16
|
+
"user": "production-db-user",
|
17
|
+
"host": "production-db-host"
|
18
|
+
},
|
19
|
+
"servers": [
|
20
|
+
{
|
21
|
+
"hostname": "some.fq.dn",
|
22
|
+
"roles": ["web", "app", "db"],
|
23
|
+
"primary": ["web", "app", "db"]
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"shared": {
|
29
|
+
"gems": [
|
30
|
+
{ "name": "bundler" },
|
31
|
+
{ "name": "chef", "version": ">=0.9.12" }
|
32
|
+
],
|
33
|
+
"run_list": ["gems"]
|
34
|
+
},
|
35
|
+
"roles": {
|
36
|
+
"web": {},
|
37
|
+
"app": {},
|
38
|
+
"db": {}
|
39
|
+
}
|
40
|
+
// "deploy_recipe": "yourcustomdeployrecipe",
|
41
|
+
}
|
data/lib/chef_cap/version.rb
CHANGED
data/lib/chef_cap.rb
CHANGED
data/recipes/chef_cap.rb
CHANGED
@@ -134,7 +134,9 @@ end
|
|
134
134
|
namespace :chef do
|
135
135
|
desc "Setup chef solo on the server(s)"
|
136
136
|
task :setup do
|
137
|
-
|
137
|
+
gem_check_for_chef_cmd = "gem specification --version '>=0.9.12' chef 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'"
|
138
|
+
install_chef_cmd = "sudo rvm default exec gem install chef --no-ri --no-rdoc"
|
139
|
+
sudo "rvm default exec #{gem_check_for_chef_cmd} || #{install_chef_cmd} && echo 'Chef Solo already on this server.'"
|
138
140
|
sudo "rvm default exec which chef-solo"
|
139
141
|
end
|
140
142
|
|
@@ -165,6 +167,7 @@ namespace :chef do
|
|
165
167
|
env_settings.each { |k, v| ChefCapHelper.recursive_merge(json_to_modify["environment"] || {}, k, v) }
|
166
168
|
|
167
169
|
json_to_modify["environment"]["revision"] = ChefCapHelper.set_revision if ChefCapHelper.has_revision?
|
170
|
+
json_to_modify["environment"]["branch"] = ChefCapHelper.set_branch if ChefCapHelper.has_branch?
|
168
171
|
json_to_modify["environment"]["servers"] = ChefCapHelper.intialize_primary_values(json_to_modify["environment"]["servers"])
|
169
172
|
|
170
173
|
should_not_deploy = no_deploy rescue false
|
@@ -49,7 +49,23 @@ class ChefCapHelper
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def set_revision
|
52
|
-
|
52
|
+
["rev", "tag", "revision"].each do |word|
|
53
|
+
[word, word.upcase, "-S#{word}"].each do |variable|
|
54
|
+
return ENV[variable] if ENV[variable]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_branch
|
61
|
+
["branch", "BRANCH", "-Sbranch"].each do |variable|
|
62
|
+
return ENV[variable] if ENV[variable]
|
63
|
+
end
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def has_branch?
|
68
|
+
!set_branch.nil?
|
53
69
|
end
|
54
70
|
|
55
71
|
def has_revision?
|
@@ -123,4 +123,35 @@ describe ChefDnaParser do
|
|
123
123
|
ChefCapHelper.intialize_primary_values(array_of_servers_hash).should == array_of_servers_hash
|
124
124
|
end
|
125
125
|
end
|
126
|
+
|
127
|
+
describe ".set_revision" do
|
128
|
+
["rev", "tag", "revision"].each do |word|
|
129
|
+
[word, word.upcase, "-S#{word}"].each do |variable|
|
130
|
+
it "returns the value of ENV['#{variable}']" do
|
131
|
+
value = Time.now.to_f.to_s
|
132
|
+
ENV["#{variable}"] = value
|
133
|
+
ChefCapHelper.set_revision.should == value
|
134
|
+
end
|
135
|
+
|
136
|
+
after :each do
|
137
|
+
ENV["#{variable}"] = nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe ".set_branch" do
|
144
|
+
["branch", "BRANCH", "-Sbranch"].each do |variable|
|
145
|
+
it "returns the value of ENV['#{variable}']" do
|
146
|
+
value = Time.now.to_f.to_s
|
147
|
+
ENV["#{variable}"] = value
|
148
|
+
ChefCapHelper.set_branch.should == value
|
149
|
+
end
|
150
|
+
|
151
|
+
after :each do
|
152
|
+
ENV["#{variable}"] = nil
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
126
157
|
end
|
data/spec/chef_cap_spec.rb
CHANGED
@@ -785,6 +785,7 @@ describe "chef_cap" do
|
|
785
785
|
|
786
786
|
it "shoves the value into the node json alongside branch" do
|
787
787
|
ENV['rev'] = "123"
|
788
|
+
ENV['branch'] = "somebranch"
|
788
789
|
chef_cap.stub!(:put => "stubbed")
|
789
790
|
chef_cap.stub!(:upload => "stubbed")
|
790
791
|
chef_cap.stub!(:sudo => "stubbed")
|
@@ -798,7 +799,7 @@ describe "chef_cap" do
|
|
798
799
|
"something"=>"other", "foo"=>"bar",
|
799
800
|
"chef"=>{"root"=>"path_to_cookbooks"},
|
800
801
|
"run_list"=>nil, "shared"=>{"foo"=>"bar"},
|
801
|
-
"environment"=> {"revision"=>"123", "servers"=>[{"primary" => [], "hostname"=>"localhost", "roles"=>["role1", "role2"]}]}, "roles"=>{"role1"=>{"something"=>"other"}}}
|
802
|
+
"environment"=> {"revision"=>"123", "branch" => "somebranch", "servers"=>[{"primary" => [], "hostname"=>"localhost", "roles"=>["role1", "role2"]}]}, "roles"=>{"role1"=>{"something"=>"other"}}}
|
802
803
|
)
|
803
804
|
}
|
804
805
|
chef_cap.cap_task["chef:deploy"].call
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Case Commons, LLC
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-21 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -45,11 +45,12 @@ files:
|
|
45
45
|
- .gitignore
|
46
46
|
- .rspec
|
47
47
|
- .rvmrc
|
48
|
+
- Capfile
|
48
49
|
- Gemfile
|
49
|
-
- Gemfile.lock
|
50
50
|
- LICENSE
|
51
51
|
- README.rdoc
|
52
52
|
- Rakefile
|
53
|
+
- chef/node.json
|
53
54
|
- chef_cap.gemspec
|
54
55
|
- fixtures/parser.json
|
55
56
|
- fixtures/ssh_deploy_key
|
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
capistrano (2.5.19)
|
5
|
-
highline
|
6
|
-
net-scp (>= 1.0.0)
|
7
|
-
net-sftp (>= 2.0.0)
|
8
|
-
net-ssh (>= 2.0.14)
|
9
|
-
net-ssh-gateway (>= 1.0.0)
|
10
|
-
diff-lcs (1.1.2)
|
11
|
-
highline (1.6.1)
|
12
|
-
net-scp (1.0.4)
|
13
|
-
net-ssh (>= 1.99.1)
|
14
|
-
net-sftp (2.0.5)
|
15
|
-
net-ssh (>= 2.0.9)
|
16
|
-
net-ssh (2.0.23)
|
17
|
-
net-ssh-gateway (1.0.1)
|
18
|
-
net-ssh (>= 1.99.1)
|
19
|
-
rspec (2.1.0)
|
20
|
-
rspec-core (~> 2.1.0)
|
21
|
-
rspec-expectations (~> 2.1.0)
|
22
|
-
rspec-mocks (~> 2.1.0)
|
23
|
-
rspec-core (2.1.0)
|
24
|
-
rspec-expectations (2.1.0)
|
25
|
-
diff-lcs (~> 1.1.2)
|
26
|
-
rspec-mocks (2.1.0)
|
27
|
-
rspec-rails (2.1.0)
|
28
|
-
rspec (~> 2.1.0)
|
29
|
-
wirble (0.1.3)
|
30
|
-
|
31
|
-
PLATFORMS
|
32
|
-
ruby
|
33
|
-
|
34
|
-
DEPENDENCIES
|
35
|
-
capistrano
|
36
|
-
rspec-rails (= 2.1)
|
37
|
-
wirble
|