---
- name: "include docker-central-database"
  include_role: 
    name: docker-central-database

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

- name: "Create {{openproject_plugins_folder}}"
  file:
    path: "{{openproject_plugins_folder}}"
    state: directory
    mode: '0755'

- name: "Transfering Gemfile.plugins to {{openproject_plugins_folder}}"
  copy:
    src: Gemfile.plugins
    dest: "{{openproject_plugins_folder}}Gemfile.plugins"
  notify:
    - docker compose project build and setup

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

- name: "create {{dummy_volume}}"
  file:
    path: "{{dummy_volume}}"
    state: directory
    mode: 0755

- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

- name: flush docker service
  meta: flush_handlers

- name: Set settings in OpenProject
  shell: >
    docker compose exec web bash -c "cd /app &&
    RAILS_ENV={{ CYMAIS_ENVIRONMENT | lower }} bundle exec rails runner \"Setting[:{{ item.key }}] = '{{ item.value }}'\""
  args:
    chdir: "{{ docker_compose.directories.instance }}"
  loop: "{{ openproject_rails_settings | dict2items }}"

- name: Setup LDAP
  include_tasks: ldap.yml
  when: applications[application_id].features.ldap | bool