Ansible installation using pip broken?

2,277 views
Skip to first unread message

an...@cultureamp.com

unread,
Feb 24, 2016, 7:56:39 PM2/24/16
to Ansible Development
Hi there,

I am trying to install Ansible within a Docker container (plain Ubuntu 14.04) to be used as a test environment.
The Python version is managed by `pyenv`, and I am using `pip` to install Ansible. This is the output of the "pip freeze" command after installing Ansible:

```
root@7e408538fd38:/usr/src/myapp# pip freeze
ansible==2.0.0.2
chardet==2.3.0
colorama==0.2.5
ecdsa==0.13
html5lib==0.999
httplib2==0.8
Jinja2==2.8
MarkupSafe==0.23
paramiko==1.16.0
pycrypto==2.6.1
python-distutils-extra==2.28
PyYAML==3.11
requests==2.2.1
six==1.5.2
urllib3==1.7.1
wheel==0.24.0
```

When I run one of my playbooks that uses the `apt` module, I get the following error indicating that the `python-apt` module is missing:
```
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Could not import python modules: apt, apt_pkg. Please install python-apt package."}
```

When trying to install python-apt module manually using pip, I get an error about more modules missing:

```
root@c833f66ef7c0:/usr/src/myapp# pip install python-apt
Collecting python-apt
  Downloading python-apt-0.7.8.tar.bz2 (49kB)
    100% |################################| 53kB 84kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-y4ASYs/python-apt/setup.py", line 6, in <module>
        from DistUtilsExtra.command import *
    ImportError: No module named DistUtilsExtra.command

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-y4ASYs/python-apt
```

I would expect these dependencies to me managed by pip when installing the Ansible package. Am I missing anything?

Any input would be appreciated.
Thanks for your help.

Angel

Brian Coca

unread,
Feb 24, 2016, 8:05:57 PM2/24/16
to an...@cultureamp.com, Ansible Development
python-apt is a dependency not of ansible master, but of the apt module, it must be installed on the 'target' machine not on the 'master'.

The module itself should try to install it automatically, but it seems there are issues with that in your systems.


----------
Brian Coca

an...@cultureamp.com

unread,
Feb 24, 2016, 10:10:48 PM2/24/16
to Ansible Development
Thanks Brian.

You are right. The module installs the python-apt package on the target instance, but the module will only be available to the Ubuntu Python installation (/usr/lib/python2.7/dist-packages/apt/), not the one managed by pyenv.

I tried to install the python-apt module using pip (within the pyenv-managed Python installation), but get a dependency error:

root@617d09e567c1:/usr/src/myapp# pip install python-apt
Collecting python-apt
  Downloading python-apt-0.7.8.tar.bz2 (49kB)
    100% |################################| 53kB 168kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-W6kZPY/python-apt/setup.py", line 6, in <module>
        from DistUtilsExtra.command import *
    ImportError: No module named DistUtilsExtra.command

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-W6kZPY/python-apt


But this is obviously not related to Ansible. 

Thanks for your help.
Angel

Colin Davis

unread,
Mar 9, 2016, 4:08:17 PM3/9/16
to Ansible Development
I've run into this problem as well - It's annoying :/

When I run with system python, I can use apt/yum/etc, but when I use virtualenvs, there's always complications with dist-only packages.
I haven't found any easy way to work around these.
My solution has been to replace the apt/yum lines with shell calls instead, but I'd love a better way to do this.
Reply all
Reply to author
Forward
0 new messages