debops / debops-tools

Your Debian-based data center in a box
https://debops.org/
GNU General Public License v3.0
1.07k stars 116 forks source link

OSX - debops command fails with Ansible from Homebrew #159

Closed hbokh closed 8 years ago

hbokh commented 8 years ago

On Mac OS X, the command debops seems to work only when Ansible is installed from pip. With Ansible installed through Homebrew, this is the error:

> debops
Traceback (most recent call last):
  File "/usr/local/bin/debops", line 36, in <module>
    import ansible
ImportError: No module named ansible

It works when uninstalling from Homebrew and use pip instead, but I wonder, is there any way around this, without installing Ansible from pip?

drybjed commented 8 years ago

I'm not really sure. IIRC, Homebrew and pip environments on MacOS X are separate and cannot be crossed over without messing stuff up. Perhaps any MacOS X users could clarify this?

xorgic commented 8 years ago

Hi hbokh!

Debops and Ansible from Homebrew works fine, the problem is that python on OSX expects the modules to placed in specific folders by default, but you can add to the list of folders that python should look into when trying to resolve modules during the import.

Oh well, less talk more action, place the code below into your bashrc or just execute it before debops command and it will work.

export PYTHONPATH="/usr/local/Cellar/ansible/2.1.0.0/libexec/lib/python2.7/site-packages:/usr/local/Cellar/ansible/2.1.0.0/libexec/vendor/lib/python2.7/site-packages:$PYTHONPATH"

Please note that the bash version of OSX is old, and that some Debops feature require v4.3 mainly the PKI, you can upgrade bash with Homebrew, and depending on you version of OSX you might have to modify some more in order to get it working.

For El Capitan or above you will have to disable the SIP in order to link the new bash. Ref to disable SIP

hbokh commented 8 years ago

Thank you @xorgic - that did the trick! Uninstalled Ansible from pip; reinstalled from Homebrew; set PYTHONPATH; debops works (I was on bash v4.3.46 on MacOS already).

Might be handy to put somewhere in your sweet documentation though.

drybjed commented 8 years ago

@xorgic If you want, you could add a file detailing the needed steps on MacOS X in the debops/debops-tools repository, in the docs/ directory.