Skip to content

Commit

Permalink
Improve Vagrant includes for nodes and local
Browse files Browse the repository at this point in the history
Note: relative paths should always use VAGRANT_HOME

fixes #155
  • Loading branch information
lazyfrosch committed Sep 10, 2018
1 parent 1c6681e commit e6e96ae
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 168 deletions.
31 changes: 3 additions & 28 deletions distributed/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

31 changes: 3 additions & 28 deletions elastic/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

31 changes: 3 additions & 28 deletions env/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

31 changes: 3 additions & 28 deletions graylog/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

31 changes: 3 additions & 28 deletions influxdb/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

31 changes: 3 additions & 28 deletions standalone/Vagrantfile
@@ -1,35 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodes = {}
if not File.exists?("Vagrantfile.nodes") then
puts "ERROR: Vagrantfile.nodes is missing from source tree."
exit 1
end

eval(IO.read("Vagrantfile.nodes"), binding)

# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME
require VAGRANT_HOME + "/../tools/vagrant_helper"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
$nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
Expand Down Expand Up @@ -125,4 +101,3 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end

32 changes: 32 additions & 0 deletions tools/vagrant_helper.rb
@@ -0,0 +1,32 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

raise "VAGRANT_HOME needs to be defined prior vagrant_helper!" unless defined? VAGRANT_HOME

VAGRANTFILE_API_VERSION = "2" unless defined? VAGRANTFILE_API_VERSION
VAGRANT_REQUIRED_VERSION = "1.8.0" unless defined? VAGRANT_REQUIRED_VERSION
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4" unless defined? VAGRANT_REQUIRED_LINKED_CLONE_VERSION

# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end

nodesFile = VAGRANT_HOME + "/Vagrantfile.nodes"
localFile = VAGRANT_HOME + "/Vagrantfile.local"
nodes = {}

raise "ERROR: Vagrantfile.nodes is missing from source tree." unless File.exists?(nodesFile)

eval(IO.read(nodesFile), binding)

# allow to override the configuration
eval(IO.read(localFile), binding) if File.exists?(localFile)

# Export nodes to global scope
$nodes = nodes

0 comments on commit e6e96ae

Please sign in to comment.