capushka 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/capushka.gemspec +25 -0
- data/lib/capushka.rb +50 -0
- data/lib/capushka/version.rb +3 -0
- data/lib/core_ext/hash.rb +21 -0
- data/readme.md +90 -0
- data/spec/capushka_spec.rb +5 -0
- data/spec/spec_helper.rb +9 -0
- metadata +124 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/capushka.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "capushka/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "capushka"
|
7
|
+
s.version = Capushka::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ivan Vanderbyl"]
|
10
|
+
s.homepage = "http://github.com/ivanvanderbyl/capushka"
|
11
|
+
s.summary = %q{Combines Babushka with Capistrano to allow you to run Babushka deps inside your recipes.}
|
12
|
+
s.description = %q{Combines Babushka with Capistrano to allow you to run Babushka deps inside your recipes. See https://github.com/ivanvanderbyl/capushka}
|
13
|
+
|
14
|
+
s.rubyforge_project = "capushka"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'capistrano', '~> 2.5.1'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rake', '~> 0.8.7'
|
24
|
+
s.add_development_dependency 'rspec', '~> 2.0.0'
|
25
|
+
end
|
data/lib/capushka.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
Dir.glob(File.dirname(__FILE__) + '/core_ext/*.rb') { |f| require f }
|
4
|
+
|
5
|
+
module Capushka
|
6
|
+
|
7
|
+
def bootstrap!
|
8
|
+
run %Q{bash -c "`wget -O- babushka.me/up/hard`"}
|
9
|
+
end
|
10
|
+
|
11
|
+
def babushka(task_name, vars = {})
|
12
|
+
write_vars task_name, vars
|
13
|
+
run "babushka '#{task_name}' --defaults", :pty => false, :shell => 'bash'
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_vars(task_name, vars = {})
|
17
|
+
if vars.any?
|
18
|
+
write_file(".babushka/vars/#{task_name}", {
|
19
|
+
:vars => vars.map_keys(&:to_s).map_values { |v| {:value => v} }
|
20
|
+
}.to_yaml)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_file(path, content)
|
25
|
+
put(content, path)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def default_opts
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
Capistrano.plugin :capushka, Capushka
|
37
|
+
|
38
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
39
|
+
Capistrano::Configuration.instance(:must_exist) :
|
40
|
+
Capistrano.configuration(:must_exist)
|
41
|
+
|
42
|
+
configuration.load do
|
43
|
+
def babushka(task, vars = {})
|
44
|
+
capushka.babushka(task, vars)
|
45
|
+
end
|
46
|
+
|
47
|
+
task :bootstrap_babushka do
|
48
|
+
capushka.bootstrap!
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Hash
|
2
|
+
def map_keys &blk
|
3
|
+
map_keys_with_values { |k, v| blk.call(k) }
|
4
|
+
end
|
5
|
+
|
6
|
+
def map_keys_with_values &blk
|
7
|
+
result = {}
|
8
|
+
each { |k, v| result[blk.call(k, v)] = v }
|
9
|
+
result
|
10
|
+
end
|
11
|
+
|
12
|
+
def map_values &blk
|
13
|
+
map_values_with_keys { |k, v| blk.call(v) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def map_values_with_keys &blk
|
17
|
+
result = {}
|
18
|
+
each { |k, v| result[k] = blk.call(k, v) }
|
19
|
+
result
|
20
|
+
end
|
21
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
Capistrano + Babushka = **Capushka**
|
2
|
+
====================================
|
3
|
+
|
4
|
+
This tiny gem does one thing: runs Babushka deps on all your servers from your Capistrano recipes and pass in variables.
|
5
|
+
|
6
|
+
Portions are based on Dollhouse.
|
7
|
+
|
8
|
+
Install
|
9
|
+
-------
|
10
|
+
|
11
|
+
Gemfile:
|
12
|
+
|
13
|
+
gem 'capushka'
|
14
|
+
|
15
|
+
Example
|
16
|
+
-------
|
17
|
+
|
18
|
+
in your config/deploy.rb
|
19
|
+
|
20
|
+
require "capushka"
|
21
|
+
|
22
|
+
...
|
23
|
+
# Usual deploy recipe stuff
|
24
|
+
...
|
25
|
+
|
26
|
+
namespace :setup do
|
27
|
+
task :create_application_user do
|
28
|
+
|
29
|
+
# This is the magic part
|
30
|
+
babushka 'benhoskings:user exists', {:username => application}
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
This will run Ben Hoskings' 'user exists' dep, which creates a new user in your application name, this is roughly equivalent to logging into each server and running:
|
36
|
+
|
37
|
+
babushka 'benhoskings:user exists'
|
38
|
+
|
39
|
+
And then entering the username every time it asks.
|
40
|
+
|
41
|
+
This does of course assume you have babushka bootstrapped, if not, run the `bootstrap_babushka` task
|
42
|
+
|
43
|
+
TODO:
|
44
|
+
====
|
45
|
+
|
46
|
+
- Better error checking and handling from Babushka
|
47
|
+
- Cleanup vars file when finished?
|
48
|
+
- Don't overwrite vars file very time, consider merging options.
|
49
|
+
- Cleanup STDOUT from babushka which doesn't play real nice with Capistrano
|
50
|
+
- Don't run in parallel?
|
51
|
+
- Write tests which work with Capistrano
|
52
|
+
|
53
|
+
Contributing
|
54
|
+
============
|
55
|
+
|
56
|
+
Once you've made your great commits:
|
57
|
+
|
58
|
+
1. Fork This repository
|
59
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
60
|
+
3. Push to your branch - `git push origin my_branch`
|
61
|
+
4. Send a pull request
|
62
|
+
5. That's it!
|
63
|
+
|
64
|
+
Authors
|
65
|
+
=======
|
66
|
+
|
67
|
+
Ivan Vanderbyl :: ivan at asterism dot com dot au :: [@IvanVanderbyl](http://twitter.com/ivanvanderbyl)
|
68
|
+
|
69
|
+
License
|
70
|
+
=======
|
71
|
+
|
72
|
+
Copyright (c) 2010 Ivan Vanderbyl
|
73
|
+
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
75
|
+
of this software and associated documentation files (the "Software"), to deal
|
76
|
+
in the Software without restriction, including without limitation the rights
|
77
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
78
|
+
copies of the Software, and to permit persons to whom the Software is
|
79
|
+
furnished to do so, subject to the following conditions:
|
80
|
+
|
81
|
+
The above copyright notice and this permission notice shall be included in
|
82
|
+
all copies or substantial portions of the Software.
|
83
|
+
|
84
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
85
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
86
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
87
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
88
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
89
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
90
|
+
THE SOFTWARE.
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capushka
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ivan Vanderbyl
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-27 00:00:00 +11:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: capistrano
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
33
|
+
- 1
|
34
|
+
version: 2.5.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 49
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 8
|
49
|
+
- 7
|
50
|
+
version: 0.8.7
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 15
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
version: 2.0.0
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
description: Combines Babushka with Capistrano to allow you to run Babushka deps inside your recipes. See https://github.com/ivanvanderbyl/capushka
|
70
|
+
email:
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files: []
|
76
|
+
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- Rakefile
|
81
|
+
- capushka.gemspec
|
82
|
+
- lib/capushka.rb
|
83
|
+
- lib/capushka/version.rb
|
84
|
+
- lib/core_ext/hash.rb
|
85
|
+
- readme.md
|
86
|
+
- spec/capushka_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://github.com/ivanvanderbyl/capushka
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project: capushka
|
118
|
+
rubygems_version: 1.3.7
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Combines Babushka with Capistrano to allow you to run Babushka deps inside your recipes.
|
122
|
+
test_files:
|
123
|
+
- spec/capushka_spec.rb
|
124
|
+
- spec/spec_helper.rb
|