Last active
October 12, 2016 20:31
-
-
Save ricardofontanelli/ce8b13721b330c8eeec7162361112ae9 to your computer and use it in GitHub Desktop.
Based on [gist](https://gist.github.com/mrLexx/9619121), an easy way to keep your hosts file updated with the VM using Puphpet, Vagrant and [vagrant-hostupdater](https://github.com/cogitatio/vagrant-hostsupdater):
This file contains hidden or 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
Vagrant.configure('2') do |config| | |
## Begin vagrant-hostsupdater | |
## https://github.com/cogitatio/vagrant-hostsupdater | |
## vagrant plugin install vagrant-hostsupdater | |
if Vagrant.has_plugin?('vagrant-hostsupdater') && (configValues['apache']['install'] == '1' || configValues['nginx']['install'] == '1') | |
if configValues['apache']['install'] == '1' | |
webserver = 'apache' | |
server_name_key = 'servername' | |
server_aliases_key = 'serveraliases' | |
end | |
if configValues['nginx']['install'] == '1' | |
webserver = 'nginx' | |
server_name_key = 'server_name' | |
server_aliases_key = 'server_aliases' | |
end | |
config.hostsupdater.remove_on_suspend = true | |
config.hostsupdater.aliases = Array.new | |
configValues[webserver]['vhosts'].each do |i, host| | |
config.hostsupdater.aliases.push(host[server_name_key]); | |
if !host[server_aliases_key].nil? | |
host[server_aliases_key].each do |j| | |
config.hostsupdater.aliases.push(j); | |
end | |
end | |
end | |
end | |
eval File.read("#{dir}/puphpet/vagrant/Vagrantfile-#{data['target']}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment