Vagrant Up won't work on Win 10
Issue Type
- Bug Report / Support Request
Your Environment
Vagrant 2.2.5 VirtualBox 6.0.8 r130520
Your OS
- OS Name : Microsoft Windows 10 Pro OS Version : 10.0.17763 N/A Build 17763
Full console output
https://gist.github.com/tomo-dev-2018/0583a8abcbf219f8575866efe093e482
Summary
After following your instructions to set up drupal VM on Windows I get the error you can see in the gist above. I'm using DrupalVm 5.0.0 and box 2.0.2 and have the following plugins installed: vagrant-vbguest (0.18.0, global) and vagrant-hostsupdater (1.1.1.160, global)
I've also run into this issue, and changing the Ansible install method got me past this particular issue.
provisioner == :ansible_local && ansible.install_mode = 'pip'
to
provisioner == :ansible_local && ansible.install_mode = 'default'
Not ideal, but seems to be a workaround for now.
@phizev , your solution works, so I think it is a genuine issue. The bad thing is that I can't use drupal console nor drush after drupal has been installed. I get the following error:
`In Connection.php line 420:
SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.`
Has anyone got any idea what could be the problem? @phizev, Can you use drush without problems?
Current workaround I'm using:
- Run Vagrant shell provisioner to work around installs hanging waiting for user input.
- Set Ansible install mode to 'default' instead of 'pip'.
Everything is working as expected as it was before this issue arose.
Changes to Vagrantfile:
...
# Our shell provision script which runs before the Ansible provisioner.
config.vm.provision "shell", path: "pre-ansible.sh"
config.vm.provision 'drupalvm', type: provisioner do |ansible|
ansible.compatibility_mode = '2.0'
...
...
# Use the default install mode as pip is broken at present.
provisioner == :ansible_local && ansible.install_mode = 'default'
...
pre-ansible.sh contains:
#!/bin/bash
# Workaround to stop a question regarding restarting services from the libssl-dev
# upgrade from breaking the Vagrant Ansible provisioner.
export DEBIAN_FRONTEND=noninteractive
echo '#'
echo '# Installing packages to workaround an issue breaking the Ansible provisioner...'
echo '#'
apt-get -yq update
apt-get -yq install build-essential curl git libssl-dev libffi-dev python-dev
echo '#'
echo '# Done! Ansible should now install without issue.'
echo '#'
I'm based on the Ubuntu 18.04 box, and updating to the latest version of DrupalVM has not resolved this.
The issue with the install hanging is due to the upgrade of the installed version of libssl-dev halting at a prompt needing user input to proceed. Resolving this first issue still results in the pip failure in this report.
I believe there is some problem installing the pip package. I've got the same error:
==> drupalvm: Running provisioner: drupalvm (ansible_local)...
drupalvm: Installing Ansible...
drupalvm: Installing pip... (for Ansible installation)
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
pip install --upgrade ansible
Then I entered the VM using vagrant ssh, and tried to execute the command to see some error log or output. The console output was the following:
vagrant@drupalvm:~$ pip
Command 'pip' not found, but can be installed with:
sudo apt install python-pip
After that, i manually installed the python-pip package using sudo apt install python-pip. Exited the SSH console, and run again "vagrant provision". Everything went smoothly from that point for the rest of the provisioning.
Made a change based on @phizev solution, turns out that just installing python-pip and keeping the install mode to 'pip' seems to fix the problem.
Even though this fixes it, the bug seems to be somewhere else, right before installing Ansible, this comes up in the console, "drupalvm: Installing pip... (for Ansible installation)". I dont know where this is originating from but certainly that part is broken, and this seems more like a workaround to me.
Can someone do some testing on the solution i proposed ?
The "pre-ansible.sh" script runs the Vagrant shell provisioner before running the Vagrant Ansible Local provisioner.
The issue is coming in before anything from DrupalVM runs. Vagrant fails to install ansible to use it as a provisioner, you can see where it fails by starting the provision, then when it reaches the point it hangs, disconnect all network access. You will have a list of packages which Vagrant was trying to install, copy that list, and try to install them. You'll see that you are asked a question regarding whether services should be automatically restarted when upgrading the version of OpenSSL (It's a major version upgrade.) Alternatively, start a VM without provisioning it, and run the install of the packages I set to install via the shell provisioner, at present on Ubuntu 18.04 it will bring up the question regarding the SSL upgrade.
That is what the first part of the workaround is for.
Made a change based on @phizev solution, turns out that just installing python-pip and keeping the install mode to 'pip' seems to fix the problem.
I tested that, but as far as I could tell, it meant that Vagrant just used the already installed pip instead of the expected/previous behaviour of installing PIP from source. Installing PIP from source was also failing for myself, so I set it to install "default" as this actually behaves as it should to avoid confusing anyone else whom may be maintaining the project I am involved with in future.
This is definitely workaround, though I believe the proper fix for the issue is beyond the control of DrupalVM, and within the realm of Vagrant for the package installation hang, and then for the PIP install issue, that is either also a Vagrant issue, or an issue with the install script it defaults to using.
I didn't put this in as a PR to DrupalVM as it is horribly hacky, and does not account for any other distro's/package managers etc.
I use phizev's solution to get the Drupal VM to work:
#provisioner == :ansible_local && ansible.install_mode = 'pip'
provisioner == :ansible_local && ansible.install_mode = 'default'
in Vagrantfiile.
If we are ok with the solution mentioned here can we merge my PR to implement it? #1959
This is a bug in Vagrant; for now please follow https://github.com/hashicorp/vagrant/issues/10950 and also if you need to work around it immediately try downgrading to Vagrant 2.2.4.
I fixed it like that:
Add this line to the section in Vagrantfile.
ansible.pip_install_cmd = "curl https://bootstrap.pypa.io/get-pip.py | sudo python"
config.vm.provision 'drupalvm', type: provisioner do |ansible|
ansible.compatibility_mode = '2.0'
ansible.playbook = playbook
ansible.extra_vars = {
config_dir: config_dir,
drupalvm_env: drupalvm_env
}
ansible.raw_arguments = Shellwords.shellsplit(ENV['DRUPALVM_ANSIBLE_ARGS']) if ENV['DRUPALVM_ANSIBLE_ARGS']
ansible.tags = ENV['DRUPALVM_ANSIBLE_TAGS']
# Use pip to get the latest Ansible version when using ansible_local.
ansible.pip_install_cmd = "curl https://bootstrap.pypa.io/get-pip.py | sudo python"
provisioner == :ansible_local && ansible.install_mode = 'pip'
end