ERROR! Ansible >= 2.4.0.0 is required when using Python 3

Just pulled a fresh clone of Trellis and Bedrock. Updated YMLs, run Vagrant up and immediately get this:

PLAY [WordPress Server: Install LEMP Stack with PHP 7.2 and MariaDB MySQL] *****
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback.vars.CallbackModule object at 0x104b216d0>): Ansible

= 2.4.0.0 is required when using Python 3. Either downgrade to Python 2 or
update your Ansible version to 2.5.3.

ERROR! Ansible >= 2.4.0.0 is required when using Python 3.
Either downgrade to Python 2 or update your Ansible version to 2.5.3.
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.


I Run the following and it shows that I am using 2.4.0.0:

➜ trellis git:(master) ✗ ansible --version
ansible 2.4.0.0
config file = /Users/username/Sites/website.com/trellis/ansible.cfg
configured module search path = [u’/Users/username/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.13 (default, May 11 2017, 12:49:28) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

And I’m not even using Python3:

➜ trellis git:(master) ✗ python --version
Python 2.7.10


Any ideas Trellis ninjas?

:thinking:

Mind adding these two lines to output the versions?

--- a/lib/trellis/plugins/vars/version.py
+++ b/lib/trellis/plugins/vars/version.py
@@ -18,6 +18,9 @@ version_requirement = '2.4.0.0'
 version_tested_max = '2.5.3'
 python3_required_version = '2.5.3'

+display.warning(str(version_info[0]))
+display.warning(__version__)
+
 if version_info[0] == 2 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
     raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
         'Either downgrade to Python 2 or update your Ansible version to {}.').format(__version__, python3_required_version))

If you re-run you’ll see something like:

PLAY [Set ansible_python_interpreter] ******************************************
 [WARNING]: 3

 [WARNING]: 2.5.3

You can just ctrl+c after that.

Also for the time being, feel free to comment out that version in the file above to skip it.

Got the following:

PLAY [WordPress Server: Install LEMP Stack with PHP 7.2 and MariaDB MySQL] *****
 [WARNING]: 2

 [WARNING]: 2.4.0.0

 [WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback.vars.CallbackModule object at 0x111a446d0>): Ansible
>= 2.4.0.0 is required when using Python 3. Either downgrade to Python 2 or
update your Ansible version to 2.5.3.

ERROR! Ansible >= 2.4.0.0 is required when using Python 3.
Either downgrade to Python 2 or update your Ansible version to 2.5.3.
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
--- a/lib/trellis/plugins/vars/version.py
+++ b/lib/trellis/plugins/vars/version.py
@@ -18,9 +18,9 @@ version_requirement = '2.4.0.0'
 version_tested_max = '2.5.3'
 python3_required_version = '2.5.3'

-if version_info[0] == 2 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
-    raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
-        'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))
+# if version_info[0] == 2 and not ge(LooseVersion(__version__), LooseVersion(python3_required_version)):
+#   raise AnsibleError(('Ansible >= {} is required when using Python 3.\n'
+#       'Either downgrade to Python 2 or update your Ansible version to {}.').format(python3_required_version, python3_required_version))

 if not ge(LooseVersion(__version__), LooseVersion(version_requirement)):
     raise AnsibleError(('Trellis no longer supports Ansible {}.\n'

You did at least identify that error message was wrong. I just updated it but that won’t fix your actual issue.

Wow okay I don’t even know how this slipped by :flushed:

It should be checking if version_info[0] == 3 and not == 2. So that’s the fix. I’ll push a commit in a minute.

Fixed in https://github.com/roots/trellis/pull/1040.

Sorry about that :pensive:

Yeap, changing that to “3” did the trick, thank you sir!

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