vagrant-rsync 0.2.0 → 0.2.1
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.
- data/lib/vagrant-rsync/cap/ensure_rsync.rb +46 -0
- data/lib/vagrant-rsync/cap/rsync_folders.rb +43 -0
- data/lib/vagrant-rsync/command.rb +50 -0
- data/lib/vagrant-rsync/errors.rb +10 -0
- data/lib/{plugin.rb → vagrant-rsync/plugin.rb} +15 -2
- data/lib/vagrant-rsync/version.rb +5 -0
- data/lib/vagrant-rsync.rb +4 -1
- data/locales/en.yml +14 -0
- data/vagrant-rsync.gemspec +4 -4
- metadata +62 -38
- checksums.yaml +0 -15
- data/lib/command.rb +0 -111
- data/lib/version.rb +0 -5
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../errors'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rsync
|
5
|
+
module Cap
|
6
|
+
class EnsureRsync
|
7
|
+
|
8
|
+
def self.ensure_rsync(machine, env)
|
9
|
+
return unless machine.communicate.ready?
|
10
|
+
|
11
|
+
if rsync_installed?(machine)
|
12
|
+
env.ui.info I18n.t('vagrant_rsync.rsync_installed')
|
13
|
+
else
|
14
|
+
env.ui.info I18n.t('vagrant_rsync.installing_rsync')
|
15
|
+
install_rsync!(machine)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.rsync_installed?(machine)
|
20
|
+
machine.communicate.execute("rsync --version") rescue false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.install_rsync!(machine)
|
24
|
+
machine.communicate.tap do |comm|
|
25
|
+
case machine.guest.name
|
26
|
+
when :debian, :ubuntu
|
27
|
+
comm.sudo "apt-get update"
|
28
|
+
comm.sudo "apt-get install rsync"
|
29
|
+
when :fedora, :centos, :redhat
|
30
|
+
comm.sudo "yum install rsync"
|
31
|
+
when :suse
|
32
|
+
comm.sudo "yast2 -i rsync"
|
33
|
+
when :gentoo
|
34
|
+
comm.sudo "emerge rsync"
|
35
|
+
when :arch
|
36
|
+
comm.sudo "pacman -s rsync"
|
37
|
+
else
|
38
|
+
raise Errors::RsyncNotAvailableError, guest: machine.guest.name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Rsync
|
3
|
+
module Cap
|
4
|
+
class RsyncFolders
|
5
|
+
def self.rsync_folders(machine)
|
6
|
+
machine.config.vm.synced_folders.each do |id, data|
|
7
|
+
next if data[:nfs]
|
8
|
+
|
9
|
+
hostpath = File.expand_path(data[:hostpath], machine.env.root_path)
|
10
|
+
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
11
|
+
guestpath = data[:guestpath]
|
12
|
+
ssh_info = machine.ssh_info
|
13
|
+
|
14
|
+
command = [
|
15
|
+
"rsync", "--verbose", "--delete", "--archive", "-z",
|
16
|
+
"--exclude", ".vagrant/",
|
17
|
+
"-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
|
18
|
+
hostpath,
|
19
|
+
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"
|
20
|
+
]
|
21
|
+
|
22
|
+
options = {}
|
23
|
+
command << '-vvv' if options[:verbose]
|
24
|
+
|
25
|
+
if options[:verbose]
|
26
|
+
## should the vagrant way of outputting text
|
27
|
+
#@env.ui.say(:info,command.join(" "))
|
28
|
+
end
|
29
|
+
|
30
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
31
|
+
#@env.ui.say(:info, "done") if options[:verbose]
|
32
|
+
if r.exit_code != 0
|
33
|
+
raise Errors::RsyncError,
|
34
|
+
:guestpath => guestpath,
|
35
|
+
:hostpath => hostpath,
|
36
|
+
:stderr => r.stderr
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rsync
|
5
|
+
class Command < Vagrant.plugin("2", :command)
|
6
|
+
def execute
|
7
|
+
options = {}
|
8
|
+
options[:install_rsync] = true
|
9
|
+
options[:verbose] = false
|
10
|
+
|
11
|
+
opts = OptionParser.new do |o|
|
12
|
+
o.banner = "Usage: vagrant rsync [vm-name]"
|
13
|
+
|
14
|
+
o.on("-n", "--no-install", "Do not attempt to install rysnc if not found") do |ni|
|
15
|
+
options[:install_rsync] = !ni
|
16
|
+
end
|
17
|
+
|
18
|
+
o.on('-v', '--verbose', "Run verbosely") do |v|
|
19
|
+
options[:verbose] = v
|
20
|
+
end
|
21
|
+
|
22
|
+
o.on( '-h', '--help', 'Display this screen' ) do
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Parse the options
|
29
|
+
argv = parse_options(opts)
|
30
|
+
return if !argv
|
31
|
+
|
32
|
+
with_target_vms(argv) do |vm|
|
33
|
+
raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
|
34
|
+
raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
|
35
|
+
end
|
36
|
+
|
37
|
+
with_target_vms(argv) do |machine|
|
38
|
+
if options[:install_rsync]
|
39
|
+
@env.ui.info I18n.t('vagrant_rsync.ensure_rsync')
|
40
|
+
machine.guest.capability(:ensure_rsync, @env)
|
41
|
+
end
|
42
|
+
|
43
|
+
@env.ui.info I18n.t('vagrant_rsync.rsync_folders')
|
44
|
+
machine.guest.capability(:rsync_folders)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -10,8 +10,11 @@ if Vagrant::VERSION < "1.1.0"
|
|
10
10
|
raise "The Vagrant AWS plugin is only compatible with Vagrant 1.1+"
|
11
11
|
end
|
12
12
|
|
13
|
+
# Add our custom translations to the load path
|
14
|
+
I18n.load_path << File.expand_path("../../../locales/en.yml", __FILE__)
|
15
|
+
|
13
16
|
module VagrantPlugins
|
14
|
-
module
|
17
|
+
module Rsync
|
15
18
|
class Plugin < Vagrant.plugin("2")
|
16
19
|
name "rsync command"
|
17
20
|
description <<-DESC
|
@@ -19,9 +22,19 @@ module VagrantPlugins
|
|
19
22
|
DESC
|
20
23
|
|
21
24
|
command("rsync") do
|
22
|
-
|
25
|
+
require_relative 'command'
|
23
26
|
Command
|
24
27
|
end
|
28
|
+
|
29
|
+
guest_capability("linux", "ensure_rsync") do
|
30
|
+
require_relative "cap/ensure_rsync"
|
31
|
+
Cap::EnsureRsync
|
32
|
+
end
|
33
|
+
|
34
|
+
guest_capability("linux", "rsync_folders") do
|
35
|
+
require_relative "cap/rsync_folders"
|
36
|
+
Cap::RsyncFolders
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
27
40
|
end
|
data/lib/vagrant-rsync.rb
CHANGED
data/locales/en.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_rsync:
|
3
|
+
ensure_rsync: |-
|
4
|
+
Ensuring that rsync is installed on guest.
|
5
|
+
rsync_installed: |-
|
6
|
+
Rsync already installed.
|
7
|
+
installing_rsync: |-
|
8
|
+
Installing rsync...
|
9
|
+
rsync_folders: |-
|
10
|
+
Syncing shared folders to guest with rsync...
|
11
|
+
vagrant:
|
12
|
+
errors:
|
13
|
+
rsync_not_available: |-
|
14
|
+
Unable to install rsync on a machine of guest type '%{guest}'.
|
data/vagrant-rsync.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
-
require
|
2
|
+
require 'vagrant-rsync/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "vagrant-rsync"
|
6
|
-
s.version = VagrantPlugins::
|
6
|
+
s.version = VagrantPlugins::Rsync::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = "Bill Cromie"
|
9
|
-
s.email = "bill@cromie.org"
|
8
|
+
s.authors = ["Bill Cromie", "Patrick Connolly"]
|
9
|
+
s.email = ["bill@cromie.org","patrick@myplanetdigital.com"]
|
10
10
|
s.homepage = "https://github.com/cromulus/vagrant-rsync"
|
11
11
|
s.summary = "Enables Vagrant to rsync shared folders on remote guests with grace and aplomb."
|
12
12
|
s.description = "Enables Vagrant to rsync shared folders on remote guests with grace and aplomb."
|
metadata
CHANGED
@@ -1,69 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-rsync
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
5
10
|
platform: ruby
|
6
|
-
authors:
|
11
|
+
authors:
|
7
12
|
- Bill Cromie
|
13
|
+
- Patrick Connolly
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
- - ! '>='
|
17
|
-
- !ruby/object:Gem::Version
|
18
|
-
version: '0'
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ! '>='
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '0'
|
17
|
+
|
18
|
+
date: 2013-09-05 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
24
22
|
type: :development
|
25
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
26
30
|
name: rake
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
requirement: *id001
|
32
|
+
prerelease: false
|
33
|
+
description: Enables Vagrant to rsync shared folders on remote guests with grace and aplomb.
|
34
|
+
email:
|
35
|
+
- bill@cromie.org
|
36
|
+
- patrick@myplanetdigital.com
|
30
37
|
executables: []
|
38
|
+
|
31
39
|
extensions: []
|
40
|
+
|
32
41
|
extra_rdoc_files: []
|
33
|
-
|
42
|
+
|
43
|
+
files:
|
34
44
|
- Gemfile
|
35
45
|
- Guardfile
|
36
|
-
- lib/
|
37
|
-
- lib/
|
46
|
+
- lib/vagrant-rsync/cap/ensure_rsync.rb
|
47
|
+
- lib/vagrant-rsync/cap/rsync_folders.rb
|
48
|
+
- lib/vagrant-rsync/command.rb
|
49
|
+
- lib/vagrant-rsync/errors.rb
|
50
|
+
- lib/vagrant-rsync/plugin.rb
|
51
|
+
- lib/vagrant-rsync/version.rb
|
38
52
|
- lib/vagrant-rsync.rb
|
39
|
-
- lib/version.rb
|
40
53
|
- License
|
54
|
+
- locales/en.yml
|
41
55
|
- RakeFile
|
42
56
|
- README.md
|
43
57
|
- vagrant-rsync.gemspec
|
44
58
|
- Vagrantfile.testing
|
45
59
|
- .gitignore
|
60
|
+
has_rdoc: true
|
46
61
|
homepage: https://github.com/cromulus/vagrant-rsync
|
47
62
|
licenses: []
|
48
|
-
|
63
|
+
|
49
64
|
post_install_message:
|
50
65
|
rdoc_options: []
|
51
|
-
|
66
|
+
|
67
|
+
require_paths:
|
52
68
|
- lib
|
53
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 3
|
83
|
+
- 6
|
62
84
|
version: 1.3.6
|
63
85
|
requirements: []
|
86
|
+
|
64
87
|
rubyforge_project: vagrant-rsync
|
65
|
-
rubygems_version:
|
88
|
+
rubygems_version: 1.3.6
|
66
89
|
signing_key:
|
67
|
-
specification_version:
|
90
|
+
specification_version: 3
|
68
91
|
summary: Enables Vagrant to rsync shared folders on remote guests with grace and aplomb.
|
69
92
|
test_files: []
|
93
|
+
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
NjRjMzc4ODNmMmQ4ZDRiNTk0YWNiNTE3YmYyMjhjYTE1YzVlZGE0OQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NGU5MGE1NjE5NmZlOWViMDI5NzRhZGQxYWEwMjQxMThmZmQ5OTVlZg==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MzJmNDNmZWRkYjBmMjU5ZDM2ZjJhODM4NmNlYTI1YThhYWQ1Yjk4NzA4NmNl
|
10
|
-
MWExNTg5NmVlY2I4MTkzYzkyYzMyMmU3NGM0YWE1OWM5YWYyNTNlMWZmYTlj
|
11
|
-
MGQ0MmMyNDNkNzlmOGViN2Y3YjNhM2M1MjU3ZDQ5ZWI5YTU0ZTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjliZmQwOGU2M2Y1YWRiYzE0Y2Q2N2U5MWExZWFjZTE2OTZjNGUxNDBlM2Vl
|
14
|
-
NmZmNzcxNWVjZjY5OTdiNDY4YTE0NGEwYWVmMTJhYTI5ZGVmMDAxZWYxNzRk
|
15
|
-
N2NhOTA5YjJmNjUzOGJkNDcyMzBiYTU1NGY0ZjI0M2FjOTc0ZmU=
|
data/lib/command.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'pp'
|
3
|
-
module VagrantPlugins
|
4
|
-
module CommandRSYNC
|
5
|
-
class Command < Vagrant.plugin("2", :command)
|
6
|
-
|
7
|
-
class RsyncNotAvailableError < Vagrant::Errors::VagrantError
|
8
|
-
error_namespace("vagrant.plugin.vagrant-rsync")
|
9
|
-
end
|
10
|
-
|
11
|
-
def verify_rsync(vm)
|
12
|
-
begin
|
13
|
-
vm.communicate.execute("rsync --version")
|
14
|
-
rescue Exception => e
|
15
|
-
@env.ui.say(:info, "rsync not found, installing rsync now. disable this with --no-install")
|
16
|
-
# should notify people we are installing rsync here.
|
17
|
-
case vm.guest.name
|
18
|
-
when :debian, :ubuntu
|
19
|
-
vm.communicate.sudo("apt-get update")
|
20
|
-
vm.communicate.sudo("apt-get install rsync")
|
21
|
-
when :fedora, :centos, :redhat
|
22
|
-
vm.communicate.sudo("yum install rsync")
|
23
|
-
when :suse
|
24
|
-
vm.communicate.sudo("yast2 -i rsync")
|
25
|
-
when :gentoo
|
26
|
-
vm.communicate.sudo("emerge rsync")
|
27
|
-
when :arch
|
28
|
-
vm.communicate.sudo("pacman -s rsync")
|
29
|
-
# when :solaris
|
30
|
-
# vm.communicate.sudo("pkg install rsync")
|
31
|
-
# when :freebsd
|
32
|
-
# vm.communicate.sudo("pkg_add -r rsync")
|
33
|
-
else
|
34
|
-
raise RsyncNotAvailableError
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def execute
|
40
|
-
options = { :install_rsync => true,
|
41
|
-
:verbose => false}
|
42
|
-
|
43
|
-
opts = OptionParser.new do |opt|
|
44
|
-
opt.banner = "Usage: vagrant rsync [vm-name]"
|
45
|
-
opt.on("-n","--no-install", "do not attempt to install rysnc if not found") do |v|
|
46
|
-
options[:install_rsync] = false
|
47
|
-
end
|
48
|
-
opt.on('-v','--verbose',"Run verbosely") do |v|
|
49
|
-
options[:verbose] = true
|
50
|
-
end
|
51
|
-
opts.on( '-h', '--help', 'Display this screen' ) do
|
52
|
-
puts opts
|
53
|
-
exit
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
argv = parse_options(opts)
|
58
|
-
unless argv
|
59
|
-
argv=["default"]
|
60
|
-
end
|
61
|
-
|
62
|
-
with_target_vms(argv) do |vm|
|
63
|
-
raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
|
64
|
-
raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
|
65
|
-
end
|
66
|
-
|
67
|
-
with_target_vms(argv) do |vm|
|
68
|
-
|
69
|
-
if options[:install_rsync]
|
70
|
-
@env.ui.say(:info,"checking if rsync exists on host")
|
71
|
-
verify_rsync(vm)
|
72
|
-
end
|
73
|
-
|
74
|
-
vm.config.vm.synced_folders.each do |id, data|
|
75
|
-
next if data[:nfs]
|
76
|
-
hostpath = File.expand_path(data[:hostpath], vm.env.root_path)
|
77
|
-
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
78
|
-
guestpath = data[:guestpath]
|
79
|
-
ssh_info = vm.ssh_info
|
80
|
-
|
81
|
-
rsync_options = "-aze --exclude #{vm.env.root_path}/.vagrant/ "
|
82
|
-
rsync_options << '-vvv' if options[:verbose]
|
83
|
-
|
84
|
-
command = [
|
85
|
-
"rsync", "--verbose", "--delete", "--archive", "-z",
|
86
|
-
"--exclude", ".vagrant/",
|
87
|
-
"-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
|
88
|
-
hostpath,
|
89
|
-
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
90
|
-
|
91
|
-
|
92
|
-
if options[:verbose]
|
93
|
-
## should the vagrant way of outputting text
|
94
|
-
@env.ui.say(:info,command.join(" "))
|
95
|
-
end
|
96
|
-
|
97
|
-
r = Vagrant::Util::Subprocess.execute(*command)
|
98
|
-
@env.ui.say(:info, "done") if options[:verbose]
|
99
|
-
pp r.inspect
|
100
|
-
if r.exit_code != 0
|
101
|
-
raise Errors::RsyncError,
|
102
|
-
:guestpath => guestpath,
|
103
|
-
:hostpath => hostpath,
|
104
|
-
:stderr => r.stderr
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|