---
# application tasks to be customized and to run after the main provision

# Install project dependencies
- name: Install composer dependencies (This can take up to 30 minutes to run)
  composer:
    command: "install"
    arguments: "--no-interaction"
    prefer_source: "yes"
    working_dir: "/var/www/openeyes"
    no_dev: "no"
  become: true
  become_user: vagrant


# Populate MySQL database TODO; Use info in all.yml / vars.yml
# - mysql_db:
#     state=import
#     name=openeyes
#     login_user=openeyes
#     login_password=oe_test
---
# application tasks to be customized and to run after the main provision

# Install project dependencies
- name: Install composer dependencies (This can take up to 30 minutes to run)
  composer:
    command: "install"
    arguments: "--no-interaction"
    prefer_source: "yes"
    working_dir: "/var/www/openeyes"
    no_dev: "no"
  become: true
  become_user: vagrant


# Populate MySQL database TODO; Use info in all.yml / vars.yml
# - mysql_db:
#     state=import
#     name=openeyes
#     login_user=openeyes
#     login_password=oe_test

# Copy congfig file into place (or use template ?)
# mkdir /var/www/openeyes/protected/runtime
# chmod +w /var/www/openeyes/protected/runtime

- name: Create runtime directory for Yii
  become: yes
  become_method: sudo
  file:
    path: /var/www/openeyes/protected/runtime
    mode: "0755"
    owner: "vagrant"
    group: "vagrant"
    state: directory

# - name: Check local.sample/common.php exists
#   stat:
#     path: /var/www/openeyes/protected/config/local.sample/common.php
#   register: common
#   ignore_errors: true

- name: Copy common.php into place
  command: creates=/var/www/openeyes/protected/config/local/common.php cp /var/www/openeyes/protected/config/local.sample/common.php /var/www/openeyes/protected/config/local/common.php
  # copy:
  #   src: /var/www/openeyes/protected/config/local.sample/common.php
  #   dest: /var/www/openeyes/protected/config/local/common.php
  #   force: false
  # when: common.stat.exists

- name: Copy console.php into place
  command: creates=/var/www/openeyes/protected/config/local/console.php cp /var/www/openeyes/protected/config/local.sample/console.vagrant.php /var/www/openeyes/protected/config/local/console.php

Copy the config common.php and console.php files into place, TODO - replace with templates
Copy the config common.php and console.php files into place, TODO - replace with templates
