missing ansible.callbacks module

Hello,

I’m completely new to ansible and I’m not even actually using it for direct development. A software I’m trying to install depends on ansible and it always reports the following error when started:

root@cc9ce7befef1:~# elasticluster
Traceback (most recent call last):
File “/usr/local/bin/elasticluster”, line 9, in
load_entry_point(‘elasticluster==1.2’, ‘console_scripts’, ‘elasticluster’)()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 547, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2720, in load_entry_point
return ep.load()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2380, in load
return self.resolve()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2386, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/local/lib/python2.7/dist-packages/elasticluster/init.py”, line 31, in
from elasticluster.providers.ansible_provider import AnsibleSetupProvider
File “/usr/local/lib/python2.7/dist-packages/elasticluster/providers/ansible_provider.py”, line 30, in
import ansible.callbacks as anscb
ImportError: No module named callbacks

I have installed/upgraded ansible several times, but the error does not disappear. I’m also not a python developer, so any help would be very welcome.

Thanks,
manuele

ansible.callbacks no longer exists in 2.0.

it sounds like you are calling Ansible from a python script. If so, this process is very different in 2.0.
You probably need to reach out to whomever wrote the software or downgrade your ansible to 1.9.

If you want to take a stab at fixing it, the way I’ve solved this for my scripts is:

`
from ansible import version as ANSIBLE_VERSION
if ANSIBLE_VERSION.startswith(‘2’):
from ansible.cli.playbook import PlaybookCLI
else:
from ansible.playbook import PlayBook
from ansible.inventory import Inventory
from ansible.callbacks import PlaybookCallbacks, AggregateStats, PlaybookRunnerCallbacks

def run_playbook():
if ANSIBLE_VERSION.startswith(‘2’):
return _run_playbook_v20()
else:
return _run_playbook_v19()

def _run_playbook_v20():
cli = PlaybookCLI()
cli.parse()
return cli.run()

def _run_playbook_v19(cliargs):
class playbook_cb(PlaybookCallbacks):

… etc …

`

Thanks Mike!
I downgraded to 1.9.4 and it worked well.