- name: Create credentials Folder
  file:
    path: /data/apps/{{appname}}
    state: directory

- name: Copy .env
  copy: src=./roles/{{app}}/templates/.env  dest=/data/apps/{{appname}}/.env

- name: Copy init_without_docker.sh
  copy: src=./roles/{{app}}/templates/init_without_docker.sh  dest=/data/apps/{{appname}}/init_without_docker.sh

- name: Excute Preparation if have pre.yml
  block:
    - name: Check if pre.yml exists
      stat:
        path: ./roles/{{app}}/tasks/pre.yml
      register: pre_exists
      delegate_to: 127.0.0.1
      
    - name: Excute pre.yml
      include_tasks: roles/{{app}}/tasks/pre.yml
      when: pre_exists.stat.exists == True
