Vaprobash icon indicating copy to clipboard operation
Vaprobash copied to clipboard

Yaml integration

Open tlartaud opened this issue 10 years ago • 2 comments

Hi there !

I really like your provisionner scripts, thanks for sharing. It could be great to implement some yaml files configuration instead of needing to edit the vagrantfile. There is a a great example on Cakebox.

So, the main Vagrant file could look something like this :

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = '2'

# Config Github Settings
github_username = "fideloper"
github_repo     = "Vaprobash"
github_branch   = "1.3.1"
github_url      = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"

path = "#{File.dirname(__FILE__)}"
require github_url + '/scripts/Vagrantfile.rb'
require 'yaml'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  raise Vagrant::Errors::VagrantError.new, 'Fatal: your Vaprobash.yaml is missing' unless File.exist?(path + '/Vaprobash.yaml')
  Vaprobash.configure(config, YAML::load(File.read(path + '/Vaprobash.yaml')))
end

So you can keep using your curl command to download the main vagrant file, and it allow the user to have two choices :

  • use require github_url + '/scripts/Vagrantfile.rb' so the user will not only use the last scripts, but also the last vagrantfile.
  • use require path + '/scripts/Vagrantfile.rb' so the user can use his own copy of vagrantfile locally (would maybe require initilisation via git clone instead of curl)

What do you think ?

tlartaud avatar Feb 28 '15 10:02 tlartaud

Definitely interesting! I've been really busy lately, but I'll give this more attention in the near future.

Thanks!

fideloper avatar Mar 02 '15 15:03 fideloper

+1

n3r0-ch avatar Nov 08 '15 17:11 n3r0-ch