Added role docker/compose-git

master
Felix Stupp 4 years ago
parent c8fdc4fae9
commit 398ed9084c
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -0,0 +1,18 @@
---
# Required arguments
#domain: example.com # to derive instance_name
instance_name: "{{ domain }}" # required if domain is not set
#repo_url: https://git.example.com/app/docker.git
# Optional arguments
repo_version: master # branch/tag of git repository to use
compose_overrides: "" # syntax of common docker-compose file
main_compose_name: docker-compose.yml # to derive main_compose_path
#user_directory # to derive docker_directory
docker_directory: "{{ user_directory }}/docker:{{ instance_name }}"
repository_directory: "{{ docker_directory }}/repository"
main_compose_path: "{{ repository_directory }}/{{{ main_compose_name }}"
compose_override_path: "{{ docker_directory }}/compose.override.yml"

@ -0,0 +1,6 @@
---
allow_duplicates: yes
dependencies:
- role: docker/application

@ -0,0 +1,32 @@
---
- name: Ensure directory for repository exists
file:
state: directory
path: "{{ docker_directory }}"
owner: root
group: root
mode: u=rwx,g=rx,o=rx
- name: Clone git repository
git:
repo: "{{ repo_url }}"
dest: "{{ repository_directory }}"
version: "{{ repo_version }}"
- name: Configure docker-compose overrides
copy:
content: "{{ compose_overrides }}"
dest: "{{ compose_override_path }}"
validate: "/usr/bin/docker-compose -f {{ main_compose_path | quote }} -f %s config" # requires original compose file because override is not (always) valid only
- name: Build and start docker containers
docker_compose:
state: present
project_name: "{{ instance_name }}"
project_src: "{{ repository_directory }}"
files:
- "{{ main_compose_name }}"
- "{{ compose_override_path }}"
build: yes
recreate: smart
Loading…
Cancel
Save