hashbangcode / vlad

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

Hostname & IP not added to hosts file on first time provision #100

Closed dixhuit closed 9 years ago

dixhuit commented 10 years ago

Steps to reproduce on both of my systems:

  1. Provision a new site with docroot already populated with site files: vagrant up
  2. Playbook will fail towards the end at test | default host is setup
  3. Verify whether hostname & IP address have been added to hosts file (they haven't - this explains the failed test).
  4. vagrant halt
  5. vagrant up --provision
  6. All is now well.

We've discussed this particular failed test before - perhaps this issue is the real cause?

I'm wondering what it is about the second attempt to provision that allows the hosts file to finally be edited as required.

philipnorton42 commented 10 years ago

Are you using Gas Mask at all? I've had trouble with that taking a few minutes to update the hosts file. Just a thought :)

dixhuit commented 10 years ago

I'm not using Gas Mask. I have experienced delays in the hosts file being updated before but this just seemed too long. To be fair, I haven't tested to see if this is indeed the result of a delay (just a very long one) or whether the entry is never added to the hosts file. I'll set up a wonky experiment to hopefully answer that.

philipnorton42 commented 10 years ago

Very strange. What does your ansible.log file say? The step to write to the hosts file is done in the trigger right at the start of the whole run-through, but it's all written to the log. (if it isn't then that will be another bug :P)

dixhuit commented 10 years ago

Did a wonky experiment and grabbed the Ansible log each time - not attached as GitHub only likes image attachments :(

Nutshell version: the vagrant trigger only runs on the second vagrant up. So the hosts file edit only happens after the first run. Subsequent halt/up commands later and it seems to work every time.

I was running a slightly older version of vagrant-triggers (0.4.1) and updating that to the latest (0.4.2) doesn't seem to make any difference. I'm running Ansible 1.7.2 (via Homebrew) and Vagrant 1.6.5.

philipnorton42 commented 10 years ago

I think you've hit the nail on the head there. Some of the 'up' triggers will only run if the hosts.ini file is in place. I think that's what is going on here. The hosts.ini file isn't present and so the trigger isn't firing.

dixhuit commented 10 years ago

Right. I can see that the host.ini file is created in local_up.yml but I don't get why that playbook isn't running the first time. Any clue?

philipnorton42 commented 10 years ago

Just tried it and I saw no problem. I was also running vagrant-triggers (0.4.1). Strange... Do you have anything else messing with your hosts file? Or perhaps something that is interfering with triggers? Some other version checks:

dixhuit commented 10 years ago

Do you have anything else messing with your hosts file? Or perhaps something that is interfering with triggers?

Not that I'm aware of. At least I have a kind-of solution for the meantime. Let's leave this issue open and see if anyone else reports anything similar - maybe then we'll be able to get a bit closer to tracking down the real cause.

philipnorton42 commented 9 years ago

Is this still an issue Dan? Looking to close if it isn't :)

dixhuit commented 9 years ago

I do still experience sometimes and am still trying to get to the bottom of exactly what the issue is. Let's leave open for now.

philipnorton42 commented 9 years ago

I have found this issue every now and then, but only when I get the password incorrect on the first trigger.

dixhuit commented 9 years ago

I'm starting to confuse this with another issue I've experienced where ssh-add is never run due to the host.ini file not being properly removed on vagrant halt.

Let's close this issue for a clean slate and I'll keep a closer eye on things and create new issues if need be.