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

PIP failing to install inside VM if Ansible local provisioner used #2138

Closed
@very-random-man

Description

@very-random-man

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 2.2.14
VirtualBox 6.0.15r135660
-bash: ansible: command not found

DrupalVM version: 6.0.2
Using latest drupalvm base box 2.0.10

Your OS

  • macOS (version)

Full console output

This is the provisioning output.

==> dev: Running provisioner: drupalvm (ansible_local)...
    dev: Installing Ansible...
    dev: Installing pip... (for Ansible installation)
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

curl https://bootstrap.pypa.io/get-pip.py | sudo python

Stdout from the command:



Stderr from the command:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1883k  100 1883k    0     0  3607k      0 --:--:-- --:--:-- --:--:-- 3600k
Traceback (most recent call last):
  File "<stdin>", line 24226, in <module>
  File "<stdin>", line 199, in main
  File "<stdin>", line 82, in bootstrap
  File "/tmp/tmpnrUI4i/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Summary

I'm not sure if this is a vagrant problem or something that needs to change on the base box. This error has only just started happening. According to something i read, it looks like a problem relating to using Python2 instead of Python3 to execute that script. Apparently Python2 has reached End Of Life.

If you run it this manually you still get errors relating to missing dependencies

curl https://bootstrap.pypa.io/get-pip.py | sudo python3

I managed to create a workaround by adding this to my Vagrantfile.local to change the method of pip installation:

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']

    ansible.pip_install_cmd = "sudo apt-get -y install python-pip"

    # Use pip to get the latest Ansible version when using ansible_local.
    provisioner == :ansible_local && ansible.install_mode = 'pip'
end

This seems a pretty hacky but it does work in the short term.

To make this work out of the box, does something need to happen to the base box so that the default pip installation command works with python3?

If everything is working as planned is there a better way to override the ansible.pip_install_cmd? Would be nice to have that option as drupalvm config. Or should I just rework it as a SHELL provisioner in Vagrantfile.local?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions