hashbangcode / vlad

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

www.boxwebaddress always ending up as www.drupal.local in hosts file #209

Closed dixhuit closed 9 years ago

dixhuit commented 9 years ago

As you can see, this box is called "bbp". The hosts file looks fine until you get down to the last entry which looks like Vlad's default.

Anyone else experiencing this? This is on a fairly wonky OS X system overdue for reprovisioning - just thought I'd check to see if anyone has seen this in case it is a real bug.

192.168.100.101  bbp  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
192.168.100.101  adminer.bbp.local  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
192.168.100.101  xhprof.bbp.local  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
192.168.100.101  logs.bbp.local  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
192.168.100.101  bbp.local  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
192.168.100.101  www.drupal.local  # VAGRANT: 20afccea64e71c2b990de0c5a72c5f0d (bbp) / c101bea3-fc7b-45c2-b222-e22d9e75e3a4
mbarcia commented 9 years ago

Dan, I think the culprit is this line in vlad/playbooks/vars/defaults/vagrant.yml

webserver_hostname_aliases: 
- 'www.drupal.local'

The variable definition there can not refer to webserver_hostname.

While it can be certainly overriden in settings.yml as a workaround, it would be better to add the drupal alias to the list in Vagrantfile

  # vagrant-hostsupdater plugin will manage /etc/hosts upon up/halt/suspend.
  config.hostsupdater.aliases = [
    'adminer.' + boxwebaddress, 
    'xhprof.' + boxwebaddress, 
    'logs.' + boxwebaddress,
    * 'drupal.' + boxwebaddress, *
    boxwebaddress
  ] + hostname_aliases

and leave webserver_hostname_aliases empty in the default vars.

dixhuit commented 9 years ago

Aaah, think I've got it. I recently upgraded this project to use a more current version of Vlad and the settings didn't explicitly define any values for webserver_hostname_aliases.

When this used to be just webserver_hostname_alias it it used to default to www.{{ webserver_hostname }} which meant you could get away with not setting it in settings at all.

I wonder if we can still use this as a sensible default? Will test...

dixhuit commented 9 years ago

@mbarcia you beat me by 25 seconds! :)

mbarcia commented 9 years ago

LOL

dixhuit commented 9 years ago

So what happens if you try expand www.{{ webserver_hostname }} as a value for webserver_hostname_aliases? Does it not let you override the default from your settings file?

mbarcia commented 9 years ago

It doesn't work, I've already tried. But see for yourself.

I don't see anything wrong with adding the drupal alias to the list of others... so it should be an easy fix.

dixhuit commented 9 years ago

But not everyone is going to want to use an alias containing the word "drupal".

mbarcia commented 9 years ago

Then use webserver_hostname_aliases in the settings.yml?

dixhuit commented 9 years ago

Then use webserver_hostname_aliases in the settings.yml?

Yes.

I'm interested as to why {{ webserver_hostname }} doesn't expand properly though. I might have a play with it.

dixhuit commented 9 years ago

I'm interested as to why {{ webserver_hostname }} doesn't expand properly though. I might have a play with it.

Of course, Ruby doesn't expand it when the Vagrantfile imports it as plain YAML.

dixhuit commented 9 years ago

I'm gonna close this as it seems that the best solution is to just ensure that you set webserver_hostname_aliases via Vlad settings per project.