Docker Module ImportError with kolla-ansible

asked 2017-01-09 09:22:12 -0600

thomas.oneill gravatar image


I don't seem to be able to shake the following ImportError:

(env) stack@control00:~/kolla-ansible$ kolla-ansible prechecks -i ansible/inventory/multinode -p ansible/site.yml --configdir /etc/kolla -e ansible_become=true -e ansible_become_method=sudo
Pre-deployment checking : ansible-playbook -i ansible/inventory/multinode -e @/etc/kolla/globals.yml -e @/etc/kolla/passwords.yml -e CONFIG_DIR=/etc/kolla  -e ansible_become=true -e ansible_become_method=
sudo -e action=precheck ansible/site.yml

PLAY [Gather facts for all hosts] **********************************************

[ ... irrelevant output omitted ... ]

TASK [prechecks : Checking docker-py version] **********************************
fatal: [control00]: FAILED! => {"changed": false, "cmd": ["python", "-c", "import docker; print docker.__version__"], "delta": "0:00:00.019425", "end": "2017-01-09 15:12:25.822150", "failed": true, "failed_when_result": true, "rc": 1, "start": "2017-01-09 15:12:25.802725", "stderr": "Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: No module named docker", "stdout": "", "stdout_lines": [], "warnings": []}
        to retry, use: --limit @/home/stack/kolla-ansible/ansible/site.retry

PLAY RECAP *********************************************************************
compute00                  : ok=1    changed=0    unreachable=0    failed=0
control00                  : ok=22   changed=0    unreachable=0    failed=1

Command failed ansible-playbook -i ansible/inventory/multinode -e @/etc/kolla/globals.yml -e @/etc/kolla/passwords.yml -e CONFIG_DIR=/etc/kolla  -e ansible_become=true -e ansible_become_method=sudo -e action=precheck ansible/site.yml

I've tried with virtual environments using both Python 2 and 3, all I've done on this Ubuntu 16.04 box so far is:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev
git clone
pip install kolla-ansible/requirements.txt
pip install kolla-ansible
pip install ansible

And also to install the latest version of Docker as documented (here).

The docker-py module is installed from the requirements.txt file, but I've also tried installing the regular docker module in pip, and also switching between either of these being installed as well as both.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-09 13:38:38 -0600

Hi des_consolado,

As said in IRC, the problem is in the virtual environments. When Ansible connect to a node, it will create a new session and the virtual environment is not activated yet (may be in other user/session).

When creating a new virtual environment, the user have to activate it in the same shell/session before doing any action involved with the virtualenv.

Of course, you can trick the system to activate the virtual environment in every session. Look at google about "virtualenv at boot time" there are thousands of blog post about that. But in my opinion virtual environments are not designed for that.

For now, I never heard about someone using any deliverable from Kolla project. I encourage you to use system userspace and not isolating python libraries.

Maybe in an all-in-one deployment using all-in-one inventory file, kolla-ansible works fine as the connection is local (Don't know if ansible_connection=local creates a new session or not, I have to test that)


edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2017-01-09 09:22:12 -0600

Seen: 1,953 times

Last updated: Jan 09 '17