Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

vagrant up fails when using centos7 due to inability to resolve repository host #1495

Closed
Graloth opened this issue Aug 2, 2017 · 14 comments
Closed

Comments

@Graloth
Copy link

Graloth commented Aug 2, 2017

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 1.9.5
bash: vboxmanage: command not found
VirtualBox
bash: ansible: command not found

Your OS

  • Windows (10, build 15063.483, version 1703)

Full console output

https://gist.github.com/Graloth/9c6cd0f83adcdf2ae15d5ee228c2c492

Summary

After I cloned the drupal-vm repo into a new folder, I changed the following in the config.yml:

  • vagrant_box: geerlingguy/centos7 (Our production servers run Centos7, so we want our local development environment to match that as closely as possible)
  • vagrant_hostname: centosvm.dev
  • vagrant_machine_name: centosvm
  • vagrant_ip: 192.168.89.89 (Changed since *.88.88 is already in use by a default drupalvm box)

Saved all config changed to local.config.yml and ran vagrant up, which produces the above linked output.

@Graloth
Copy link
Author

Graloth commented Aug 2, 2017

It might be worth noting that I can access the address (http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock) just fine locally, it is the the vagrant box that for some reason cannot access it.

@Graloth
Copy link
Author

Graloth commented Aug 2, 2017

Running vagrant up a second time, give a similar result, but with some additional errors at the end: https://gist.github.com/Graloth/1c26e83a5e72928f30fb3e50c0b727bf

I assume it's likely that the box is unable to connect to the internet, which is a bit strange to me, as none of the normal drupal-vm boxes has that issue (but they are all geerlingguy/ubuntu1604).

@geerlingguy
Copy link
Owner

@Graloth - it looks like you might be using a fairly old centos7 box image. Can you run vagrant box update in the project directory? This should get you the newest box version with 5.1.26 guest additions.

From the error:

[centosvm] GuestAdditions versions on your host (5.1.26) and guest (5.1.20) do not match.

I just updated the box last night :)

@geerlingguy
Copy link
Owner

Also, the other error:

C:/Users/dsj/.vagrant.d/gems/2.2.5/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `initialize': Permission denied @ rb_sysopen - C:/WINDOWS/system32/drivers/etc/hosts (Errno::EACCES)

...seems to indicate that maybe you entered the wrong administrative password when prompted by the hostsupdater plugin?

@Graloth
Copy link
Author

Graloth commented Aug 2, 2017

@geerlingguy I updated it after re-reading my past post, that had no effect on the error. The hostupdater plugin never prompted me for a password, it just asked if I wanted to allow it to make administrative changes, which I allow it to do the first time, and the second time it didn't ask me anything (which then explains the error you mentioned).

I will give it another try on a clean drupal-vm clone on my home computer later today, and see what happens.

@geerlingguy
Copy link
Owner

Sounds good! Let me know what happens then.

@Graloth
Copy link
Author

Graloth commented Aug 2, 2017

My home computer had neither vagrant or virtualbox, so this is as clean of a test as I could do short of a fresh windows install :)

Here is more information, including another gist.
Running Git Bash as admin next.

Environment

Vagrant 1.9.7
bash: vboxmanage: command not found
VirtualBox
bash: ansible: command not found

OS

  • Windows (10, build 15063.483, version 1703)

Full Console Output

https://gist.github.com/Graloth/c6645b3c66b4ede6c9671866a509fd6b

Summary

Ran vagrant up and it prompted me twice to allow access to modify files that required higher permission level, it still threw the error even though I allowed all of it.

@Graloth
Copy link
Author

Graloth commented Aug 2, 2017

Running the entire Git Bash as adminitrator resolves the problem, so it is because the hostupdater doesn't have permission to do it's thing (even though I checked and it did update the hostfile just fine before the error)

I have also tested it with windows command prompt (cmd) as well as PowerShell, both required me to run them as administrator for the error to be avoided.

I don't consider this very safe, or practical. What makes it even more confusing is that the error only happens when using centos7, have tried with ubuntu1604 and it runs without issue.

@Graloth
Copy link
Author

Graloth commented Aug 3, 2017

Found a solution!
As the is caused by vagrant and it's vagrant-hostupdater plugin trying to update the %SystemRoot%\system32\drivers\etc\hosts-file, which it does not have permission to do.
Running the entire terminal/bash/cmd as administrator to solve the problem, is not a very good idea, so I set out to find a solution to this... even if it's just temporary.

We want the current user, the one that is trying to run vagrant up to have permission to modify the hosts-file, which would remove the need for elevated permissions.
Here is how to do that:

  • Navigate to %SystemRoot%\system32\drivers\etc, you can paste that address into the address bar in windows explorer and it should take you to the correct location.
  • Find the file named hosts inside the folder, right-click and choose Properties.
  • In the opened Properties window, click the Security tab.
  • In the Security tab, select the current user. In my case it is titled Users (COMPUTER-NAME\Users), but yours may vary.
  • Click Edit right below where you selected the user.
  • In the new window it opens, select the same user again.
  • Below where you selected the user, make sure the following permissions are checked under the Allow-column:
    • Modify (This is the important one)
    • Read & Execute
    • Read
    • Write (Should automatically get checked if Modify is checked)

Related issue already exists on the vagrant repo: agiledivider/vagrant-hostsupdater#89 and agiledivider/vagrant-hostsupdater#40

@geerlingguy
Copy link
Owner

@Graloth - wow, yes, that would be good to add. So is the box able to connect now, even when not run as administrator? Or does the build still fail at some point?

@Graloth
Copy link
Author

Graloth commented Aug 3, 2017

It runs smoothly, until it hits the composer install-issue.

I have tested using the vagrant-hostmanager plugin instead of vagrant-hostupdater, but neither correctly gives me the prompt, I assume Microsoft changed something that broke that functionality.
The fix mentioned does work on all boxes now, even pure drupal-vm with no custom config.

If you want to add more details to the docs about this (you do mention it), I can provide screenshots of the relevant windows on windows 10.

@geerlingguy
Copy link
Owner

I'm working on the composer install issue now, hopefully will have that tagged soon, and then get the updated version into Drupal VM's master branch. I needed this feature for a project I'm working on now :)

@geerlingguy
Copy link
Owner

@Graloth - if you get a chance, can you try with the master branch, and set the variable:

drupal_deploy_composer_install: no

...and make sure that works like you'd want it to work?

@Graloth
Copy link
Author

Graloth commented Aug 22, 2017

@geerlingguy It does indeed work as I expect it to, thanks for the help :D

ashabed pushed a commit to debugacademy/academyvm that referenced this issue Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants