capistrano-rbenv 1.0.5 → 2.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +2 -17
- data/CHANGELOG.md +13 -0
- data/README.md +24 -45
- data/Rakefile +0 -1
- data/capistrano-rbenv.gemspec +13 -12
- data/lib/capistrano-rbenv.rb +0 -378
- data/lib/capistrano/rbenv.rb +1 -0
- data/lib/capistrano/tasks/rbenv.rake +46 -0
- metadata +26 -51
- data/CHANGES.md +0 -34
- data/LICENSE +0 -22
- data/lib/capistrano-rbenv/version.rb +0 -5
- data/test/centos6-64/.gitignore +0 -5
- data/test/centos6-64/Capfile +0 -2
- data/test/centos6-64/Gemfile +0 -2
- data/test/centos6-64/Vagrantfile +0 -99
- data/test/centos6-64/run.sh +0 -7
- data/test/config/deploy.rb +0 -136
- data/test/precise64/.gitignore +0 -5
- data/test/precise64/Capfile +0 -2
- data/test/precise64/Gemfile +0 -2
- data/test/precise64/Vagrantfile +0 -99
- data/test/precise64/run.sh +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f39b8c5a594ab8e97a35dcf1d70a98eacfe5357a
|
4
|
+
data.tar.gz: 9aa3a513e2733cc4326f668f02a0dabc9f38be28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1a34c5d62e3631adc3c6b6996c7f7c6c4117b48a5b5f3e9a7ee8ecf03ed51dd264fa6676516e82855ea74db0604c170ec4bec489889e93d0767e990c8d87231
|
7
|
+
data.tar.gz: 11f77d78f691a1c32971d0efdee531af76af8bdd7c80d117f0935c1385be2c7dc11a75a61977eff9e7ba3f0707a1781719995fe3bb7a575fa5f89d6b8ebeed3c
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# 2.0.0
|
2
|
+
|
3
|
+
* Added ability to setup custom `rbenv_prefix` variable.
|
4
|
+
* prefix rails with rbenv by default
|
5
|
+
* Switching to new command map (https://github.com/capistrano/sshkit/pull/45)
|
6
|
+
This gives us more flexible integration and command mapping.
|
7
|
+
Fixed bug when `cap some_task` didn't invoke rbenv hooks.
|
8
|
+
|
9
|
+
Capistrano 3 -ready release.
|
10
|
+
|
11
|
+
# 1.0.5
|
12
|
+
|
13
|
+
Versions < 2.0 are located in another repo: https://github.com/yyuu/capistrano-rbenv
|
data/README.md
CHANGED
@@ -1,65 +1,44 @@
|
|
1
|
-
#
|
1
|
+
# Capistrano::rbenv
|
2
2
|
|
3
|
-
|
3
|
+
This gem provides idiomatic rbenv support for Capistrano 3.x (and 3.x
|
4
|
+
*only*).
|
5
|
+
|
6
|
+
## Please Note
|
7
|
+
|
8
|
+
If you want to use this plugin with Cap 2.x, please use 1.x version of the gem.
|
9
|
+
Source code and docs for older integration is available in [another repo](https://github.com/yyuu/capistrano-rbenv)
|
10
|
+
|
11
|
+
Thanks a lot to [@yyuu](https://github.com/yyuu) for merging his gem with official one.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
7
15
|
Add this line to your application's Gemfile:
|
8
16
|
|
9
|
-
gem 'capistrano
|
17
|
+
gem 'capistrano', '~> 3.0'
|
18
|
+
gem 'capistrano-rbenv', github: "capistrano/rbenv"
|
10
19
|
|
11
20
|
And then execute:
|
12
21
|
|
13
|
-
$ bundle
|
22
|
+
$ bundle install
|
14
23
|
|
15
|
-
|
24
|
+
## Usage
|
16
25
|
|
17
|
-
|
26
|
+
# Capfile
|
27
|
+
require 'capistrano/rbenv'
|
18
28
|
|
19
|
-
## Usage
|
20
29
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
set :rbenv_ruby_version, "1.9.3-p392"
|
29
|
-
```
|
30
|
-
|
31
|
-
Following options are available to manage your rbenv.
|
32
|
-
|
33
|
-
* `:rbenv_branch` - the git branch to install `rbenv` from. use `master` by default.
|
34
|
-
* `:rbenv_bundler_gem` - package name of `bundler`.
|
35
|
-
* `:rbenv_bundler_version` - version for `bundler` package.
|
36
|
-
* `:rbenv_cmd` - the `rbenv` command.
|
37
|
-
* `:rbenv_path` - the path where `rbenv` will be installed. use `$HOME/.rbenv` by default.
|
38
|
-
* `:rbenv_plugins` - rbenv plugins to install. install `ruby-build` by default.
|
39
|
-
* `:rbenv_repository` - repository URL of rbenv.
|
40
|
-
* `:rbenv_ruby_dependencies` - dependency packages.
|
41
|
-
* `:rbenv_ruby_version` - the ruby version to install. install `1.9.3-p392` by default.
|
42
|
-
* `:rbenv_install_bundler` - controls whether installing bundler or not. `true` by default.
|
43
|
-
* `:rbenv_install_dependencies` - controls whether installing dependencies or not. `true` if the required packages are missing.
|
44
|
-
* `:rbenv_setup_shell` - setup rbenv in your shell config or not. `true` by default. users who are using Chef/Puppet may prefer setting this value `false`.
|
45
|
-
* `:rbenv_setup_default_environment` - setup `RBENV_ROOT` and update `PATH` to use rbenv over capistrano. `true` by default.
|
46
|
-
* `:rbenv_configure_files` - list of shell configuration files to be configured for rbenv. by default, guessing from user's `$SHELL` and `$HOME`.
|
47
|
-
* `:rbenv_configure_basenames` - advanced option for `:rbenv_configure_files`. list of filename of your shell configuration files if you don't like the default value of `:rbenv_configure_files`.
|
30
|
+
# config/deploy.rb
|
31
|
+
set :rbenv_type, :user # or :system, depends on your rbenv setup
|
32
|
+
set :rbenv_ruby, '2.0.0-p247'
|
33
|
+
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
|
34
|
+
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
|
35
|
+
|
36
|
+
If your rbenv is located in some custom path, you can use `rbenv_custom_path` to set it.
|
48
37
|
|
49
38
|
## Contributing
|
50
39
|
|
51
40
|
1. Fork it
|
52
41
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
-
3. Commit your changes (`git commit -am '
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
43
|
4. Push to the branch (`git push origin my-new-feature`)
|
55
44
|
5. Create new Pull Request
|
56
|
-
|
57
|
-
## Author
|
58
|
-
|
59
|
-
- YAMASHITA Yuu (https://github.com/yyuu)
|
60
|
-
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
61
|
-
- Nico Schottelius (http://www.nico.schottelius.org/)
|
62
|
-
|
63
|
-
## License
|
64
|
-
|
65
|
-
MIT
|
data/Rakefile
CHANGED
data/capistrano-rbenv.gemspec
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
|
4
5
|
Gem::Specification.new do |gem|
|
5
|
-
gem.
|
6
|
-
gem.
|
7
|
-
gem.
|
8
|
-
gem.
|
9
|
-
gem.
|
6
|
+
gem.name = "capistrano-rbenv"
|
7
|
+
gem.version = '2.0.0'
|
8
|
+
gem.authors = ["Kir Shatrov", "Yamashita Yuu"]
|
9
|
+
gem.email = ["shatrov@me.com", "yamashita@geishatokyo.com"]
|
10
|
+
gem.description = %q{rbenv integration for Capistrano}
|
11
|
+
gem.summary = %q{rbenv integration for Capistrano}
|
12
|
+
gem.homepage = "https://github.com/capistrano/rbenv"
|
10
13
|
|
11
|
-
gem.files = `git ls-files`.split(
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split($/)
|
13
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name = "capistrano-rbenv"
|
15
16
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = Capistrano::RbEnv::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency
|
19
|
-
gem.add_dependency
|
18
|
+
gem.add_dependency 'capistrano', '~> 3.0'
|
19
|
+
gem.add_dependency 'sshkit', '~> 1.2.0'
|
20
|
+
|
20
21
|
end
|
data/lib/capistrano-rbenv.rb
CHANGED
@@ -1,378 +0,0 @@
|
|
1
|
-
require "capistrano-rbenv/version"
|
2
|
-
require "capistrano/configuration"
|
3
|
-
require "capistrano/configuration/resources/platform_resources"
|
4
|
-
require "capistrano/recipes/deploy/scm"
|
5
|
-
|
6
|
-
module Capistrano
|
7
|
-
module RbEnv
|
8
|
-
def self.extended(configuration)
|
9
|
-
configuration.load {
|
10
|
-
namespace(:rbenv) {
|
11
|
-
_cset(:rbenv_root, "$HOME/.rbenv")
|
12
|
-
_cset(:rbenv_path) {
|
13
|
-
# expand to actual path since rbenv may be executed by users other than `:user`.
|
14
|
-
capture("echo #{rbenv_root.dump}").strip
|
15
|
-
}
|
16
|
-
_cset(:rbenv_bin_path) { File.join(rbenv_path, "bin") }
|
17
|
-
_cset(:rbenv_shims_path) { File.join(rbenv_path, "shims") }
|
18
|
-
_cset(:rbenv_bin) {
|
19
|
-
File.join(rbenv_bin_path, "rbenv")
|
20
|
-
}
|
21
|
-
def rbenv_command(options={})
|
22
|
-
environment = _merge_environment(rbenv_environment, options.fetch(:env, {}))
|
23
|
-
environment["RBENV_VERSION"] = options[:version] if options.key?(:version)
|
24
|
-
if environment.empty?
|
25
|
-
rbenv_bin
|
26
|
-
else
|
27
|
-
env = (["env"] + environment.map { |k, v| "#{k}=#{v.dump}" }).join(" ")
|
28
|
-
"#{env} #{rbenv_bin}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
_cset(:rbenv_cmd) { rbenv_command(:version => rbenv_ruby_version) } # this declares RBENV_VERSION.
|
32
|
-
_cset(:rbenv_environment) {{
|
33
|
-
"RBENV_ROOT" => rbenv_path,
|
34
|
-
"PATH" => [ rbenv_shims_path, rbenv_bin_path, "$PATH" ].join(":"),
|
35
|
-
}}
|
36
|
-
_cset(:rbenv_repository, 'git://github.com/sstephenson/rbenv.git')
|
37
|
-
_cset(:rbenv_branch, 'master')
|
38
|
-
|
39
|
-
_cset(:rbenv_plugins) {{
|
40
|
-
"ruby-build" => { :repository => "git://github.com/sstephenson/ruby-build.git", :branch => "master" },
|
41
|
-
}}
|
42
|
-
_cset(:rbenv_plugins_options, {}) # for backward compatibility. plugin options can be configured from :rbenv_plugins.
|
43
|
-
_cset(:rbenv_plugins_path) {
|
44
|
-
File.join(rbenv_path, 'plugins')
|
45
|
-
}
|
46
|
-
_cset(:rbenv_ruby_version, "1.9.3-p392")
|
47
|
-
|
48
|
-
_cset(:rbenv_install_bundler) {
|
49
|
-
if exists?(:rbenv_use_bundler)
|
50
|
-
logger.info(":rbenv_use_bundler has been deprecated. use :rbenv_install_bundler instead.")
|
51
|
-
fetch(:rbenv_use_bundler, true)
|
52
|
-
else
|
53
|
-
true
|
54
|
-
end
|
55
|
-
}
|
56
|
-
set(:bundle_cmd) { # override bundle_cmd in "bundler/capistrano"
|
57
|
-
rbenv_install_bundler ? "#{rbenv_cmd} exec bundle" : "bundle"
|
58
|
-
}
|
59
|
-
|
60
|
-
_cset(:rbenv_install_dependencies) {
|
61
|
-
if rbenv_ruby_dependencies.empty?
|
62
|
-
false
|
63
|
-
else
|
64
|
-
not(platform.packages.installed?(rbenv_ruby_dependencies))
|
65
|
-
end
|
66
|
-
}
|
67
|
-
|
68
|
-
desc("Setup rbenv.")
|
69
|
-
task(:setup, :except => { :no_release => true }) {
|
70
|
-
#
|
71
|
-
# skip installation if the requested version has been installed.
|
72
|
-
#
|
73
|
-
reset!(:rbenv_ruby_versions)
|
74
|
-
begin
|
75
|
-
installed = rbenv_ruby_versions.include?(rbenv_ruby_version)
|
76
|
-
rescue
|
77
|
-
installed = false
|
78
|
-
end
|
79
|
-
_setup unless installed
|
80
|
-
configure if rbenv_setup_shell
|
81
|
-
rbenv.global(rbenv_ruby_version) if fetch(:rbenv_setup_global_version, true)
|
82
|
-
setup_bundler if rbenv_install_bundler
|
83
|
-
}
|
84
|
-
after "deploy:setup", "rbenv:setup"
|
85
|
-
|
86
|
-
task(:_setup, :except => { :no_release => true }) {
|
87
|
-
dependencies if rbenv_install_dependencies
|
88
|
-
update
|
89
|
-
build
|
90
|
-
}
|
91
|
-
|
92
|
-
def _update_repository(destination, options={})
|
93
|
-
configuration = Capistrano::Configuration.new()
|
94
|
-
options = {
|
95
|
-
:source => proc { Capistrano::Deploy::SCM.new(configuration[:scm], configuration) },
|
96
|
-
:revision => proc { configuration[:source].head },
|
97
|
-
:real_revision => proc {
|
98
|
-
configuration[:source].local.query_revision(configuration[:revision]) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } }
|
99
|
-
},
|
100
|
-
}.merge(options)
|
101
|
-
variables.merge(options).each do |key, val|
|
102
|
-
configuration.set(key, val)
|
103
|
-
end
|
104
|
-
source = configuration[:source]
|
105
|
-
revision = configuration[:real_revision]
|
106
|
-
#
|
107
|
-
# we cannot use source.sync since it cleans up untacked files in the repository.
|
108
|
-
# currently we are just calling git sub-commands directly to avoid the problems.
|
109
|
-
#
|
110
|
-
verbose = configuration[:scm_verbose] ? nil : "-q"
|
111
|
-
run((<<-EOS).gsub(/\s+/, ' ').strip)
|
112
|
-
if [ -d #{destination} ]; then
|
113
|
-
cd #{destination} &&
|
114
|
-
#{source.command} fetch #{verbose} #{source.origin} &&
|
115
|
-
#{source.command} fetch --tags #{verbose} #{source.origin} &&
|
116
|
-
#{source.command} reset #{verbose} --hard #{revision};
|
117
|
-
else
|
118
|
-
#{source.checkout(revision, destination)};
|
119
|
-
fi
|
120
|
-
EOS
|
121
|
-
end
|
122
|
-
|
123
|
-
desc("Update rbenv installation.")
|
124
|
-
task(:update, :except => { :no_release => true }) {
|
125
|
-
_update_repository(rbenv_path, :scm => :git, :repository => rbenv_repository, :branch => rbenv_branch)
|
126
|
-
plugins.update
|
127
|
-
}
|
128
|
-
|
129
|
-
_cset(:rbenv_setup_default_environment) {
|
130
|
-
if exists?(:rbenv_define_default_environment)
|
131
|
-
logger.info(":rbenv_define_default_environment has been deprecated. use :rbenv_setup_default_environment instead.")
|
132
|
-
fetch(:rbenv_define_default_environment, true)
|
133
|
-
else
|
134
|
-
true
|
135
|
-
end
|
136
|
-
}
|
137
|
-
# workaround for loading `capistrano-rbenv` later than `capistrano/ext/multistage`.
|
138
|
-
# https://github.com/yyuu/capistrano-rbenv/pull/5
|
139
|
-
if top.namespaces.key?(:multistage)
|
140
|
-
after "multistage:ensure", "rbenv:setup_default_environment"
|
141
|
-
else
|
142
|
-
on :load do
|
143
|
-
if top.namespaces.key?(:multistage)
|
144
|
-
# workaround for loading `capistrano-rbenv` earlier than `capistrano/ext/multistage`.
|
145
|
-
# https://github.com/yyuu/capistrano-rbenv/issues/7
|
146
|
-
after "multistage:ensure", "rbenv:setup_default_environment"
|
147
|
-
else
|
148
|
-
setup_default_environment
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
_cset(:rbenv_environment_join_keys, %w(DYLD_LIBRARY_PATH LD_LIBRARY_PATH MANPATH PATH))
|
154
|
-
def _merge_environment(x, y)
|
155
|
-
x.merge(y) { |key, x_val, y_val|
|
156
|
-
if rbenv_environment_join_keys.include?(key)
|
157
|
-
( y_val.split(":") + x_val.split(":") ).uniq.join(":")
|
158
|
-
else
|
159
|
-
y_val
|
160
|
-
end
|
161
|
-
}
|
162
|
-
end
|
163
|
-
|
164
|
-
task(:setup_default_environment, :except => { :no_release => true }) {
|
165
|
-
if rbenv_setup_default_environment
|
166
|
-
set(:default_environment, _merge_environment(default_environment, rbenv_environment))
|
167
|
-
end
|
168
|
-
}
|
169
|
-
|
170
|
-
desc("Purge rbenv.")
|
171
|
-
task(:purge, :except => { :no_release => true }) {
|
172
|
-
run("rm -rf #{rbenv_path.dump}")
|
173
|
-
}
|
174
|
-
|
175
|
-
namespace(:plugins) {
|
176
|
-
desc("Update rbenv plugins.")
|
177
|
-
task(:update, :except => { :no_release => true }) {
|
178
|
-
rbenv_plugins.each do |name, repository|
|
179
|
-
# for backward compatibility, obtain plugin options from :rbenv_plugins_options first
|
180
|
-
options = rbenv_plugins_options.fetch(name, {})
|
181
|
-
options = options.merge(Hash === repository ? repository : {:repository => repository})
|
182
|
-
_update_repository(File.join(rbenv_plugins_path, name), options.merge(:scm => :git))
|
183
|
-
end
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
_cset(:rbenv_configure_home) { capture("echo $HOME").chomp }
|
188
|
-
_cset(:rbenv_configure_shell) { capture("echo $SHELL").chomp }
|
189
|
-
_cset(:rbenv_configure_files) {
|
190
|
-
if fetch(:rbenv_configure_basenames, nil)
|
191
|
-
[ rbenv_configure_basenames ].flatten.map { |basename|
|
192
|
-
File.join(rbenv_configure_home, basename)
|
193
|
-
}
|
194
|
-
else
|
195
|
-
bash_profile = File.join(rbenv_configure_home, '.bash_profile')
|
196
|
-
profile = File.join(rbenv_configure_home, '.profile')
|
197
|
-
case File.basename(rbenv_configure_shell)
|
198
|
-
when /bash/
|
199
|
-
[ capture("test -f #{profile.dump} && echo #{profile.dump} || echo #{bash_profile.dump}").chomp ]
|
200
|
-
when /zsh/
|
201
|
-
[ File.join(rbenv_configure_home, '.zshenv') ]
|
202
|
-
else # other sh compatible shell such like dash
|
203
|
-
[ profile ]
|
204
|
-
end
|
205
|
-
end
|
206
|
-
}
|
207
|
-
_cset(:rbenv_configure_script) {
|
208
|
-
(<<-EOS).gsub(/^\s*/, '')
|
209
|
-
# Configured by capistrano-rbenv. Do not edit directly.
|
210
|
-
export PATH=#{[ rbenv_bin_path, "$PATH"].join(":").dump}
|
211
|
-
eval "$(rbenv init -)"
|
212
|
-
EOS
|
213
|
-
}
|
214
|
-
|
215
|
-
def _do_update_config(script_file, file, tempfile)
|
216
|
-
execute = []
|
217
|
-
## (1) ensure copy source file exists
|
218
|
-
execute << "( test -f #{file.dump} || touch #{file.dump} )"
|
219
|
-
## (2) copy originao config to temporary file
|
220
|
-
execute << "rm -f #{tempfile.dump}" # remove tempfile to preserve permissions of original file
|
221
|
-
execute << "cp -fp #{file.dump} #{tempfile.dump}"
|
222
|
-
## (3) modify temporary file
|
223
|
-
execute << "sed -i -e '/^#{Regexp.escape(rbenv_configure_signature)}/,/^#{Regexp.escape(rbenv_configure_signature)}/d' #{tempfile.dump}"
|
224
|
-
execute << "echo #{rbenv_configure_signature.dump} >> #{tempfile.dump}"
|
225
|
-
execute << "cat #{script_file.dump} >> #{tempfile.dump}"
|
226
|
-
execute << "echo #{rbenv_configure_signature.dump} >> #{tempfile.dump}"
|
227
|
-
## (4) update config only if it is needed
|
228
|
-
execute << "cp -fp #{file.dump} #{(file + ".orig").dump}"
|
229
|
-
execute << "( diff -u #{file.dump} #{tempfile.dump} || mv -f #{tempfile.dump} #{file.dump} )"
|
230
|
-
run(execute.join(" && "))
|
231
|
-
end
|
232
|
-
|
233
|
-
def _update_config(script_file, file)
|
234
|
-
begin
|
235
|
-
tempfile = capture("mktemp /tmp/rbenv.XXXXXXXXXX").strip
|
236
|
-
_do_update_config(script_file, file, tempfile)
|
237
|
-
ensure
|
238
|
-
run("rm -f #{tempfile.dump}") rescue nil
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
_cset(:rbenv_setup_shell) {
|
243
|
-
if exists?(:rbenv_use_configure)
|
244
|
-
logger.info(":rbenv_use_configure has been deprecated. please use :rbenv_setup_shell instead.")
|
245
|
-
fetch(:rbenv_use_configure, true)
|
246
|
-
else
|
247
|
-
true
|
248
|
-
end
|
249
|
-
}
|
250
|
-
_cset(:rbenv_configure_signature, '##rbenv:configure')
|
251
|
-
task(:configure, :except => { :no_release => true }) {
|
252
|
-
begin
|
253
|
-
script_file = capture("mktemp /tmp/rbenv.XXXXXXXXXX").strip
|
254
|
-
top.put(rbenv_configure_script, script_file)
|
255
|
-
[ rbenv_configure_files ].flatten.each do |file|
|
256
|
-
_update_config(script_file, file)
|
257
|
-
end
|
258
|
-
ensure
|
259
|
-
run("rm -f #{script_file.dump}") rescue nil
|
260
|
-
end
|
261
|
-
}
|
262
|
-
|
263
|
-
_cset(:rbenv_platform) { fetch(:platform_identifier) }
|
264
|
-
_cset(:rbenv_ruby_dependencies) {
|
265
|
-
case rbenv_platform.to_sym
|
266
|
-
when :debian, :ubuntu
|
267
|
-
%w(git-core build-essential libreadline6-dev zlib1g-dev libssl-dev bison)
|
268
|
-
when :redhat, :fedora, :centos, :amazon, :amazonami
|
269
|
-
%w(git-core autoconf gcc-c++ glibc-devel patch readline readline-devel zlib zlib-devel openssl openssl-devel bison)
|
270
|
-
else
|
271
|
-
[]
|
272
|
-
end
|
273
|
-
}
|
274
|
-
task(:dependencies, :except => { :no_release => true }) {
|
275
|
-
platform.packages.install(rbenv_ruby_dependencies)
|
276
|
-
}
|
277
|
-
|
278
|
-
_cset(:rbenv_ruby_versions) { rbenv.versions }
|
279
|
-
desc("Build ruby within rbenv.")
|
280
|
-
task(:build, :except => { :no_release => true }) {
|
281
|
-
# reset!(:rbenv_ruby_versions)
|
282
|
-
ruby = fetch(:rbenv_ruby_cmd, "ruby")
|
283
|
-
if rbenv_ruby_version != "system" and not rbenv_ruby_versions.include?(rbenv_ruby_version)
|
284
|
-
rbenv.install(rbenv_ruby_version)
|
285
|
-
end
|
286
|
-
rbenv.exec("#{ruby} --version") # check if ruby is executable
|
287
|
-
}
|
288
|
-
|
289
|
-
_cset(:rbenv_bundler_gem, 'bundler')
|
290
|
-
task(:setup_bundler, :except => { :no_release => true }) {
|
291
|
-
gem = "#{rbenv_cmd} exec gem"
|
292
|
-
if version = fetch(:rbenv_bundler_version, nil)
|
293
|
-
query_args = "-i -n #{rbenv_bundler_gem.dump} -v #{version.dump}"
|
294
|
-
install_args = "-v #{version.dump} #{rbenv_bundler_gem.dump}"
|
295
|
-
else
|
296
|
-
query_args = "-i -n #{rbenv_bundler_gem.dump}"
|
297
|
-
install_args = "#{rbenv_bundler_gem.dump}"
|
298
|
-
end
|
299
|
-
run("unset -v GEM_HOME; #{gem} query #{query_args} 2>/dev/null || #{gem} install -q #{install_args}")
|
300
|
-
rbenv.rehash
|
301
|
-
run("#{bundle_cmd} version")
|
302
|
-
}
|
303
|
-
|
304
|
-
# call `rbenv rehash` to update shims.
|
305
|
-
def rehash(options={})
|
306
|
-
invoke_command("#{rbenv_command} rehash", options)
|
307
|
-
end
|
308
|
-
|
309
|
-
def global(version, options={})
|
310
|
-
invoke_command("#{rbenv_command} global #{version.dump}", options)
|
311
|
-
end
|
312
|
-
|
313
|
-
def invoke_command_with_path(cmdline, options={})
|
314
|
-
path = options.delete(:path)
|
315
|
-
if path
|
316
|
-
chdir = "cd #{path.dump}"
|
317
|
-
via = options.delete(:via)
|
318
|
-
# as of Capistrano 2.14.2, `sudo()` cannot handle multiple command correctly.
|
319
|
-
if via == :sudo
|
320
|
-
invoke_command("#{chdir} && #{sudo} #{cmdline}", options)
|
321
|
-
else
|
322
|
-
invoke_command("#{chdir} && #{cmdline}", options.merge(:via => via))
|
323
|
-
end
|
324
|
-
else
|
325
|
-
invoke_command(cmdline, options)
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def local(version, options={})
|
330
|
-
invoke_command_with_path("#{rbenv_command} local #{version.dump}", options)
|
331
|
-
end
|
332
|
-
|
333
|
-
def which(command, options={})
|
334
|
-
version = ( options.delete(:version) || rbenv_ruby_version )
|
335
|
-
invoke_command_with_path("#{rbenv_command(:version => version)} which #{command.dump}", options)
|
336
|
-
end
|
337
|
-
|
338
|
-
def exec(command, options={})
|
339
|
-
# users of rbenv.exec must sanitize their command line.
|
340
|
-
version = ( options.delete(:version) || rbenv_ruby_version )
|
341
|
-
invoke_command_with_path("#{rbenv_command(:version => version)} exec #{command}", options)
|
342
|
-
end
|
343
|
-
|
344
|
-
def versions(options={})
|
345
|
-
capture("#{rbenv_command} versions --bare", options).split(/(?:\r?\n)+/)
|
346
|
-
end
|
347
|
-
|
348
|
-
def available_versions(options={})
|
349
|
-
capture("#{rbenv_command} install --complete", options).split(/(?:\r?\n)+/)
|
350
|
-
end
|
351
|
-
|
352
|
-
_cset(:rbenv_install_ruby_threads) {
|
353
|
-
capture("cat /proc/cpuinfo | cut -f1 | grep processor | wc -l").to_i rescue 1
|
354
|
-
}
|
355
|
-
# create build processes as many as processor count
|
356
|
-
_cset(:rbenv_make_options) { "-j #{rbenv_install_ruby_threads}" }
|
357
|
-
_cset(:rbenv_configure_options, nil)
|
358
|
-
def install(version, options={})
|
359
|
-
environment = {}
|
360
|
-
environment["CONFIGURE_OPTS"] = rbenv_configure_options.to_s if rbenv_configure_options
|
361
|
-
environment["MAKE_OPTS"] = rbenv_make_options.to_s if rbenv_make_options
|
362
|
-
invoke_command("#{rbenv_command(:env => environment)} install #{version.dump}", options)
|
363
|
-
end
|
364
|
-
|
365
|
-
def uninstall(version, options={})
|
366
|
-
invoke_command("#{rbenv_command} uninstall -f #{version.dump}", options)
|
367
|
-
end
|
368
|
-
}
|
369
|
-
}
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
if Capistrano::Configuration.instance
|
375
|
-
Capistrano::Configuration.instance.extend(Capistrano::RbEnv)
|
376
|
-
end
|
377
|
-
|
378
|
-
# vim:set ft=ruby ts=2 sw=2 :
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../tasks/rbenv.rake", __FILE__)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
namespace :rbenv do
|
2
|
+
task :validate do
|
3
|
+
on roles(:all) do
|
4
|
+
rbenv_ruby = fetch(:rbenv_ruby)
|
5
|
+
if rbenv_ruby.nil?
|
6
|
+
error "rbenv: rbenv_ruby is not set"
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
if test "[ ! -d #{fetch(:rbenv_ruby_dir)} ]"
|
11
|
+
error "rbenv: #{rbenv_ruby} is not installed or not found in #{fetch(:rbenv_ruby_dir)}"
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :map_bins do
|
18
|
+
rbenv_prefix = fetch(:rbenv_prefix, proc { "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" })
|
19
|
+
SSHKit.config.command_map[:rbenv] = "#{fetch(:rbenv_path)}/bin/rbenv"
|
20
|
+
|
21
|
+
fetch(:rbenv_map_bins).each do |command|
|
22
|
+
SSHKit.config.command_map.prefix[command.to_sym].unshift(rbenv_prefix)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Capistrano::DSL.stages.each do |stage|
|
28
|
+
after stage, 'rbenv:validate'
|
29
|
+
after stage, 'rbenv:map_bins'
|
30
|
+
end
|
31
|
+
|
32
|
+
namespace :load do
|
33
|
+
task :defaults do
|
34
|
+
set :rbenv_path, -> {
|
35
|
+
rbenv_path = fetch(:rbenv_custom_path)
|
36
|
+
rbenv_path ||= if fetch(:rbenv_type, :user) == :system
|
37
|
+
"/usr/local/rbenv"
|
38
|
+
else
|
39
|
+
"~/.rbenv"
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
set :rbenv_ruby_dir, -> { "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}" }
|
44
|
+
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-rbenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
7
|
+
- Kir Shatrov
|
8
8
|
- Yamashita Yuu
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - ~>
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3'
|
20
|
+
version: '3.0'
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3'
|
27
|
+
version: '3.0'
|
30
28
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
29
|
+
name: sshkit
|
32
30
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
31
|
requirements:
|
35
|
-
- -
|
32
|
+
- - ~>
|
36
33
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
34
|
+
version: 1.2.0
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
|
-
- -
|
39
|
+
- - ~>
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
description:
|
41
|
+
version: 1.2.0
|
42
|
+
description: rbenv integration for Capistrano
|
47
43
|
email:
|
44
|
+
- shatrov@me.com
|
48
45
|
- yamashita@geishatokyo.com
|
49
46
|
executables: []
|
50
47
|
extensions: []
|
51
48
|
extra_rdoc_files: []
|
52
49
|
files:
|
53
50
|
- .gitignore
|
54
|
-
-
|
51
|
+
- CHANGELOG.md
|
55
52
|
- Gemfile
|
56
|
-
- LICENSE
|
57
53
|
- README.md
|
58
54
|
- Rakefile
|
59
55
|
- capistrano-rbenv.gemspec
|
60
56
|
- lib/capistrano-rbenv.rb
|
61
|
-
- lib/capistrano
|
62
|
-
-
|
63
|
-
|
64
|
-
- test/centos6-64/Gemfile
|
65
|
-
- test/centos6-64/Vagrantfile
|
66
|
-
- test/centos6-64/run.sh
|
67
|
-
- test/config/deploy.rb
|
68
|
-
- test/precise64/.gitignore
|
69
|
-
- test/precise64/Capfile
|
70
|
-
- test/precise64/Gemfile
|
71
|
-
- test/precise64/Vagrantfile
|
72
|
-
- test/precise64/run.sh
|
73
|
-
homepage: https://github.com/yyuu/capistrano-rbenv
|
57
|
+
- lib/capistrano/rbenv.rb
|
58
|
+
- lib/capistrano/tasks/rbenv.rake
|
59
|
+
homepage: https://github.com/capistrano/rbenv
|
74
60
|
licenses: []
|
61
|
+
metadata: {}
|
75
62
|
post_install_message:
|
76
63
|
rdoc_options: []
|
77
64
|
require_paths:
|
78
65
|
- lib
|
79
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
67
|
requirements:
|
82
|
-
- -
|
68
|
+
- - '>='
|
83
69
|
- !ruby/object:Gem::Version
|
84
70
|
version: '0'
|
85
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
72
|
requirements:
|
88
|
-
- -
|
73
|
+
- - '>='
|
89
74
|
- !ruby/object:Gem::Version
|
90
75
|
version: '0'
|
91
76
|
requirements: []
|
92
77
|
rubyforge_project:
|
93
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.0.3
|
94
79
|
signing_key:
|
95
|
-
specification_version:
|
96
|
-
summary:
|
97
|
-
test_files:
|
98
|
-
|
99
|
-
- test/centos6-64/Capfile
|
100
|
-
- test/centos6-64/Gemfile
|
101
|
-
- test/centos6-64/Vagrantfile
|
102
|
-
- test/centos6-64/run.sh
|
103
|
-
- test/config/deploy.rb
|
104
|
-
- test/precise64/.gitignore
|
105
|
-
- test/precise64/Capfile
|
106
|
-
- test/precise64/Gemfile
|
107
|
-
- test/precise64/Vagrantfile
|
108
|
-
- test/precise64/run.sh
|
80
|
+
specification_version: 4
|
81
|
+
summary: rbenv integration for Capistrano
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|
data/CHANGES.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
v1.0.0 (Yamashita, Yuu)
|
2
|
-
|
3
|
-
* Rename some of options
|
4
|
-
* `:rbnev_use_bundler` -> `:rbenv_install_bundler`
|
5
|
-
* `:rbenv_use_configure` -> `:rbenv_setup_shell`
|
6
|
-
* `:rbenv_define_default_environment` -> `:rbenv_setup_default_environment`
|
7
|
-
* Update default ruby version (1.9.3-p327 -> 1.9.3p392)
|
8
|
-
* Add rbenv convenience methods such like `rbenv.global()` and `rbenv.exec()`.
|
9
|
-
* Add `:rbenv_make_options` and `:rbenv_configure_options` to control `ruby-build`. By default, create `make` jobs as much as processor count.
|
10
|
-
|
11
|
-
v1.0.1 (Yamashita, Yuu)
|
12
|
-
|
13
|
-
* Use [capistrano-platform-resources](https://github.com/yyuu/capistrano-platform-resources) to manage platform packages.
|
14
|
-
* Add `rbenv:setup_default_environment` task.
|
15
|
-
* Join `PATH` variables with ':' on generating `:default_environment` to respect pre-defined values.
|
16
|
-
* Fix a problem during invoking rbenv via sudo with path.
|
17
|
-
|
18
|
-
v1.0.2 (Yamashita, Yuu)
|
19
|
-
|
20
|
-
* Set up `:default_environment` after the loading of the recipes, not after the task start up.
|
21
|
-
* Fix a problem on generating `:default_environment`.
|
22
|
-
|
23
|
-
v1.0.3 (Yamashita, Yuu)
|
24
|
-
|
25
|
-
* Add support for extra flavors of RedHat.
|
26
|
-
* Remove useless gem dependencies.
|
27
|
-
|
28
|
-
v1.0.4 (Yamashita, Yuu)
|
29
|
-
|
30
|
-
* Fixed support for Amazon Linux. Thanks [@tk0miya](https://github.com/tk0miya).
|
31
|
-
|
32
|
-
v1.0.5 (Yamashita, Yuu)
|
33
|
-
|
34
|
-
* Install OpenSSL headers on RedHat. Thanks [@tk0miya](https://github.com/tk0miya).
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Yamashita Yuu
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/test/centos6-64/.gitignore
DELETED
data/test/centos6-64/Capfile
DELETED
data/test/centos6-64/Gemfile
DELETED
data/test/centos6-64/Vagrantfile
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant::Config.run do |config|
|
5
|
-
# All Vagrant configuration is done here. The most common configuration
|
6
|
-
# options are documented and commented below. For a complete reference,
|
7
|
-
# please see the online documentation at vagrantup.com.
|
8
|
-
|
9
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
10
|
-
config.vm.box = "centos6-64"
|
11
|
-
|
12
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
13
|
-
# doesn't already exist on the user's system.
|
14
|
-
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box"
|
15
|
-
|
16
|
-
# Boot with a GUI so you can see the screen. (Default is headless)
|
17
|
-
# config.vm.boot_mode = :gui
|
18
|
-
|
19
|
-
# Assign this VM to a host-only network IP, allowing you to access it
|
20
|
-
# via the IP. Host-only networks can talk to the host machine as well as
|
21
|
-
# any other machines on the same network, but cannot be accessed (through this
|
22
|
-
# network interface) by any external networks.
|
23
|
-
config.vm.network :hostonly, "192.168.33.10"
|
24
|
-
|
25
|
-
# Assign this VM to a bridged network, allowing you to connect directly to a
|
26
|
-
# network using the host's network device. This makes the VM appear as another
|
27
|
-
# physical device on your network.
|
28
|
-
# config.vm.network :bridged
|
29
|
-
|
30
|
-
# Forward a port from the guest to the host, which allows for outside
|
31
|
-
# computers to access the VM, whereas host only networking does not.
|
32
|
-
# config.vm.forward_port 80, 8080
|
33
|
-
|
34
|
-
# Share an additional folder to the guest VM. The first argument is
|
35
|
-
# an identifier, the second is the path on the guest to mount the
|
36
|
-
# folder, and the third is the path on the host to the actual folder.
|
37
|
-
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
|
38
|
-
|
39
|
-
# Enable provisioning with Puppet stand alone. Puppet manifests
|
40
|
-
# are contained in a directory path relative to this Vagrantfile.
|
41
|
-
# You will need to create the manifests directory and a manifest in
|
42
|
-
# the file precise-amd64.pp in the manifests_path directory.
|
43
|
-
#
|
44
|
-
# An example Puppet manifest to provision the message of the day:
|
45
|
-
#
|
46
|
-
# # group { "puppet":
|
47
|
-
# # ensure => "present",
|
48
|
-
# # }
|
49
|
-
# #
|
50
|
-
# # File { owner => 0, group => 0, mode => 0644 }
|
51
|
-
# #
|
52
|
-
# # file { '/etc/motd':
|
53
|
-
# # content => "Welcome to your Vagrant-built virtual machine!
|
54
|
-
# # Managed by Puppet.\n"
|
55
|
-
# # }
|
56
|
-
#
|
57
|
-
# config.vm.provision :puppet do |puppet|
|
58
|
-
# puppet.manifests_path = "manifests"
|
59
|
-
# puppet.manifest_file = "precise-amd64.pp"
|
60
|
-
# end
|
61
|
-
|
62
|
-
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
63
|
-
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
64
|
-
# some recipes and/or roles.
|
65
|
-
#
|
66
|
-
# config.vm.provision :chef_solo do |chef|
|
67
|
-
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
68
|
-
# chef.roles_path = "../my-recipes/roles"
|
69
|
-
# chef.data_bags_path = "../my-recipes/data_bags"
|
70
|
-
# chef.add_recipe "mysql"
|
71
|
-
# chef.add_role "web"
|
72
|
-
#
|
73
|
-
# # You may also specify custom JSON attributes:
|
74
|
-
# chef.json = { :mysql_password => "foo" }
|
75
|
-
# end
|
76
|
-
|
77
|
-
# Enable provisioning with chef server, specifying the chef server URL,
|
78
|
-
# and the path to the validation key (relative to this Vagrantfile).
|
79
|
-
#
|
80
|
-
# The Opscode Platform uses HTTPS. Substitute your organization for
|
81
|
-
# ORGNAME in the URL and validation key.
|
82
|
-
#
|
83
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
84
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
85
|
-
# validation key to validation.pem.
|
86
|
-
#
|
87
|
-
# config.vm.provision :chef_client do |chef|
|
88
|
-
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
89
|
-
# chef.validation_key_path = "ORGNAME-validator.pem"
|
90
|
-
# end
|
91
|
-
#
|
92
|
-
# If you're using the Opscode platform, your validator client is
|
93
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
94
|
-
#
|
95
|
-
# IF you have your own Chef Server, the default validation client name is
|
96
|
-
# chef-validator, unless you changed the configuration.
|
97
|
-
#
|
98
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
99
|
-
end
|
data/test/centos6-64/run.sh
DELETED
data/test/config/deploy.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
set :application, "capistrano-rbenv"
|
2
|
-
set :repository, "."
|
3
|
-
set :deploy_to do
|
4
|
-
File.join("/home", user, application)
|
5
|
-
end
|
6
|
-
set :deploy_via, :copy
|
7
|
-
set :scm, :none
|
8
|
-
set :use_sudo, false
|
9
|
-
set :user, "vagrant"
|
10
|
-
set :password, "vagrant"
|
11
|
-
set :ssh_options, {
|
12
|
-
:auth_methods => %w(publickey password),
|
13
|
-
:keys => File.join(ENV["HOME"], ".vagrant.d", "insecure_private_key"),
|
14
|
-
:user_known_hosts_file => "/dev/null"
|
15
|
-
}
|
16
|
-
|
17
|
-
role :web, "192.168.33.10"
|
18
|
-
role :app, "192.168.33.10"
|
19
|
-
role :db, "192.168.33.10", :primary => true
|
20
|
-
|
21
|
-
$LOAD_PATH.push(File.expand_path("../../lib", File.dirname(__FILE__)))
|
22
|
-
require "capistrano-rbenv"
|
23
|
-
|
24
|
-
task(:test_all) {
|
25
|
-
find_and_execute_task("test_default")
|
26
|
-
find_and_execute_task("test_without_global")
|
27
|
-
}
|
28
|
-
|
29
|
-
namespace(:test_default) {
|
30
|
-
task(:default) {
|
31
|
-
methods.grep(/^test_/).each do |m|
|
32
|
-
send(m)
|
33
|
-
end
|
34
|
-
}
|
35
|
-
before "test_default", "test_default:setup"
|
36
|
-
after "test_default", "test_default:teardown"
|
37
|
-
|
38
|
-
task(:setup) {
|
39
|
-
find_and_execute_task("rbenv:setup")
|
40
|
-
}
|
41
|
-
|
42
|
-
task(:teardown) {
|
43
|
-
}
|
44
|
-
|
45
|
-
task(:test_rbenv) {
|
46
|
-
run("rbenv --version")
|
47
|
-
}
|
48
|
-
|
49
|
-
## standard
|
50
|
-
task(:test_rbenv_exec) {
|
51
|
-
rbenv.exec("ruby --version")
|
52
|
-
}
|
53
|
-
|
54
|
-
task(:test_run_rbenv_exec) {
|
55
|
-
run("rbenv exec ruby --version")
|
56
|
-
}
|
57
|
-
|
58
|
-
## with path
|
59
|
-
task(:test_rbenv_exec_with_path) {
|
60
|
-
rbenv.exec("ruby -e 'exit(Dir.pwd==%{/}?0:1)'", :path => "/")
|
61
|
-
}
|
62
|
-
|
63
|
-
task(:test_rbenv_exec_ruby_via_sudo_with_path) {
|
64
|
-
# capistrano does not provide safer way to invoke multiple commands via sudo.
|
65
|
-
rbenv.exec("ruby -e 'exit(Dir.pwd==%{/}&&Process.uid==0?0:1)'", :path => "/", :via => :sudo )
|
66
|
-
}
|
67
|
-
|
68
|
-
## via sudo
|
69
|
-
task(:test_rbenv_exec_via_sudo) {
|
70
|
-
rbenv.exec("ruby -e 'exit(Process.uid==0?0:1)'", :via => :sudo)
|
71
|
-
}
|
72
|
-
|
73
|
-
task(:test_run_sudo_rbenv_exec) {
|
74
|
-
# we may not be able to invoke rbenv since sudo may reset $PATH.
|
75
|
-
# if you prefer to invoke rbenv via sudo, call it with absolute path.
|
76
|
-
# run("#{sudo} rbenv exec ruby -e 'exit(Process.uid==0?0:1)'")
|
77
|
-
run("#{sudo} #{rbenv_cmd} exec ruby -e 'exit(Process.uid==0?0:1)'")
|
78
|
-
}
|
79
|
-
|
80
|
-
task(:test_sudo_rbenv_exec) {
|
81
|
-
sudo("#{rbenv_cmd} exec ruby -e 'exit(Process.uid==0?0:1)'")
|
82
|
-
}
|
83
|
-
|
84
|
-
## bundler
|
85
|
-
task(:test_run_bundle) {
|
86
|
-
run("#{bundle_cmd} version")
|
87
|
-
}
|
88
|
-
|
89
|
-
task(:test_run_sudo_bundle) {
|
90
|
-
run("#{sudo} #{bundle_cmd} version")
|
91
|
-
}
|
92
|
-
|
93
|
-
task(:test_sudo_bundle) {
|
94
|
-
sudo("#{bundle_cmd} version")
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
namespace(:test_without_global) {
|
99
|
-
task(:default) {
|
100
|
-
methods.grep(/^test_/).each do |m|
|
101
|
-
send(m)
|
102
|
-
end
|
103
|
-
}
|
104
|
-
before "test_without_global", "test_without_global:setup"
|
105
|
-
after "test_without_global", "test_without_global:teardown"
|
106
|
-
|
107
|
-
task(:setup) {
|
108
|
-
version_file = File.join(rbenv_path, "version")
|
109
|
-
run("mv -f #{version_file} #{version_file}.orig")
|
110
|
-
set(:rbenv_setup_global_version, false)
|
111
|
-
find_and_execute_task("rbenv:setup")
|
112
|
-
run("test \! -f #{version_file.dump}")
|
113
|
-
}
|
114
|
-
|
115
|
-
task(:teardown) {
|
116
|
-
version_file = File.join(rbenv_path, "version")
|
117
|
-
run("mv -f #{version_file}.orig #{version_file}")
|
118
|
-
}
|
119
|
-
|
120
|
-
## standard
|
121
|
-
task(:test_rbenv_exec_ruby) {
|
122
|
-
rbenv.exec("ruby --version")
|
123
|
-
}
|
124
|
-
|
125
|
-
## with path
|
126
|
-
task(:test_rbenv_exec_ruby_with_path) {
|
127
|
-
rbenv.exec("ruby -e 'exit(Dir.pwd==%{/}?0:1)'", :path => "/")
|
128
|
-
}
|
129
|
-
|
130
|
-
## via sudo
|
131
|
-
task(:test_rbenv_exec_ruby_via_sudo) {
|
132
|
-
rbenv.exec("ruby -e 'exit(Process.uid==0?0:1)'", :via => :sudo)
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
# vim:set ft=ruby sw=2 ts=2 :
|
data/test/precise64/.gitignore
DELETED
data/test/precise64/Capfile
DELETED
data/test/precise64/Gemfile
DELETED
data/test/precise64/Vagrantfile
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant::Config.run do |config|
|
5
|
-
# All Vagrant configuration is done here. The most common configuration
|
6
|
-
# options are documented and commented below. For a complete reference,
|
7
|
-
# please see the online documentation at vagrantup.com.
|
8
|
-
|
9
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
10
|
-
config.vm.box = "precise64"
|
11
|
-
|
12
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
13
|
-
# doesn't already exist on the user's system.
|
14
|
-
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
15
|
-
|
16
|
-
# Boot with a GUI so you can see the screen. (Default is headless)
|
17
|
-
# config.vm.boot_mode = :gui
|
18
|
-
|
19
|
-
# Assign this VM to a host-only network IP, allowing you to access it
|
20
|
-
# via the IP. Host-only networks can talk to the host machine as well as
|
21
|
-
# any other machines on the same network, but cannot be accessed (through this
|
22
|
-
# network interface) by any external networks.
|
23
|
-
config.vm.network :hostonly, "192.168.33.10"
|
24
|
-
|
25
|
-
# Assign this VM to a bridged network, allowing you to connect directly to a
|
26
|
-
# network using the host's network device. This makes the VM appear as another
|
27
|
-
# physical device on your network.
|
28
|
-
# config.vm.network :bridged
|
29
|
-
|
30
|
-
# Forward a port from the guest to the host, which allows for outside
|
31
|
-
# computers to access the VM, whereas host only networking does not.
|
32
|
-
# config.vm.forward_port 80, 8080
|
33
|
-
|
34
|
-
# Share an additional folder to the guest VM. The first argument is
|
35
|
-
# an identifier, the second is the path on the guest to mount the
|
36
|
-
# folder, and the third is the path on the host to the actual folder.
|
37
|
-
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
|
38
|
-
|
39
|
-
# Enable provisioning with Puppet stand alone. Puppet manifests
|
40
|
-
# are contained in a directory path relative to this Vagrantfile.
|
41
|
-
# You will need to create the manifests directory and a manifest in
|
42
|
-
# the file precise-amd64.pp in the manifests_path directory.
|
43
|
-
#
|
44
|
-
# An example Puppet manifest to provision the message of the day:
|
45
|
-
#
|
46
|
-
# # group { "puppet":
|
47
|
-
# # ensure => "present",
|
48
|
-
# # }
|
49
|
-
# #
|
50
|
-
# # File { owner => 0, group => 0, mode => 0644 }
|
51
|
-
# #
|
52
|
-
# # file { '/etc/motd':
|
53
|
-
# # content => "Welcome to your Vagrant-built virtual machine!
|
54
|
-
# # Managed by Puppet.\n"
|
55
|
-
# # }
|
56
|
-
#
|
57
|
-
# config.vm.provision :puppet do |puppet|
|
58
|
-
# puppet.manifests_path = "manifests"
|
59
|
-
# puppet.manifest_file = "precise-amd64.pp"
|
60
|
-
# end
|
61
|
-
|
62
|
-
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
63
|
-
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
64
|
-
# some recipes and/or roles.
|
65
|
-
#
|
66
|
-
# config.vm.provision :chef_solo do |chef|
|
67
|
-
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
68
|
-
# chef.roles_path = "../my-recipes/roles"
|
69
|
-
# chef.data_bags_path = "../my-recipes/data_bags"
|
70
|
-
# chef.add_recipe "mysql"
|
71
|
-
# chef.add_role "web"
|
72
|
-
#
|
73
|
-
# # You may also specify custom JSON attributes:
|
74
|
-
# chef.json = { :mysql_password => "foo" }
|
75
|
-
# end
|
76
|
-
|
77
|
-
# Enable provisioning with chef server, specifying the chef server URL,
|
78
|
-
# and the path to the validation key (relative to this Vagrantfile).
|
79
|
-
#
|
80
|
-
# The Opscode Platform uses HTTPS. Substitute your organization for
|
81
|
-
# ORGNAME in the URL and validation key.
|
82
|
-
#
|
83
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
84
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
85
|
-
# validation key to validation.pem.
|
86
|
-
#
|
87
|
-
# config.vm.provision :chef_client do |chef|
|
88
|
-
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
89
|
-
# chef.validation_key_path = "ORGNAME-validator.pem"
|
90
|
-
# end
|
91
|
-
#
|
92
|
-
# If you're using the Opscode platform, your validator client is
|
93
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
94
|
-
#
|
95
|
-
# IF you have your own Chef Server, the default validation client name is
|
96
|
-
# chef-validator, unless you changed the configuration.
|
97
|
-
#
|
98
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
99
|
-
end
|