Last active
October 14, 2016 14:16
-
-
Save bivas/6192d6e422f8ff87c29d to your computer and use it in GitHub Desktop.
Vagrant file (CentOS65 based) with the ability to pass environment variables to your provisionening scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "centos65" | |
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box" | |
config.vm.define "<your-vm-name>" do |vmname| | |
end | |
$before_script = <<SCRIPT | |
echo # vagrant profile script > /etc/profile.d/vagrant.sh | |
echo export ENV_VAR1=foo.com/bar >> /etc/profile.d/vagrant.sh | |
echo export ENV_VAR2=bar.com/foo >> /etc/profile.d/vagrant.sh | |
chmod +x /etc/profile.d/vagrant.sh | |
SCRIPT | |
$after_script = <<SCRIPT | |
rm -rf /etc/profile.d/vagrant.sh | |
SCRIPT | |
config.vm.provision "shell", inline: $before_script | |
config.vm.provision "shell", path: "build.sh" | |
config.vm.provision "shell", inline: $after_script | |
config.vm.provider "virtualbox" do |vm| | |
vm.name = "<your-vm-name>" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment