Skip to content

Commit

Permalink
First commit of the plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanns committed Oct 14, 2013
0 parents commit a104a0b
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# OS-specific
.DS_Store

# Bundler/Rubygems
*.gem
.bundle
pkg/*
tags
Gemfile.lock

# Vagrant
.vagrant
Vagrantfile
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gemspec

group :development do
# We depend on Vagrant for development, but we don't add it as a
# gem dependency because we expect to be installed within the
# Vagrant environment itself using `vagrant plugin`.
gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :tag => "v1.3.4"
end
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 Aidan Nagorcka-Smith

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Vagrant Reload Provisioner

This is a Vagrant 1.2+ plugin that adds a `reload` provisioning step that can
be used to do a reload on a VM during provisioning.

# Installation

`$ vagrant plugin install vagrant-reload`

## Usage

Add `config.vm.provision :reload` to your `Vagrantfile` to reload your VM
during provisioning.

## Development

To work on the `vagrant-reload` plugin, clone this repository out, and use
[Bundler](http://gembundler.com) to get the dependencies:

$ bundle

You can test the plugin without installing it into your Vagrant environment by
just creating a `Vagrantfile` in the top level of this directory
(it is gitignored) and add the following line to your `Vagrantfile`

```ruby
Vagrant.require_plugin "vagrant-aws"
```
Use bundler to execute Vagrant:

$ bundle exec vagrant up --provider=aws

## Contributing

1. Fork it
2. Create your feature branch (`$ git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rubygems'
require 'bundler/setup'

# This installs the tasks that help with gem creation and
# publishing.
Bundler::GemHelper.install_tasks

# Default task is to run the unit tests
task :default => "build"
53 changes: 53 additions & 0 deletions lib/vagrant-reload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
begin
require "vagrant"
rescue LoadError
raise "The Vagrant AWS plugin must be run within Vagrant."
end

# This is a sanity check to make sure no one is attempting to install
# this into an early Vagrant version.
if Vagrant::VERSION < "1.2.0"
raise "The Vagrant Reload plugin is only compatible with Vagrant 1.2+"
end

module VagrantPlugins
module Reload

VERSION = "0.0.1"

class Plugin < Vagrant.plugin("2")
name "Reload"
description <<-DESC
The reload plugin allows a VM to be reloaded as a provisioning step.
DESC

provisioner "reload" do
class ReloadProvisioner < Vagrant.plugin("2", :provisioner)

def initialize(machine, config)
super
end

def configure(root_config)
end

def provision
options = {}
options[:provision_ignore_sentinel] = false
@machine.action(:reload, options)
begin
sleep 10
end until @machine.communicate.ready?
end

def cleanup
end

end
ReloadProvisioner

end
end
end
end

5 changes: 5 additions & 0 deletions lib/vagrant-reload/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module VagrantPlugins
module Reload
VERSION = "0.0.1"
end
end
53 changes: 53 additions & 0 deletions vagrant-reload.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Add the lib directory to the load path so we can get the version file out.
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)

require 'vagrant-reload/version'

Gem::Specification.new do |gem|
gem.name = "vagrant-reload"
gem.version = VagrantPlugins::Reload::VERSION
gem.platform = Gem::Platform::RUBY
gem.license = "MIT"
gem.authors = "Aidan Nagorcka-Smith"
gem.email = "[email protected]"
gem.homepage = "http://www.vagrantup.com"
gem.description = "Enables reloading a vagrant VM as a provisioning step."
gem.summary = "Enables reloading a vagrant VM as a provisioning step."

gem.add_development_dependency "rake"

# The following block of code determines the files that should be included
# in the gem. It does this by reading all the files in the directory where
# this gemspec is, and parsing out the ignored files from the gitignore.
# Note that the entire gitignore(5) syntax is not supported, specifically
# the "!" syntax, but it should mostly work correctly.
root_path = File.dirname(__FILE__)
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
gitignore_path = File.join(root_path, ".gitignore")
gitignore = File.readlines(gitignore_path)
gitignore.map! { |line| line.chomp.strip }
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }

unignored_files = all_files.reject do |file|
# Ignore any directories, the gemspec only cares about files
next true if File.directory?(file)

# Ignore any paths that match anything in the gitignore. We do
# two tests here:
#
# - First, test to see if the entire path matches the gitignore.
# - Second, match if the basename does, this makes it so that things
# like '.DS_Store' will match sub-directories too (same behavior
# as git).
#
gitignore.any? do |ignore|
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
end
end

gem.files = unignored_files
gem.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
gem.require_path = 'lib'
end

0 comments on commit a104a0b

Please sign in to comment.