Reputation: 91
I have problem executing docker-compose
which is called from inside ansible playbook, I have try few way but all give me an error:
1.
docker_service:
project_src: /test/docker/
command: docker-compose -f {{ name }}_compose.yml up -d
2.
docker_service:
project_src: /test/docker/
files:
src: "{{ name }}_compose.yml"
state: present
Errors are various:
FAILED! => {"changed": false, "msg": "Failed to import docker or docker-py - No module named 'requests'. Try `pip install docker` or `pip install docker-py` (Python 2.6)"}
FAILED! => {"changed": false, "msg": "Unsupported parameters for (docker_service) module: command Supported parameters include: api_version, build, cacert_path, cert_path, debug, definition, dependencies, docker_host, files, hostname_check, key_path, nocache, project_name, project_src, pull, recreate, remove_images, remove_orphans, remove_volumes, restarted, scale, services, ssl_version, state, stopped, timeout, tls, tls_hostname, tls_verify"}
What am I doing wrong?
Upvotes: 2
Views: 948
Reputation: 66
The task below should start up your compose file.
- name: Deploy docker compose
docker_compose:
project_src: /test/docker/
files:
- "./{{ name }}_compose.yml"
state: present
It looks like you don't have the docker
python module installed which is required to use the docker modules in Ansible. You can install that using pip in the task below.
- name: Ensure docker python module is present
pip:
name: docker[tls]
You may also need to install pip which will vary depending on your OS and package manager
Note: Ansible has changed the name of the docker_service
module to docker_compose
starting in version 2.8
Upvotes: 3