rsyncinator 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rsyncinator.rb +7 -0
- data/lib/rsyncinator/built-in.rb +20 -0
- data/lib/rsyncinator/check.rb +24 -0
- data/lib/rsyncinator/config.rb +59 -0
- data/lib/rsyncinator/examples/Capfile +4 -0
- data/lib/rsyncinator/examples/config/deploy.rb +4 -0
- data/lib/rsyncinator/examples/config/deploy/staging.rb +14 -0
- data/lib/rsyncinator/rsync.rb +68 -0
- metadata +135 -0
data/lib/rsyncinator.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
set :rsync_user, -> { fetch(:deployment_username) }
|
2
|
+
set :rsync_log_file, -> { shared_path.join('log', 'rsyncinator.log') }
|
3
|
+
set :rsync_tail_lines, "10"
|
4
|
+
|
5
|
+
def rsync(host, from_host, source, destination)
|
6
|
+
execute(
|
7
|
+
"rsync", "-ah", fetch(:rsync_options),
|
8
|
+
"--rsh", "\"ssh", "-o", "PasswordAuthentication=no", "-o", "StrictHostKeyChecking=no\"",
|
9
|
+
"--log-file", fetch(:rsync_log_file),
|
10
|
+
"#{fetch(:rsync_user)}@#{from_host}:#{source}", destination
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def rsync_log_run(host)
|
15
|
+
capture("tac #{fetch(:rsync_log_file)} | grep 'receiving file list' -B100000 -m1 | tac")
|
16
|
+
end
|
17
|
+
|
18
|
+
def rsync_log_tail(host)
|
19
|
+
capture "tail", "-n", fetch(:rsync_tail_lines), fetch(:rsync_log_file)
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :rsync do
|
2
|
+
namespace :check do
|
3
|
+
|
4
|
+
desc 'Ensure all rsyncinator specific settings are set, and warn and exit if not.'
|
5
|
+
task :settings do
|
6
|
+
{
|
7
|
+
(File.dirname(__FILE__) + "/examples/config/deploy.rb") => 'config/deploy.rb',
|
8
|
+
(File.dirname(__FILE__) + "/examples/config/deploy/staging.rb") => "config/deploy/#{fetch(:stage)}.rb"
|
9
|
+
}.each do |abs, rel|
|
10
|
+
Rake::Task['deployinator:settings'].invoke(abs, rel)
|
11
|
+
Rake::Task['deployinator:settings'].reenable
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :settings do
|
16
|
+
desc 'Print example rsyncinator specific settings for comparison.'
|
17
|
+
task :print do
|
18
|
+
set :print_all, true
|
19
|
+
Rake::Task['rsync:check:settings'].invoke
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module TaskEnhancements
|
3
|
+
alias_method :rsync_original_default_tasks, :default_tasks
|
4
|
+
def default_tasks
|
5
|
+
rsync_original_default_tasks + [
|
6
|
+
"rsyncinator:write_built_in",
|
7
|
+
"rsyncinator:write_example_configs",
|
8
|
+
"rsyncinator:write_example_configs:in_place"
|
9
|
+
]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :rsyncinator do
|
15
|
+
|
16
|
+
set :example, "_example"
|
17
|
+
|
18
|
+
desc "Write example config files (with '_example' appended to their names)."
|
19
|
+
task :write_example_configs do
|
20
|
+
run_locally do
|
21
|
+
execute "mkdir", "-p", "config/deploy"
|
22
|
+
{
|
23
|
+
"examples/Capfile" => "Capfile#{fetch(:example)}",
|
24
|
+
"examples/config/deploy.rb" => "config/deploy#{fetch(:example)}.rb",
|
25
|
+
"examples/config/deploy/staging.rb" => "config/deploy/staging#{fetch(:example)}.rb"
|
26
|
+
}.each do |source, destination|
|
27
|
+
config = File.read(File.dirname(__FILE__) + "/#{source}")
|
28
|
+
File.open("./#{destination}", 'w') { |f| f.write(config) }
|
29
|
+
info "Wrote '#{destination}'"
|
30
|
+
end
|
31
|
+
unless fetch(:example).empty?
|
32
|
+
info "Now remove the '#{fetch(:example)}' portion of their names or diff with existing files and add the needed lines."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Write example config files (will overwrite any existing config files).'
|
38
|
+
namespace :write_example_configs do
|
39
|
+
task :in_place do
|
40
|
+
set :example, ""
|
41
|
+
Rake::Task['rsyncinator:write_example_configs'].invoke
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Write a file showing the built-in overridable settings.'
|
46
|
+
task :write_built_in do
|
47
|
+
run_locally do
|
48
|
+
{
|
49
|
+
'built-in.rb' => 'built-in.rb',
|
50
|
+
}.each do |source, destination|
|
51
|
+
config = File.read(File.dirname(__FILE__) + "/#{source}")
|
52
|
+
File.open("./#{destination}", 'w') { |f| f.write(config) }
|
53
|
+
info "Wrote '#{destination}'"
|
54
|
+
end
|
55
|
+
info "Now examine the file and copy-paste into your deploy.rb or <stage>.rb and customize."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
##### rsyncinator
|
2
|
+
### ------------------------------------------------------------------
|
3
|
+
server "my-app-stage.example.com",
|
4
|
+
:user => fetch(:deployment_username),
|
5
|
+
:rsyncs => [ # rsyncinator
|
6
|
+
{
|
7
|
+
:from => "my-app.example.com",
|
8
|
+
:dirs => {
|
9
|
+
shared_path.join("var", "images") => shared_path.join("var", "images"),
|
10
|
+
shared_path.join("public", "images") => shared_path.join("public", "images")
|
11
|
+
}
|
12
|
+
}
|
13
|
+
]
|
14
|
+
### ------------------------------------------------------------------
|
@@ -0,0 +1,68 @@
|
|
1
|
+
desc "Rsync according to each host's settings"
|
2
|
+
task :rsync do
|
3
|
+
on roles(:all) do |host|
|
4
|
+
as :root do
|
5
|
+
with :ssh_auth_sock => capture("echo $SSH_AUTH_SOCK") do
|
6
|
+
if host.properties.rsyncs.nil?
|
7
|
+
info ""
|
8
|
+
info "No syncs defined for #{host}"
|
9
|
+
else
|
10
|
+
execute "mkdir", "-p", Pathname.new(fetch(:rsync_log_file)).split.first.to_s
|
11
|
+
host.properties.rsyncs.each do |sync|
|
12
|
+
sync[:dirs].each do |source, destination|
|
13
|
+
rsync(host, sync[:from], source, destination)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :rsync do
|
23
|
+
|
24
|
+
desc "Rsync according to each host's settings using the --dry-run option"
|
25
|
+
task :dry do
|
26
|
+
set :rsync_options, "--dry-run"
|
27
|
+
Rake::Task["rsync"].invoke
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Rsync according to each host's settings using the --delete option"
|
31
|
+
task :delete do
|
32
|
+
set :rsync_options, "--delete"
|
33
|
+
Rake::Task["rsync"].invoke
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :delete do
|
37
|
+
desc "Rsync according to each host's settings using the --delete and --dry-run options"
|
38
|
+
task :dry do
|
39
|
+
set :rsync_options, "--dry-run --delete"
|
40
|
+
Rake::Task["rsync"].invoke
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Show the latest sync in the log file"
|
45
|
+
task :log do
|
46
|
+
on roles(:all), in: :sequence do |host|
|
47
|
+
as :root do
|
48
|
+
info "Latest Rsync run on #{host}"
|
49
|
+
rsync_log_run(host).lines.each { |line| info line }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
namespace :log do
|
55
|
+
desc "Show the last few lines of the sync's log file"
|
56
|
+
task :tail do
|
57
|
+
on roles(:all), in: :sequence do |host|
|
58
|
+
as :root do
|
59
|
+
info "From #{host}:"
|
60
|
+
rsync_log_tail(host).lines.each { |line| info line }
|
61
|
+
info ""
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsyncinator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- david amick
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: deployinator
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.1.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: colorize
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.7.3
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 10.3.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 10.3.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sshkit
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.5.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.5.1
|
94
|
+
description: Capistrano Plugin to rsync between roles
|
95
|
+
email: davidamick@ctisolutionsinc.com
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- lib/rsyncinator.rb
|
101
|
+
- lib/rsyncinator/rsync.rb
|
102
|
+
- lib/rsyncinator/config.rb
|
103
|
+
- lib/rsyncinator/check.rb
|
104
|
+
- lib/rsyncinator/built-in.rb
|
105
|
+
- lib/rsyncinator/examples/Capfile
|
106
|
+
- lib/rsyncinator/examples/config/deploy.rb
|
107
|
+
- lib/rsyncinator/examples/config/deploy/staging.rb
|
108
|
+
homepage: https://github.com/snarlysodboxer/rsyncinator
|
109
|
+
licenses:
|
110
|
+
- GNU
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.9.3
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements:
|
128
|
+
- Rsync
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.8.23.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: Rsync between roles
|
134
|
+
test_files: []
|
135
|
+
has_rdoc:
|