Vagrant up - installing ansible via pip syntax error


I just wanted to share this information amongst the roots community, recently python has dropped support for previous versions on 23/01/21. More information here:

When running a new “vagrant up” today, I was caught out by this error:

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 | 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  1521k      0  0:00:01  0:00:01 --:--:-- 1521k
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/tmpf2GbZ5/", line 60
    sys.stderr.write(f"ERROR: {exc}")
SyntaxError: invalid syntax

Adding this line to install python3 and utilities solves this error (on line 125):

ansible.pip_install_cmd = "sudo apt-get install -y python3-distutils && curl -s | sudo python3"

Thank you! :slight_smile:

That did not work for me. I had to log in to the vagrant box with ssh and run a slightly similar command and then provision. This was the command I ran:

sudo rm -rf /usr/bin/python && sudo ln -s /usr/bin/python3 /usr/bin/python && sudo apt-get install -y python3-distutils && curl -s | sudo python

Thanks @dconyard, your solution worked for me too!

This topic was automatically closed after 42 days. New replies are no longer allowed.