---

- include_tasks: ../functions/get_secret.yml
  with_items:
   - { path: /srv/ldap/secret/ldap_admin_pass,  length: 24 }
   - { path: /srv/ldap/secret/ldap_readonly_pass,  length: 24 }

- name: create folder struct for ldap
  file:
    path: "/srv/ldap/{{ item.path }}"
    state: "directory"
    recurse: yes
  with_items:
    - { path: 'database' }
    - { path: 'config' }

- name: Docker Compose Konfig-Datei erstellen
  template:
    src: "{{ item }}"
    dest: "/srv/ldap/{{ item }}"
  with_items:
    - docker-compose.yml
    - Dockerfile 
    - syncrepl_exporter.yml 
  register: config

- name: "stop {{ servicename}} docker"
  docker_compose:
    project_src: "{{ basedir }}"
    state: absent
  when: config.changed

- name: "start {{ servicename}} docker"
  docker_compose:
    project_src: "{{ basedir }}"
    state: present

