ansible: ImportError: No module named ansible.playbook
08 Mar 2014 in TIL
TL;DR: brew link --overwrite ansible
This week I tried to run ansible-playbook
on OSX and received the following error message:
bash
$ ansible-playbookImportError: No module named ansible.playbook
I also tried running ansible
, but that didn't work either
bash
$ ansibleTraceback (most recent call last):File "/usr/local/bin/ansible", line 24, in <module>from ansible.runner import RunnerImportError: No module named ansible.runner
Strange! The binaries exist but the actual underlying code wasn't there. I decided to try reinstalling:
bash
$ brew install ansibleWarning: ansible-1.4.4 already installed, it's just not linked
Aha! So we have it installed but it's not available. Let's try and link everything needed:
bash
$ brew link ansibleLinking /usr/local/Cellar/ansible/1.4.4... Warning: Could not link ansible. Unlinking...Error: Could not symlink file: /usr/local/Cellar/ansible/1.4.4/bin/ansible-pullTarget /usr/local/bin/ansible-pull already exists. You may need to delete it.To force the link and overwrite all other conflicting files, do:brew link --overwrite formula_name
It didn't work as it already exists. It was already broken, so running with --overwrite
wouldn't break anything for me.
bash
$ brew link --overwrite ansibleLinking /usr/local/Cellar/ansible/1.4.4... 92 symlinks created
Let's check if it works
bash
$ ansible --versionansible 1.4.4
Job done! ansible
and ansible-playbook
work fine again.