missing ansible.callbacks module

1,081 views
Skip to first unread message

Manuele Simi

unread,
Feb 12, 2016, 11:51:56 AM2/12/16
to Ansible Project
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 <module>
    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 <module>
    from elasticluster.providers.ansible_provider import AnsibleSetupProvider
  File "/usr/local/lib/python2.7/dist-packages/elasticluster/providers/ansible_provider.py", line 30, in <module>
    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

Mike Biancaniello

unread,
Feb 12, 2016, 12:15:20 PM2/12/16
to Ansible Project
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 ...


Manuele Simi

unread,
Feb 12, 2016, 2:01:44 PM2/12/16
to Ansible Project
Thanks Mike!
I downgraded to 1.9.4 and it worked well.
Reply all
Reply to author
Forward
0 new messages