---
# Deployment playbook for bulgaria-vm
# Category: vms
# Services: 10
#
# Usage:
#   ansible-playbook playbooks/deploy_bulgaria_vm.yml
#   ansible-playbook playbooks/deploy_bulgaria_vm.yml -e "stack_deploy=false"
#   ansible-playbook playbooks/deploy_bulgaria_vm.yml --check

- name: Deploy services to bulgaria-vm
  hosts: bulgaria_vm
  gather_facts: true
  vars:
    services: '{{ host_services | default([]) }}'
  tasks:
  - name: Display deployment info
    ansible.builtin.debug:
      msg: Deploying {{ services | length }} services to {{ inventory_hostname }}
  - name: Ensure docker data directory exists
    ansible.builtin.file:
      path: '{{ docker_data_path }}'
      state: directory
      mode: '0755'
  - name: Deploy each enabled service
    ansible.builtin.include_role:
      name: docker_stack
    vars:
      stack_name: '{{ item.stack_dir }}'
      stack_compose_file: '{{ item.compose_file }}'
      stack_env_file: '{{ item.env_file | default(omit) }}'
    loop: '{{ services }}'
    loop_control:
      label: '{{ item.name }}'
    when: item.enabled | default(true)
