Deploy a docker-compose stack (TM) remotely.
The host needs to have docker
and docker-compose
installed and the ansible_user
must be able to run docker.
- docker_compose_path: Path to
docker-compose
binary defaults to/usr/local/bin/docker-compose
- remote_deploy_base_path: Base path, where the docker-compose stack is deployed, defaults to
/srv/docker
(which will most likely need sudo perms) - remote_deploy_name: Folder name that gets appended to the remote_deploy_base_path; defaults to
docker-stack
- remote_pull_images: Should
docker-compose pull
be run before bringing up the stack? Defaults tofalse
. - deploy_path: Path where to local
docker-compose.yml
is stored; will get copied to server and must end with/
! - (optional) remote_docker_login_registry: Private docker registry; initially not set and thus will default to the DockerHub.
- (optional) remote_docker_login_user: Login for (private) docker registry; initially not set.
- (optional) remote_docker_login_pass: Password for (private) docker registry; initially not set. `
- (optional) force_recreation: Force container recreation, by calling
docker-compose down
before bringing the stackup -d
. It defaults tofalse
. This is useful if you have changes that a normalup -d
would not pick up (i.e. changes in bind-mounted volumes). - (optional) force_recreation_args: Additional arguments that are used for the remote
docker-compose down
call before bringing up the stack. Defaults to|| true
(sic!) to prevent failure ofdocker-compose down
because it exits with non-zero codes, while for example trying to delete an external network. - remote_remove_only: Remove remote docker-compose stack by invoking
docker-compose down
; defaults tofalse
. Setting it to true, will skip deploying the stack (but will still copy it). - remote_remove_args: Additional arguments that get passed to
docker-compose down
if remote_remove_only is set totrue
. Defaults to--rmi all --remove-orphans
Note: it is advised to set remote_docker_login_pass via the environment when invoking ansible-playbook
instead of setting it in the actual playbook (and thus keep secrets out of a repo). An easy way to do so would be ansible-playbook -i inventory -e "remote_docker_login_pass=$MY_DOCKER_LOGIN" playbook-yml
Nope.
- hosts: servers
roles:
- role: zal_ari.deploy_docker_compose
deploy_path: test/fixture/
remote_deploy_base_path: /tmp/docker
remote_deploy_name: hello-world
remote_pull_images: True
- allow for login into multiple private docker registries
- add docker-based test env
- use Travis for building and automagic releases to Ansible Galaxy.
PRs are welcome.
MIT
Christian Ulbrich christian.ulbrich@zalari.de, Zalari GmbH