cap-strap 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cap-strap might be problematic. Click here for more details.
- data/.gitignore +1 -0
- data/Capfile +4 -0
- data/Guardfile +6 -0
- data/README.md +27 -8
- data/Rakefile +27 -0
- data/Vagrantfile +10 -0
- data/cap-strap.gemspec +9 -6
- data/config/deploy.rb +24 -0
- data/config/test-authorized-keys +1 -0
- data/config/test-deploy-key +1 -0
- data/lib/cap-strap/helpers.rb +13 -6
- data/lib/cap-strap/recipes/bootstrap.rb +3 -1
- data/lib/cap-strap/recipes/rvm.rb +1 -2
- data/spec/rvm_spec.rb +7 -2
- metadata +49 -30
data/.gitignore
CHANGED
data/Capfile
ADDED
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# cap-strap
|
2
2
|
|
3
|
-
|
4
|
-
It installs System-wide
|
5
|
-
deploy
|
3
|
+
cap-strap is a Capistrano Extension that bootstraps a machine for future capistrano tasks.
|
4
|
+
It installs System-wide RVM and specified rubies and gems. It will create a deploy user, upload authorized_keys and
|
5
|
+
deploy key.
|
6
6
|
|
7
7
|
## Notes
|
8
8
|
|
9
|
-
Currently only Ubuntu 10.04 and 10.10
|
9
|
+
Currently cap-strap has only been tested on Ubuntu 10.04 and 10.10.
|
10
10
|
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
14
14
|
Add this line to your application's Gemfile:
|
15
15
|
|
16
|
-
gem 'cap-strap'
|
16
|
+
gem 'cap-strap'
|
17
17
|
|
18
18
|
And then execute:
|
19
19
|
|
@@ -22,9 +22,12 @@ And then execute:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
You will be prompted for the name of the future deploy_user, location of authorized keys and
|
25
|
-
the deploy_key. Deploy key isn't required, and you may skip.
|
25
|
+
the deploy user's deploy_key. Deploy key isn't required, and you may skip.
|
26
|
+
|
27
|
+
You may re-run the deploy_key task by `$ cap <stage> bootstrap:upload_deploy_key`
|
26
28
|
|
27
29
|
In your deploy.rb, you may override the following variables:
|
30
|
+
|
28
31
|
Note: Paths are relative to the root
|
29
32
|
|
30
33
|
* `set :deploy_user, "<name of user for future deployes>"`
|
@@ -51,7 +54,23 @@ Note: Run from project root
|
|
51
54
|
We're https://github.com/technicalpickles/capistrano-spec for testing the capistrano
|
52
55
|
configuration.
|
53
56
|
|
54
|
-
###
|
57
|
+
### Testing with Vagrant
|
58
|
+
|
59
|
+
Vagrant will fetch a lucid-64 box and boot it up. Once started, it will run
|
60
|
+
cap bootstrap on the vagrant box.
|
61
|
+
|
62
|
+
To run: `bundle exec rake vagrant_test`
|
63
|
+
|
64
|
+
To reload the box and run again: `bundle exec rake vagrant_test:restart`
|
65
|
+
|
66
|
+
Vagrant Notes:
|
67
|
+
|
68
|
+
* `vagrant ssh` - will ssh into the vagrant VM.
|
69
|
+
* lucid64 root user and password is "vagrant"
|
70
|
+
* vagrant box runs on port 2222
|
71
|
+
* `vagrant destroy` - will destroy the current vagrant VM. It doesn't remove the large downloaded box.
|
72
|
+
|
73
|
+
For more information regarding Vagrant: http://vagrantup.com/
|
55
74
|
|
56
75
|
## Contributing
|
57
76
|
|
data/Rakefile
CHANGED
@@ -3,6 +3,33 @@ require "rspec/core/rake_task"
|
|
3
3
|
|
4
4
|
task :default => :spec
|
5
5
|
|
6
|
+
desc "Test cap-strap on a local virtual machine, courtesy of vagrant."
|
7
|
+
task :vagrant_test => ["vagrant_test:default"]
|
8
|
+
|
9
|
+
namespace :vagrant_test do
|
10
|
+
|
11
|
+
task :default => [:up, :test]
|
12
|
+
|
13
|
+
task :test do
|
14
|
+
puts "Running cap bootstrap"
|
15
|
+
%x[bundle exec cap bootstrap]
|
16
|
+
end
|
17
|
+
|
18
|
+
task :restart => [:down, :up, :test]
|
19
|
+
|
20
|
+
task :down do
|
21
|
+
puts "Forcing vagrant shutdown"
|
22
|
+
%x[bundle exec vagrant destroy --force]
|
23
|
+
end
|
24
|
+
|
25
|
+
task :up do
|
26
|
+
puts "WARNING: This will take a while..."
|
27
|
+
puts "Starting up vagrant"
|
28
|
+
%x[bundle exec vagrant up]
|
29
|
+
puts "Vagrant is up."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
6
33
|
Rspec::Core::RakeTask.new do |t|
|
7
34
|
t.pattern = "./spec/*_spec.rb"
|
8
35
|
end
|
data/Vagrantfile
ADDED
data/cap-strap.gemspec
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "cap-strap/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "cap-strap"
|
7
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.4"
|
8
7
|
s.authors = ["Shaun Dern"]
|
9
8
|
s.email = ["shaun@substantial.com"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary = %q{Bootstrap a new machine
|
9
|
+
s.homepage = "http://github.com/substantial/cap-strap"
|
10
|
+
s.summary = %q{Bootstrap a new machine. Use with Capistrano to fully automate your provisioning.}
|
12
11
|
s.description = %q{Bootstrap a machine. Create a deploy user, upload authorized keys and deploy key. Uses RVM to install desired rubies, with patch support.}
|
13
12
|
|
14
13
|
s.rubyforge_project = "cap-strap"
|
@@ -18,9 +17,13 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
20
|
+
s.add_development_dependency "rake", "~> 0.9.2.2"
|
21
21
|
s.add_development_dependency "capistrano", '>= 2.0.0'
|
22
|
-
s.add_development_dependency "capistrano-spec"
|
23
|
-
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "capistrano-spec","~> 0.1.0"
|
23
|
+
s.add_development_dependency "rspec", "~> 2.9.0"
|
24
|
+
s.add_development_dependency "guard-rspec", "~> 0.7.0"
|
25
|
+
s.add_development_dependency "vagrant", "~> 1.0.2"
|
26
|
+
|
24
27
|
|
25
28
|
s.add_runtime_dependency "capistrano", ">= 2.0.0"
|
26
29
|
end
|
data/config/deploy.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'cap-strap'
|
2
|
+
|
3
|
+
server "localhost", :test
|
4
|
+
|
5
|
+
set :port, 2222
|
6
|
+
|
7
|
+
set :user, "vagrant"
|
8
|
+
set :password, "vagrant"
|
9
|
+
|
10
|
+
set :gemset, "build-agent"
|
11
|
+
set :rubies, [
|
12
|
+
"1.9.3-p125",
|
13
|
+
{
|
14
|
+
:version => "1.9.3-p125-perf",
|
15
|
+
:patch => "falcon,debug --force-autoconf -j 3"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
|
19
|
+
set :default_ruby, "1.9.3-p125-perf"
|
20
|
+
|
21
|
+
set :deploy_user, "deploy"
|
22
|
+
set :group, "rvm"
|
23
|
+
set :authorized_keys_file, "config/test-authorized-keys"
|
24
|
+
set :deploy_key_file, "config/test-deploy-key"
|
@@ -0,0 +1 @@
|
|
1
|
+
Authorized Keys
|
@@ -0,0 +1 @@
|
|
1
|
+
deploy_user's deploy key
|
data/lib/cap-strap/helpers.rb
CHANGED
@@ -43,15 +43,22 @@ def user_exists?(user)
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def default_known_hosts
|
46
|
-
|
46
|
+
<<TEXT
|
47
47
|
github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
48
|
-
|
48
|
+
TEXT
|
49
|
+
end
|
50
|
+
|
51
|
+
def ruby_installed?(ruby)
|
52
|
+
ruby_test = "source /etc/profile.d/rvm.sh && if rvm list | grep -q '#{ruby} '; then echo 'true'; else echo 'false'; fi"
|
53
|
+
return capture(rvm_wrapper(ruby_test)).include?("true")
|
49
54
|
end
|
50
55
|
|
51
56
|
def install_ruby(ruby, patch = nil)
|
52
|
-
|
53
|
-
|
54
|
-
|
57
|
+
unless ruby_installed?(ruby)
|
58
|
+
command = "rvm install #{ruby}"
|
59
|
+
command << " --patch #{patch}" if patch
|
60
|
+
sudo rvm_wrapper(command)
|
61
|
+
end
|
55
62
|
end
|
56
63
|
|
57
64
|
def install_global_gem(ruby, gem)
|
@@ -59,7 +66,7 @@ def install_global_gem(ruby, gem)
|
|
59
66
|
end
|
60
67
|
|
61
68
|
def rvm_wrapper(command)
|
62
|
-
"bash -c
|
69
|
+
"bash -c \". /etc/profile.d/rvm.sh && #{command}\""
|
63
70
|
end
|
64
71
|
|
65
72
|
def gemrc
|
@@ -20,7 +20,7 @@ module Capistrano
|
|
20
20
|
_cset(:known_hosts) { default_known_hosts }
|
21
21
|
|
22
22
|
namespace :bootstrap do
|
23
|
-
desc "
|
23
|
+
desc "Bootstraps a fresh box. Install RVM, create the deploy user, upload keys."
|
24
24
|
task :default do
|
25
25
|
rvm.default
|
26
26
|
bootstrap.create_deploy_user
|
@@ -36,6 +36,8 @@ module Capistrano
|
|
36
36
|
add_user_to_group(deploy_user, "admin")
|
37
37
|
end
|
38
38
|
|
39
|
+
desc "Upload authorized keys for the deploy_user. Override by setting :authorized_keys_file. This
|
40
|
+
is the relative path from the project root"
|
39
41
|
task :upload_deploy_authorized_keys do
|
40
42
|
begin
|
41
43
|
authorized_keys_path = File.join(File.expand_path(Dir.pwd), authorized_keys_file)
|
@@ -7,7 +7,7 @@ module Capistrano
|
|
7
7
|
|
8
8
|
_cset :default_ruby , "1.9.3-p125"
|
9
9
|
_cset :gemset, "global"
|
10
|
-
_cset :rubies, []
|
10
|
+
_cset :rubies, ["1.9.3-p125"]
|
11
11
|
_cset(:user) { Capistrano::CLI.ui.ask("bootstrap root user: ") }
|
12
12
|
_cset :global_gems, ["bundler"]
|
13
13
|
|
@@ -31,7 +31,6 @@ module Capistrano
|
|
31
31
|
end
|
32
32
|
|
33
33
|
task :install_rubies do
|
34
|
-
rubies << default_ruby
|
35
34
|
rubies.each do |rubie|
|
36
35
|
if rubie.is_a?(Hash)
|
37
36
|
ruby = rubie.fetch(:version)
|
data/spec/rvm_spec.rb
CHANGED
@@ -22,8 +22,13 @@ describe Capistrano::RVM do
|
|
22
22
|
@configuration.fetch(:gemset).should be
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
@configuration.fetch(:rubies).length.should be
|
25
|
+
it "has a rubie ruby set" do
|
26
|
+
@configuration.fetch(:rubies).length.should be 1
|
27
|
+
end
|
28
|
+
|
29
|
+
it "ruby is the default rubie" do
|
30
|
+
default_ruby = @configuration.fetch(:default_ruby)
|
31
|
+
@configuration.fetch(:rubies).first.should == default_ruby
|
27
32
|
end
|
28
33
|
|
29
34
|
it "has bundler in it's global gems" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap-strap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,59 +9,77 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
15
|
+
name: rake
|
16
|
+
requirement: &70250544779080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 0.9.2.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: *70250544779080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: capistrano
|
27
|
+
requirement: &70250544778420 !ruby/object:Gem::Requirement
|
25
28
|
none: false
|
26
29
|
requirements:
|
27
30
|
- - ! '>='
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 2.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70250544778420
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
37
|
name: capistrano-spec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70250544777660 !ruby/object:Gem::Requirement
|
33
39
|
none: false
|
34
40
|
requirements:
|
35
|
-
- -
|
41
|
+
- - ~>
|
36
42
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
43
|
+
version: 0.1.0
|
38
44
|
type: :development
|
39
45
|
prerelease: false
|
40
|
-
version_requirements:
|
46
|
+
version_requirements: *70250544777660
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &70250544777100 !ruby/object:Gem::Requirement
|
41
50
|
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - ~>
|
44
53
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
54
|
+
version: 2.9.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70250544777100
|
46
58
|
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
+
name: guard-rspec
|
60
|
+
requirement: &70250544776580 !ruby/object:Gem::Requirement
|
49
61
|
none: false
|
50
62
|
requirements:
|
51
|
-
- -
|
63
|
+
- - ~>
|
52
64
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
65
|
+
version: 0.7.0
|
54
66
|
type: :development
|
55
67
|
prerelease: false
|
56
|
-
version_requirements:
|
68
|
+
version_requirements: *70250544776580
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vagrant
|
71
|
+
requirement: &70250544776120 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
73
|
requirements:
|
59
|
-
- -
|
74
|
+
- - ~>
|
60
75
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
76
|
+
version: 1.0.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70250544776120
|
62
80
|
- !ruby/object:Gem::Dependency
|
63
81
|
name: capistrano
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
+
requirement: &70250544775660 !ruby/object:Gem::Requirement
|
65
83
|
none: false
|
66
84
|
requirements:
|
67
85
|
- - ! '>='
|
@@ -69,12 +87,7 @@ dependencies:
|
|
69
87
|
version: 2.0.0
|
70
88
|
type: :runtime
|
71
89
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 2.0.0
|
90
|
+
version_requirements: *70250544775660
|
78
91
|
description: Bootstrap a machine. Create a deploy user, upload authorized keys and
|
79
92
|
deploy key. Uses RVM to install desired rubies, with patch support.
|
80
93
|
email:
|
@@ -84,10 +97,16 @@ extensions: []
|
|
84
97
|
extra_rdoc_files: []
|
85
98
|
files:
|
86
99
|
- .gitignore
|
100
|
+
- Capfile
|
87
101
|
- Gemfile
|
102
|
+
- Guardfile
|
88
103
|
- README.md
|
89
104
|
- Rakefile
|
105
|
+
- Vagrantfile
|
90
106
|
- cap-strap.gemspec
|
107
|
+
- config/deploy.rb
|
108
|
+
- config/test-authorized-keys
|
109
|
+
- config/test-deploy-key
|
91
110
|
- lib/cap-strap.rb
|
92
111
|
- lib/cap-strap/helpers.rb
|
93
112
|
- lib/cap-strap/recipes/bootstrap.rb
|
@@ -95,7 +114,7 @@ files:
|
|
95
114
|
- spec/bootstrap_spec.rb
|
96
115
|
- spec/rvm_spec.rb
|
97
116
|
- spec/spec_helper.rb
|
98
|
-
homepage:
|
117
|
+
homepage: http://github.com/substantial/cap-strap
|
99
118
|
licenses: []
|
100
119
|
post_install_message:
|
101
120
|
rdoc_options: []
|
@@ -115,10 +134,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
134
|
version: '0'
|
116
135
|
requirements: []
|
117
136
|
rubyforge_project: cap-strap
|
118
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.10
|
119
138
|
signing_key:
|
120
139
|
specification_version: 3
|
121
|
-
summary: Bootstrap a new machine
|
140
|
+
summary: Bootstrap a new machine. Use with Capistrano to fully automate your provisioning.
|
122
141
|
test_files:
|
123
142
|
- spec/bootstrap_spec.rb
|
124
143
|
- spec/rvm_spec.rb
|