hashbangcode / vlad

Vlad - Vagrant LAMP Ansible Drupal
173 stars 53 forks source link

Adding ability to automatically install required plugins in Vagrantfile. Adding plugin vagrant-hostsupdater and adapting host entries mgmt in /etc/hosts. Adding those server aliases to Apache vhost config. #177

Closed mbarcia closed 9 years ago

mbarcia commented 9 years ago

Based upon this patch. I've tested it and magically works. Docs should be updated as well if/when this PR is accepted. This addition should simplify the docs and the installation process.

mbarcia commented 9 years ago

I went ahead and added vagrant-hostsupdater in order to improve the way VLAD manages the host entries in /etc/hosts. vagrant up adds entries, vagrant suspend/halt removes them. It shows this on vagrant up

...
==> vlad: Checking for host entries
==> vlad: adding to (C:/Windows/system32/drivers/etc/hosts) : 192.168.100.100  vlad  # VAGRANT: b1db0ba933a169e9f36a827d
4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
==> vlad: adding to (C:/Windows/system32/drivers/etc/hosts) : 192.168.100.100  www.drupal.local  # VAGRANT: b1db0ba933a1
69e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
==> vlad: adding to (C:/Windows/system32/drivers/etc/hosts) : 192.168.100.100  adminer.drupal.local  # VAGRANT: b1db0ba9
33a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
==> vlad: adding to (C:/Windows/system32/drivers/etc/hosts) : 192.168.100.100  xhprof.drupal.local  # VAGRANT: b1db0ba93
3a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
==> vlad: adding to (C:/Windows/system32/drivers/etc/hosts) : 192.168.100.100  logs.drupal.local  # VAGRANT: b1db0ba933a
169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
==> vlad: Setting hostname... 

and this on vagrant suspend/halt

==> vlad: Saving VM state and suspending execution...
==> vlad: Removing hosts

Entries get added to /etc/hosts like this

192.168.100.100  vlad  # VAGRANT: b1db0ba933a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
192.168.100.100  www.drupal.local  # VAGRANT: b1db0ba933a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
192.168.100.100  adminer.drupal.local  # VAGRANT: b1db0ba933a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
192.168.100.100  xhprof.drupal.local  # VAGRANT: b1db0ba933a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
192.168.100.100  logs.drupal.local  # VAGRANT: b1db0ba933a169e9f36a827d4c8811bd (vlad) / 560bc6d5-4233-49d4-9d94-f58ee807cd43
mbarcia commented 9 years ago

Great, thank you Philip.

philipnorton42 commented 9 years ago

I've gone through this and chatting it over with @danbohea and we decided that we should merge it. Which I have just done! I might make a few tweaks in the next couple of days, but it all makes sense. Thanks very much.

One thing that I did note was that this pull request seems to have evolved slightly into touching multiple areas of the system. I can see why in this case as once you install a host entry creator you need to create the correct hostname setup in the system to accommodate that. But you also added in multi-site support here, and tweaked some of the windows install settings. I don't want to detract from the wonderful work you are doing here (really, it's fantastic!) but it makes it difficult to go through everything and make sure it makes sense. I don't mind a number of different pull requests if they just touch on specific aspects of functionality.

mbarcia commented 9 years ago

Yeah, the long title says it all... it grew longer and longer... :-P The original motivation was that, in Windows, there was no easy way to maintain the /etc/hosts. The previous code was actually lacking a way to remove the hosts once the Vm was halted. The *nix code was OK but somewhat convoluted. So, I stumbled upon that plugin, but then it connected to what Dan was saying in #146 , and the rest is (a long) history :-).

Of course, I'm all for keeping things simple and focused, and this PR went totally out of control in that aspect. On the other hand, I think it means a significant improvement. So, I'm glad that you actually found the time to look at it and decided to merge, considering the circumstances. Let's see how it goes with the next PR coming up (for fixing Windows provisioning). Stay tuned! Cheers. BTW, I will be updating the docs accordingly.

philipnorton42 commented 9 years ago

I didn't want to create an issue for this but I just ran this on my home machine and got the following error:

Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.6.2'` succeeds before bundling.

I updated Vagrant and this seemed to fix things :)

I only mention it as it looped over and over with the same error message and was difficult to stop.

dixhuit commented 9 years ago

If this is a Vagrant dependency error then we should consider adding a minimum supported version to the Vagrantfile: http://docs.vagrantup.com/v2/vagrantfile/vagrant_version.html

dixhuit commented 9 years ago

I just got the same error testing this on Vagrant 1.6.3. Am updating Vagrant now - I'll re-test and report back...

dixhuit commented 9 years ago

The lowest version of Vagrant that seems to get past this stumbling block is 1.6.4. I've just pushed a tweaked Vagrantfile that requires >= 1.6.4.

https://github.com/hashbangcode/vlad/commit/54632e843c47ce61466a162892bcc840d1f60520

philipnorton42 commented 9 years ago

Yeah, I'm running Vagrant 1.6.5 at work and the problem doesn't exist. Thanks Dan :)

mbarcia commented 9 years ago

Right on the spot @danbohea. I've submitted https://github.com/hashbangcode/vlad-docs/pull/5, thank you.