Error provisioning Vagrant: mariadb : Set root user password

Hi there, I inherited a situation where the trellis environment is being used to provision servers for a number of projects. I recently upgraded MacOs to Monterrey and haven’t been able to provision a local server since the update. I’ve tried setting up the most recent version of Trellis but am getting an error during the “mariadb : Set root user password” step.

System info:
  Ansible 2.10.17; Vagrant 2.2.18; Linux
  Trellis version (per changelog): "Remove Python 2 support"
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [default] (item=default) => {"ansible_loop_var": "item", "changed": false, "item": "default"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [default] (item=127.0.0.1) => {"ansible_loop_var": "item", "changed": false, "item": "127.0.0.1"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [default] (item=::1) => {"ansible_loop_var": "item", "changed": false, "item": "::1"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [default] (item=localhost) => {"ansible_loop_var": "item", "changed": false, "item": "localhost"}

I’ve tried installing pymysql and setting my PATH for Python3, but am still getting the error.

Any advice or suggestions on what actions I could take would be greatly appreciated. Thanks.

There is a lot of guidance on this forum for fixing Trellis after upgrading MacOS. What have you tried?

https://discourse.roots.io/search?q=Monterey

Are you using trellis-cli? If not, I’d recommend using it because it will automatically manage the Ansible dependencies for you which should hopefully resolve this issue.

You can just run trellis init in the project folder after its installed. After that, use trellis provision.

Thanks for the response. When I try using trellis-cli and provision my development environment I get the following error.

--------------------------------------------------- The following modules failed to execute: ansible.legacy.setup fatal: [192.168.56.5]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform darwin on host 192.168.56.5 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information."]}}}

I’ve tried setting an alias for python=’/usr/bin/python3’ locally and adding “vagrant_ansible_python_interpreter: ‘/usr/bin/python3’” to the vagrant.default.yml file, but I’m not sure if I’m addressing the right issue, since the errors seem to be on the virtual machine.

That message about Python is just a warning (it’s under warnings).

The actual error is above it:

“module_stderr”: “sudo: a password is required\n”

Which is a strange one… I suggest posting your entire output log. It’s not really possible to troubleshoot with just that small output in isolation.

I’m also getting the same error (The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.), but I haven’t recently updated macOS.

I had provisioned a server using Trellis @ #1355, not using Trellis CLI initially. I’ve since updated to the latest Trellis @ #1373 and now I can’t reprovision the server, getting the error above. I’ve tried both with and without Trellis CLI.

The differences in Trellis in that period that might be affecting this are removal of Python 2 in favour of Python 3, and creating the my.cnf credentials file earlier.

Changes in my local setup since updating Trellis: I’ve updated Ansible to 2.11.9 and ran ansible-galaxy collection install community.general to avoid errors from #1365. I also updated to the latest Trellis CLI (1.6.0).

Looking into it, will report back if I learn anything.

Edit: python -V on the remote server shows Python 2.7.18.

Edit 2 (SOLVED): I had to remove Python 2 from the server, using:

sudo apt remove python2
sudo apt autoremove --purge

Usual cautions apply; mine was a brand new production server that didn’t matter if it messed up.

Edit 3: You may also be interested in [BUG] Host uses wrong python interpreter · Issue #1371 · roots/trellis · GitHub.

3 Likes

Thank you @dalepgrant — this has worked on a staging environment and I am wondering if it’s safe to remove python2, based on the solution above, in a production environment going forward? Have you been able to provision and deploy without any issues since?

I’ve had no issues, but I’ve also updated Trellis to include #1373 which should solve the issue anyway. If you’re up to date with the latest trellis and still having issues, see my comment on #1371, which might help you get further.

Let us (and future readers) know how you go :+1: