Skip to content

Instantly share code, notes, and snippets.

@jgornick
Created August 13, 2014 16:29
Show Gist options
  • Save jgornick/02a5aa01bd0bb852d836 to your computer and use it in GitHub Desktop.
Save jgornick/02a5aa01bd0bb852d836 to your computer and use it in GitHub Desktop.
Vagrant + Ruby: Require Environment Variables in Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
variables = %w{ANSIBLE_PATH ANSIBLE_VAULT_PASS}
missing = variables.find_all { |v| ENV[v] == nil }
unless missing.empty?
puts "FATAL: The following variables are missing and are needed to run this script: #{missing.join(', ')}."
exit
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment