├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── lib ├── vagrant-reload.rb └── vagrant-reload │ └── version.rb └── vagrant-reload.gemspec /.gitignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vagrant Reload Provisioner 2 | 3 | This is a Vagrant 1.2+ plugin that adds a `reload` provisioning step that can 4 | be used to do a reload on a VM during provisioning. 5 | 6 | # Installation 7 | 8 | $ vagrant plugin install vagrant-reload 9 | 10 | ## Usage 11 | 12 | Add `config.vm.provision :reload` to your `Vagrantfile` to reload your VM 13 | during provisioning. 14 | 15 | ## Development 16 | 17 | To work on the `vagrant-reload` 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-reload" 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 40 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 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" -------------------------------------------------------------------------------- /lib/vagrant-reload.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require "vagrant" 3 | rescue LoadError 4 | raise "The Vagrant AWS plugin must be run within 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 Reload plugin is only compatible with Vagrant 1.2+" 11 | end 12 | 13 | module VagrantPlugins 14 | module Reload 15 | 16 | VERSION = "0.0.1" 17 | 18 | class Plugin < Vagrant.plugin("2") 19 | name "Reload" 20 | description <<-DESC 21 | The reload plugin allows a VM to be reloaded as a provisioning step. 22 | DESC 23 | 24 | provisioner "reload" do 25 | class ReloadProvisioner < 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 = {} 36 | options[:provision_ignore_sentinel] = false 37 | @machine.action(:reload, options) 38 | begin 39 | sleep 10 40 | end until @machine.communicate.ready? 41 | end 42 | 43 | def cleanup 44 | end 45 | 46 | end 47 | ReloadProvisioner 48 | 49 | end 50 | end 51 | end 52 | end 53 | 54 | -------------------------------------------------------------------------------- /lib/vagrant-reload/version.rb: -------------------------------------------------------------------------------- 1 | module VagrantPlugins 2 | module Reload 3 | VERSION = "0.0.1" 4 | end 5 | end -------------------------------------------------------------------------------- /vagrant-reload.gemspec: -------------------------------------------------------------------------------- 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-reload/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "vagrant-reload" 8 | gem.version = VagrantPlugins::Reload::VERSION 9 | gem.platform = Gem::Platform::RUBY 10 | gem.license = "MIT" 11 | gem.authors = "Aidan Nagorcka-Smith" 12 | gem.email = "aidanns@gmail.com" 13 | gem.homepage = "https://github.com/aidanns/vagrant-reload" 14 | gem.description = "Enables reloading a vagrant VM as a provisioning step." 15 | gem.summary = "Enables reloading 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 54 | --------------------------------------------------------------------------------