Skip to content

Instantly share code, notes, and snippets.

@rastaman
Created October 28, 2018 10:56
Show Gist options
  • Select an option

  • Save rastaman/27e56aaad11d7faea50ad671477e5261 to your computer and use it in GitHub Desktop.

Select an option

Save rastaman/27e56aaad11d7faea50ad671477e5261 to your computer and use it in GitHub Desktop.
Deploy a docker-compose setup with ansible
---
# $ PIP_REQUIRE_VIRTUALENV=false pip3 install docker-compose
# $ ansible-playbook forge.yml -e ansible_python_interpreter=python3
- name: Deploy a docker-compose setup
hosts: localhost
vars_files:
- docker-compose.yml
tasks:
- name: Create volumes
docker_volume:
name: "{{ item.key }}"
state: present
with_dict: "{{ services }}"
- name: Pull images
docker_image:
name: "{{ item.value.image }}"
state: present
with_dict: "{{ services }}"
- name: Deploy containers
docker_service:
files:
- docker-compose.yml
project_src: "{{ playbook_dir }}"
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment