Reputation: 1494
I am trying to use the Ansible Docker module at the moment but I am currently encountering this error when I try to run my playbook -
NameError: global name 'DEFAULT_DOCKER_API_VERSION' is not defined
I found an official bug regarding this at https://github.com/ansible/ansible-modules-core/issues/1792.
I have tried the workaround by installing docker-py but have had no joy as of yet.
Any ideas on what could be going wrong? I'm trying to run my Playbook from my local OSX host that connects to AWS.
Upvotes: 1
Views: 1759
Reputation: 1661
TLDR; -e use_tls=encrypt
dockerpy==1.5.0
~/.bash_profile
I have eval "$(docker-machine env default)"
which will run
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/meyers/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
Now that your environment is setup let me tell you the fix. The docker module needs the parameter tls=encrypt
. You can supply it to each invocation of the docker module in your Ansible task or you can set it "globally" via -e use_tls=encrypt
or in your playbook:
- hosts: all
vars:
use_tls: 'encrypt'
tasks:
...
Upvotes: 0
Reputation: 434
Normally it is related to the absence of pip or docker-py library.
I have this in my docker ansible role.
- name: install the required packages
apt: pkg={{ item }} state=present update_cache=yes
with_items:
- python-pip
- name: Install docker-py as a workaround for Ansible issue
pip: name=docker-py version=1.2.3
Upvotes: 0
Reputation: 1494
After further investigation we managed to get it to work by using -
name: Install Docker PY
pip: name=docker-py==1.1.0
In our .yml file
Upvotes: 1
Reputation: 59969
pip is a package manager for python and installs with it. So what you want to do is installing python.
On OS X I recommend you to first install Homebrew, which is a package manager for OS X. The command to install Homebrew is
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After Homebrew is installed you can install python and along with it pip with
brew install python
Upvotes: 0