Skip to content

Instantly share code, notes, and snippets.

@benyanke
Last active July 24, 2017 14:24
Show Gist options
  • Save benyanke/ee70204bde5a5f45fb331071b050ec26 to your computer and use it in GitHub Desktop.
Save benyanke/ee70204bde5a5f45fb331071b050ec26 to your computer and use it in GitHub Desktop.
Vagrant file exerpts showing hosts editing
##############
# Box Config #
##############
# Specify any plugins you want installed on every `vagrant up` run
# You need the hostsupdated plugin, but the others are useful too.
required_plugins = %w(vagrant-hostsupdater vagrant-vbguest vagrant-triggers)
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of one or more plugins has failed. Aborting."
end
end
Vagrant.configure("2") do |config|
# [...] Typical config goes here
# Update hosts file
config.vm.hostname = "primarydomain"
config.hostsupdater.aliases = ["aliasdomain_1", "aliasdomain_2", "aliasdomain_n-1", "aliasdomain_n"]
# [...] Typical config goes here
# Load bootstrap shell script into vm
config.vm.provision :shell, :path => "config/bootstrap.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment