=========
Reusable role for any Docker containers (like docker-compose).
- Ansible 2.3.0
docker_container_prefix: prefix
# Create volume
docker_container_volumes: volume_name
# Check http port when container is started
docker_check_port: 8080
# HTTP Headers
docker_check_headers:
API-Key: "test_key"
Host: "example.com"
docker_container:
- name: container-name
path: ../path-to-build # OPTIONAL | Local docker build if needed
image: image/name
restart: always
volumes:
- "volume-name:/path/mount/to"
env:
"{{ env_variables_dict }}"
networks:
- networks_to_connect
---
- hosts: localhost
connection: local
roles:
- docker-run
vars:
docker_container_prefix: mon
docker_container_network: monitoring
docker_container_volume:
- grafana_data
- db_data
docker_container:
- name: postgres
path: ../postgres
restart: always
volumes:
- "db_data:/var/lib/postgresql/data"
env:
"{{ postgres_variables }}"
networks:
- monitoring
- name: grafana
image: grafana/grafana
ports:
- 3000:3000
volumes:
- grafana_data:/var/lib/grafana
env:
"{{ grafana_variables }}"
networks:
- monitoring
Apache 2.0
Ivan Tuzhilkin [email protected]