From 81b1458b0ff2ce1cd5b4f189ae2ff504bfdea5d5 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Wed, 13 Jan 2016 13:48:02 -0700 Subject: [PATCH] Add Ruby code to all Vagrantfiles Add Ruby code to determine full path to supporting files referenced in all Vagrantfiles. This will allow more effective use of Vagrant commands when not in the same directory as the Vagrantfile. --- docker-swarm-ha/Vagrantfile | 2 +- docker-swarm/Vagrantfile | 2 +- etcd-2.0/Vagrantfile | 2 +- openstack-cli/Vagrantfile | 2 +- photon-cloudinit/Vagrantfile | 2 +- photon/Vagrantfile | 2 +- rkt/Vagrantfile | 2 +- swarm-etcd2-photon/Vagrantfile | 2 +- vagrant-docker-yaml/Vagrantfile | 12 ++++++------ vagrant-docker/Vagrantfile | 4 ++-- vagrant-openstack-multi/Vagrantfile | 4 ++-- vagrant-openstack/Vagrantfile | 6 ++++-- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docker-swarm-ha/Vagrantfile b/docker-swarm-ha/Vagrantfile index 3dbcdc9..b232018 100644 --- a/docker-swarm-ha/Vagrantfile +++ b/docker-swarm-ha/Vagrantfile @@ -15,7 +15,7 @@ require 'erb' # Read YAML file with VM details (box, CPU, RAM, IP addresses) # Be sure to edit servers.yml to provide correct IP addresses -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Use template to create server-specific configuration files template = File.join(File.dirname(__FILE__), 'config.json.erb') diff --git a/docker-swarm/Vagrantfile b/docker-swarm/Vagrantfile index 3236ec6..5bd320f 100644 --- a/docker-swarm/Vagrantfile +++ b/docker-swarm/Vagrantfile @@ -16,7 +16,7 @@ USER_DATA = File.join(File.dirname(__FILE__), "user-data") # Read YAML file with VM details (box, CPU, RAM, IP addresses) # Be sure to edit servers.yml to provide correct IP addresses -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Create and configure the VMs Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| diff --git a/etcd-2.0/Vagrantfile b/etcd-2.0/Vagrantfile index 559227d..bea9a19 100644 --- a/etcd-2.0/Vagrantfile +++ b/etcd-2.0/Vagrantfile @@ -11,7 +11,7 @@ require 'yaml' # Read YAML file with VM details (box, CPU, RAM, IP addresses) # Be sure to edit servers.yml to provide correct IP addresses -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Require 'erb' module require 'erb' diff --git a/openstack-cli/Vagrantfile b/openstack-cli/Vagrantfile index 7bd1591..9f11298 100644 --- a/openstack-cli/Vagrantfile +++ b/openstack-cli/Vagrantfile @@ -10,7 +10,7 @@ ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant' require 'yaml' # Read YAML file with VM details (box, CPU, and RAM) -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Create and configure the VMs Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| diff --git a/photon-cloudinit/Vagrantfile b/photon-cloudinit/Vagrantfile index 4b92fd9..91c2c73 100644 --- a/photon-cloudinit/Vagrantfile +++ b/photon-cloudinit/Vagrantfile @@ -15,7 +15,7 @@ require 'yaml' # Read YAML file to get VM configuration information # Edit servers.yml to change VM configuration details -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Look for user-data and meta-data files in same directory USER_DATA = File.join(File.dirname(__FILE__), "user-data") diff --git a/photon/Vagrantfile b/photon/Vagrantfile index 828feae..16d8975 100644 --- a/photon/Vagrantfile +++ b/photon/Vagrantfile @@ -11,7 +11,7 @@ require 'yaml' # Read YAML file to get VM configuration information # Edit servers.yml to change VM configuration details -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Create and configure the VMs Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| diff --git a/rkt/Vagrantfile b/rkt/Vagrantfile index 7979e23..f3f739a 100644 --- a/rkt/Vagrantfile +++ b/rkt/Vagrantfile @@ -10,7 +10,7 @@ ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant' require 'yaml' # Read YAML file with VM details (box, CPU, and RAM) -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Create and configure the VMs Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| diff --git a/swarm-etcd2-photon/Vagrantfile b/swarm-etcd2-photon/Vagrantfile index 3a1828a..fc08168 100644 --- a/swarm-etcd2-photon/Vagrantfile +++ b/swarm-etcd2-photon/Vagrantfile @@ -21,7 +21,7 @@ META_DATA = File.join(File.dirname(__FILE__), "meta-data") # Read YAML file with VM details (box, CPU, RAM, IP addresses) # Be sure to edit servers.yml to provide correct IP addresses -servers = YAML.load_file('servers.yml') +servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) # Use config from YAML file to write out templates for etcd overrides template = File.join(File.dirname(__FILE__), 'etcd.defaults.erb') diff --git a/vagrant-docker-yaml/Vagrantfile b/vagrant-docker-yaml/Vagrantfile index afe6a17..5e7b013 100644 --- a/vagrant-docker-yaml/Vagrantfile +++ b/vagrant-docker-yaml/Vagrantfile @@ -12,7 +12,7 @@ require 'yaml' # Read details of containers to be created from YAML file # Be sure to edit 'containers.yml' to provide container details -containers = YAML.load_file('containers.yml') +containers = YAML.load_file(File.join(File.dirname(__FILE__), 'containers.yml')) # Create and configure the Docker container(s) Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| @@ -22,7 +22,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # to use default boot2docker box config.vm.provider "docker" do |docker| docker.vagrant_vagrantfile = "host/Vagrantfile" - end + end # config.vm.provider # Iterate through the entries in the YAML file containers.each do |container| @@ -44,7 +44,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Specify a friendly name for the Docker container, pull from YAML file docker.name = container["name"] - end - end - end -end + end # contnr.vm.provider + end # config.vm.define + end # containers.each +end # Vagrant.configure diff --git a/vagrant-docker/Vagrantfile b/vagrant-docker/Vagrantfile index 541dcda..6cf83c8 100644 --- a/vagrant-docker/Vagrantfile +++ b/vagrant-docker/Vagrantfile @@ -30,5 +30,5 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Specify a friendly name for the Docker container docker.name = 'nginx-container' - end -end + end # config.vm.provider +end # Vagrant.configure diff --git a/vagrant-openstack-multi/Vagrantfile b/vagrant-openstack-multi/Vagrantfile index 9b04cb5..2c5494c 100644 --- a/vagrant-openstack-multi/Vagrantfile +++ b/vagrant-openstack-multi/Vagrantfile @@ -6,10 +6,10 @@ require 'vagrant-openstack-provider' require 'yaml' # Read YAML file with OpenStack credentials -creds = YAML.load_file('credentials.yml') +creds = YAML.load_file(File.join(File.dirname(__FILE__), 'credentials.yml')) # Read YAML file with instance information -instances = YAML.load_file('instances.yml') +instances = YAML.load_file(File.join(File.dirname(__FILE__), 'instances.yml')) # Specify Vagrant version, Vagrant API version, and Vagrant provider Vagrant.require_version '>= 1.6.0' diff --git a/vagrant-openstack/Vagrantfile b/vagrant-openstack/Vagrantfile index 8dde57d..0c95816 100644 --- a/vagrant-openstack/Vagrantfile +++ b/vagrant-openstack/Vagrantfile @@ -6,8 +6,10 @@ require 'vagrant-openstack-provider' require 'yaml' # Read YAML file with OpenStack credentials -creds = YAML.load_file('credentials.yml') -instances = YAML.load_file('instances.yml') +creds = YAML.load_file(File.join(File.dirname(__FILE__), 'credentials.yml')) + +# Read YAML file with instance information +instances = YAML.load_file(File.join(File.dirname(__FILE__), 'instances.yml')) # Specify Vagrant version and Vagrant API version Vagrant.require_version '>= 1.6.0'