add: ansible deploy.yml
This commit is contained in:
33
ansible/deploy.yml
Normal file
33
ansible/deploy.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
- name: GitOps deploy docker compose services (Semaphore)
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
|
||||||
|
vars:
|
||||||
|
# Repo root (Semaphore already cloned it)
|
||||||
|
repo_dir: "{{ playbook_dir }}/.."
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Show repo root (debug)
|
||||||
|
debug:
|
||||||
|
msg: "Repo root: {{ repo_dir }}"
|
||||||
|
|
||||||
|
- name: Find all compose.yml files
|
||||||
|
find:
|
||||||
|
paths: "{{ repo_dir }}"
|
||||||
|
patterns: "compose.yml"
|
||||||
|
file_type: file
|
||||||
|
depth: 2
|
||||||
|
register: compose_files
|
||||||
|
|
||||||
|
- name: Deploy each service
|
||||||
|
shell: |
|
||||||
|
set -e
|
||||||
|
service_dir=$(dirname "{{ item.path }}")
|
||||||
|
echo "=================================================="
|
||||||
|
echo "Deploying service in $service_dir"
|
||||||
|
echo "=================================================="
|
||||||
|
docker compose -f "{{ item.path }}" up -d
|
||||||
|
loop: "{{ compose_files.files }}"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
Reference in New Issue
Block a user