Ansible role to deploy applications via docker-compose
.
The deploying host which is running the playbook should have at least Ansible 2.3 so that
the bug with copy
module
not preserving permissions is fixed.
The target host should have docker
, docker-compose
and the python library docker-py
installed.
code_source
: 'local' orgit
. Set tolocal
to get source code from the host machine, orgit
from a git repository.git_repo
: URL for a git repository.get_local_commit
: Ifcode_source
is set togit
and this is set totrue
, will get a commit from the local directory instead of using a branch.git_repo_version
: Ifcode_source
is set togit
, specify a commit or branch name to deploydocker_compose_files
: An array ofdocker-compose
files to use to deploylocal_path
: ifcode_source
islocal
or ifget_local_commit
is true, the path to the local source code.project_directory
: The path on the target host to deploy source code to.remove_volumes
: Set toyes
to remove existing volumes while deploying. Defaults tono
.pull_images
: Set toTrue
to pull images from a registry before creating the containers. Defaults toTrue
.build_images
: Set toTrue
to build images for containers. Defaults toTrue
.docker_become
: Set toTrue
tobecome
with docker commands.
---
- name: "Deploy Application"
hosts: all
roles:
- role: docker_compose_deploy
code_source: 'local'
project_directory: "/home/{{ ansible_user_id }}/app"
local_path: "{{ playbook_dir }}/app"
Apache 2.0
Write tests