vagrant-force-rsync 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 680c4dc731a367f726994d2c458a9e904e32bf26
4
+ data.tar.gz: d57804b39282faaef4c669b710490ca25908f160
5
+ SHA512:
6
+ metadata.gz: f2762cca0f88bd5d2f22c8987a82c9adc685b0592d1b2ae419644003bf535eeee381990125bf0c605b7a4b8e7c2f7d34dc29ac9c166b4c452ad22e774ece4a68
7
+ data.tar.gz: 216d229595fc5b23e4af20d1d95a8b4819cb89b583637ec0b5fabe9ea9387685bf838558534aa44412b93d2bf7eabcddf889782f2ab75b5e9a8bafcf0e63dd1b
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ # OS-specific
2
+ .DS_Store
3
+
4
+ # Bundler/Rubygems
5
+ *.gem
6
+ .bundle
7
+ pkg/*
8
+ tags
9
+ Gemfile.lock
10
+
11
+ # Vagrant
12
+ .vagrant
13
+ Vagrantfile
14
+
15
+ # Emacs backups
16
+ *~
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :tag => "v1.3.4"
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Aidan Nagorcka-Smith
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/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Vagrant Force Rsync Provisioner
2
+
3
+ This is a Vagrant plugin that adds a `force-rsync` provisioning step that can
4
+ be used to force directory synchronization on a VM during provisioning.
5
+
6
+ # Installation
7
+
8
+ `$ vagrant plugin install vagrant-force-rsync`
9
+
10
+ ## Usage
11
+
12
+ Add `config.vm.provision :force-rsync` to your `Vagrantfile` to rsync your VM
13
+ during provisioning.
14
+
15
+ ## Development
16
+
17
+ To work on the `vagrant-force-rsync` plugin, clone this repository out, and use
18
+ [Bundler](http://gembundler.com) to get the dependencies:
19
+
20
+ $ bundle
21
+
22
+ You can test the plugin without installing it into your Vagrant environment by
23
+ just creating a `Vagrantfile` in the top level of this directory
24
+ (it is gitignored) and add the following line to your `Vagrantfile`
25
+
26
+ ```ruby
27
+ Vagrant.require_plugin "vagrant-force-rsync"
28
+ ```
29
+ Use bundler to execute Vagrant:
30
+
31
+ $ bundle exec vagrant up
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`$ git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # This installs the tasks that help with gem creation and
5
+ # publishing.
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ # Default task is to run the unit tests
9
+ task :default => "build"
@@ -0,0 +1,148 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "There was an error loading Vagrant"
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < "1.2.0"
10
+ raise "The Vagrant Force Rsync plugin is only compatible with Vagrant 1.2+"
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module ForceRsync
15
+
16
+ VERSION = "0.0.1"
17
+
18
+ class Plugin < Vagrant.plugin("2")
19
+ name "ForceRsync"
20
+ description <<-DESC
21
+ The force rsync plugin allows a VM to use rsync as a provisioning step.
22
+ DESC
23
+
24
+ provisioner "force-rsync" do
25
+ class ForceRsyncProvisioner < Vagrant.plugin("2", :provisioner)
26
+
27
+ def initialize(machine, config)
28
+ super
29
+ end
30
+
31
+ def configure(root_config)
32
+ end
33
+
34
+ def provision
35
+ #options[:provision_ignore_sentinel] = false
36
+ #@machine.action(:rsync, options)
37
+ #puts exec('vagrant rsync')
38
+
39
+
40
+ opts = {:hostpath=>'.', :guestpath=>'/vagrant/', :exclude=>'.git/', :args=> ["--verbose", "--archive", "-r", "-z", "--copy-links"]}
41
+
42
+ ssh_info = machine.ssh_info
43
+
44
+ # Folder info
45
+ guestpath = opts[:guestpath]
46
+ hostpath = opts[:hostpath]
47
+ hostpath = File.expand_path(hostpath, machine.env.root_path)
48
+ hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
49
+ if Vagrant::Util::Platform.windows?
50
+ # rsync for Windows expects cygwin style paths, always.
51
+ hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
52
+ end
53
+ # Make sure the host path ends with a "/" to avoid creating
54
+ # a nested directory...
55
+ if !hostpath.end_with?("/")
56
+ hostpath += "/"
57
+ end
58
+ # Folder options
59
+ opts[:owner] ||= ssh_info[:username]
60
+ opts[:group] ||= ssh_info[:username]
61
+ # Connection information
62
+ username = ssh_info[:username]
63
+ host = ssh_info[:host]
64
+ proxy_command = ""
65
+ if ssh_info[:proxy_command]
66
+ proxy_command = "-o ProxyCommand='#{ssh_info[:proxy_command]}' "
67
+ end
68
+ rsh = [
69
+ "ssh -p #{ssh_info[:port]} " +
70
+ proxy_command +
71
+ "-o StrictHostKeyChecking=no " +
72
+ "-o UserKnownHostsFile=/dev/null",
73
+ ssh_info[:private_key_path].map { |p| "-i '#{p}'" },
74
+ ].flatten.join(" ")
75
+ # Exclude some files by default, and any that might be configured
76
+ # by the user.
77
+ excludes = ['.vagrant/']
78
+ excludes += Array(opts[:exclude]).map(&:to_s) if opts[:exclude]
79
+ excludes.uniq!
80
+ # Get the command-line arguments
81
+ args = nil
82
+ args = Array(opts[:args]).dup if opts[:args]
83
+ args ||= ["--verbose", "--archive", "--delete", "-z", "--copy-links"]
84
+ # On Windows, we have to set a default chmod flag to avoid permission issues
85
+ if Vagrant::Util::Platform.windows? && !args.any? { |arg| arg.start_with?("--chmod=") }
86
+ # Ensures that all non-masked bits get enabled
87
+ args << "--chmod=ugo=rwX"
88
+ # Remove the -p option if --archive is enabled (--archive equals -rlptgoD)
89
+ # otherwise new files will not have the destination-default permissions
90
+ args << "--no-perms" if args.include?("--archive") || args.include?("-a")
91
+ end
92
+ # Disable rsync's owner/group preservation (implied by --archive) unless
93
+ # specifically requested, since we adjust owner/group to match shared
94
+ # folder setting ourselves.
95
+ args << "--no-owner" unless args.include?("--owner") || args.include?("-o")
96
+ args << "--no-group" unless args.include?("--group") || args.include?("-g")
97
+ # Tell local rsync how to invoke remote rsync with sudo
98
+ if machine.guest.capability?(:rsync_command)
99
+ args << "--rsync-path"<< machine.guest.capability(:rsync_command)
100
+ end
101
+ # Build up the actual command to execute
102
+ command = [
103
+ "rsync",
104
+ args,
105
+ "-e", rsh,
106
+ excludes.map { |e| ["--exclude", e] },
107
+ hostpath,
108
+ "#{username}@#{host}:#{guestpath}",
109
+ ].flatten
110
+ # The working directory should be the root path
111
+ command_opts = {}
112
+ command_opts[:workdir] = machine.env.root_path.to_s
113
+ machine.ui.info(I18n.t(
114
+ "vagrant.rsync_folder", guestpath: guestpath, hostpath: hostpath))
115
+ if excludes.length > 1
116
+ machine.ui.info(I18n.t(
117
+ "vagrant.rsync_folder_excludes", excludes: excludes.inspect))
118
+ end
119
+ # If we have tasks to do before rsyncing, do those.
120
+ if machine.guest.capability?(:rsync_pre)
121
+ machine.guest.capability(:rsync_pre, opts)
122
+ end
123
+ r = Vagrant::Util::Subprocess.execute(*(command + [command_opts]))
124
+ if r.exit_code != 0
125
+ raise Vagrant::Errors::RSyncError,
126
+ command: command.join(" "),
127
+ guestpath: guestpath,
128
+ hostpath: hostpath,
129
+ stderr: r.stderr
130
+ end
131
+ # If we have tasks to do after rsyncing, do those.
132
+ if machine.guest.capability?(:rsync_post)
133
+ machine.guest.capability(:rsync_post, opts)
134
+ end
135
+
136
+ end
137
+
138
+ def cleanup
139
+ end
140
+
141
+ end
142
+ ForceRsyncProvisioner
143
+
144
+ end
145
+ end
146
+ end
147
+ end
148
+
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module ForceRsync
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ # Add the lib directory to the load path so we can get the version file out.
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
+
4
+ require 'vagrant-force-rsync/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vagrant-force-rsync"
8
+ gem.version = VagrantPlugins::ForceRsync::VERSION
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.license = "MIT"
11
+ gem.authors = "Justin Beaty"
12
+ gem.email = "jbeaty@morroni.com"
13
+ gem.homepage = "http://www.vagrantup.com"
14
+ gem.description = "Forces rsync in a vagrant VM as a provisioning step."
15
+ gem.summary = "Forces rsync in a vagrant VM as a provisioning step."
16
+
17
+ gem.add_development_dependency "rake"
18
+
19
+ # The following block of code determines the files that should be included
20
+ # in the gem. It does this by reading all the files in the directory where
21
+ # this gemspec is, and parsing out the ignored files from the gitignore.
22
+ # Note that the entire gitignore(5) syntax is not supported, specifically
23
+ # the "!" syntax, but it should mostly work correctly.
24
+ root_path = File.dirname(__FILE__)
25
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
26
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
27
+ gitignore_path = File.join(root_path, ".gitignore")
28
+ gitignore = File.readlines(gitignore_path)
29
+ gitignore.map! { |line| line.chomp.strip }
30
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
31
+
32
+ unignored_files = all_files.reject do |file|
33
+ # Ignore any directories, the gemspec only cares about files
34
+ next true if File.directory?(file)
35
+
36
+ # Ignore any paths that match anything in the gitignore. We do
37
+ # two tests here:
38
+ #
39
+ # - First, test to see if the entire path matches the gitignore.
40
+ # - Second, match if the basename does, this makes it so that things
41
+ # like '.DS_Store' will match sub-directories too (same behavior
42
+ # as git).
43
+ #
44
+ gitignore.any? do |ignore|
45
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
46
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
47
+ end
48
+ end
49
+
50
+ gem.files = unignored_files
51
+ gem.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
52
+ gem.require_path = 'lib'
53
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-force-rsync
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Beaty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Forces rsync in a vagrant VM as a provisioning step.
28
+ email: jbeaty@morroni.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".gitignore"
34
+ - ".gitignore~"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/vagrant-force-rsync.rb
40
+ - lib/vagrant-force-rsync/version.rb
41
+ - vagrant-force-rsync.gemspec
42
+ homepage: http://www.vagrantup.com
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.2.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Forces rsync in a vagrant VM as a provisioning step.
66
+ test_files: []