How to do it…

  1. Let's install the pip package docker-py in a version greater than 1.7.0. Ansible will use this Python library to interact with the Docker API:
$ pip install 'docker-py>=1.7.0'
  1. Let's install the docker-compose pip package in a version greater than 1.7.0. Ansible will use this to interact with Docker compose:
$ pip install 'docker-compose>=1.7.0'
  1. The Ansible module connects with the Docker API, as we mentioned earlier. Using parameters passed with tasks, we will be using a local Docker engine to create and manage Docker containers. It connects to a docker parameter using the parameter called docker_host. We can also set the environment variable to DOCKER_HOST.

We should note that the default host used by the Ansible module ...

Get Ansible 2 Cloud Automation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.