Files
2026-01-15 09:28:37 +00:00

44 lines
1.2 KiB
YAML

- name: GitOps deploy docker compose services (Semaphore)
hosts: all
become: true
tasks:
- name: Resolve repository root directory (Semaphore-safe)
command: pwd
args:
chdir: "{{ playbook_dir }}"
register: playbook_pwd
- name: Set repo root fact
set_fact:
repo_dir: "{{ playbook_pwd.stdout | dirname }}"
- name: Show repo root (debug)
debug:
msg: "Repo root resolved to: {{ repo_dir }}"
- name: Find all compose.yml files
find:
paths: "{{ repo_dir }}"
patterns: "compose.yml"
file_type: file
depth: 2
register: compose_files
- name: Fail if no compose.yml found (safety)
fail:
msg: "No compose.yml files found under {{ repo_dir }}"
when: compose_files.matched == 0
- 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