---
- name: "include docker-compose role"
  include_role: 
    name: docker-compose

- name: "include role nginx-domain-setup for {{application_id}}"
  include_role:
    name: nginx-domain-setup
  vars:
    domain: 	"{{ domains[application_id] }}"
    http_port: 	"{{ ports.localhost.http[application_id] }}"

- name: "include role docker-repository-setup for {{application_id}}"
  include_role: 
    name: docker-repository-setup

- name: "Check if host-specific config.yaml exists in {{ config_inventory_path }}"
  stat:
    path: "{{ config_inventory_path }}"
  delegate_to: localhost
  become: false
  register: config_file

- name: Copy host-specific config.yaml if it exists
  template:
    src: "{{ config_inventory_path }}"
    dest: "{{docker_repository_path}}/app/config.yaml"
  notify: docker compose project setup
  when: config_file.stat.exists

- name: Copy default config.yaml from the role template if host-specific file does not exist
  template:
    src: "config.yaml.j2"
    dest: "{{docker_repository_path}}/app/config.yaml"
  notify: docker compose project setup
  when: not config_file.stat.exists

- name: add docker-compose.yml
  template:
    src:  docker-compose.yml.j2 
    dest: "{docker_compose.directories.instance}}docker-compose.yml"
  notify: docker compose project setup