Question:
I’m trying to execute ansible2 commnads…
When I do:
1 2 |
ansible-playbook -vvv -i my/inventory my/playbook.yml |
I get:
Unexpected Exception: name ‘basestring’ is not defined
the full traceback was:
1234567891011 Traceback (most recent call last):File "/usr/local/bin/ansible-playbook", line 85, insys.exit(cli.run())File "/usr/local/lib/python3.4/site-packages/ansible/cli/playbook.py", line 150, in runresults = pbex.run()File "/usr/local/lib/python3.4/site-packages/ansible/executor/playbook_executor.py", line 87, in runself._tqm.load_callbacks()File "/usr/local/lib/python3.4/site-packages/ansible/executor/task_queue_manager.py", line 149, in load_callbackselif isinstance(self._stdout_callback, basestring):NameError: name 'basestring' is not defined
Here is ansible --version
:
1 2 3 4 |
ansible 2.0.0.2 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides |
And here is python --version
1 2 |
Python 3.4.3 |
Answer:
Ansible below version 2.5 requires Python 2.6 or 2.7 on the control host: Control Node Requirements
basestring
is no longer available in Python 3. From What’s New In Python 3.0:
The builtin
basestring
abstract type was removed. Usestr
instead. Thestr
andbytes
types don’t have functionality enough in common to warrant a shared base class. The2to3
tool (see below) replaces every occurrence ofbasestring
withstr
.
So the solution is to either upgrade Ansible or downgrade Python.