---
- name: Create the socket directory
  file: path=/var/run/php-fpm
        owner=deploy
        group=deploy
        state=directory

- name: Generate the virtual host
  template: src=vhost.j2
            dest=/etc/nginx/sites-available/lychee
            mode=755
  notify:
    - Restart Nginx
    - restart php-fpm

- name: Enable the virtual host
  file: path=/etc/nginx/sites-enabled/lychee
        src=/etc/nginx/sites-available/lychee
        state=link
  notify:
    - Restart Nginx
    - restart php-fpm

- name: Create the application directories
  file: path={{ item }}
        owner=deploy
        group=deploy
        state=directory
  with_items:
    - "{{ app_location }}"
    - "{{ app_location }}/shared"
    - "{{ app_location }}/shared/log"
    - "{{ app_location }}/shared/data"
    - "{{ app_location }}/shared/uploads"
    - "{{ app_location }}/current"
  notify:
    - Modify permissions on uploads

- name: Check out the latest revision of the codebase
  git: repo=https://github.com/electerious/Lychee.git
       dest={{ app_location }}/current
       version=master
  sudo: yes
  sudo_user: deploy
  notify:
    - Symlink the shared directories
    - Modify permissions on uploads
    - restart php-fpm

- name: Generate the database config
  template: src=data-config.php.j2
            dest={{app_location}}/shared/data/config.php
            mode=755


---
- name: Install imagemagick
  apt: pkg=php5-imagick state=present

- name: Create the socket directory
  file: path=/var/run/php-fpm
        owner=deploy
        group=deploy
        state=directory

- name: Generate the virtual host
  template: src=vhost.j2
            dest=/etc/nginx/sites-available/lychee
            mode=755
  notify:
    - Restart Nginx
    - restart php-fpm

- name: Enable the virtual host
  file: path=/etc/nginx/sites-enabled/lychee
        src=/etc/nginx/sites-available/lychee
        state=link
  notify:
    - Restart Nginx
    - restart php-fpm

- name: Create the application directories
  file: path={{ item }}
        owner=deploy
        group=deploy
        state=directory
  with_items:
    - "{{ app_location }}"
    - "{{ app_location }}/shared"
    - "{{ app_location }}/shared/log"
    - "{{ app_location }}/shared/data"
    - "{{ app_location }}/shared/uploads"
    - "{{ app_location }}/current"
  notify:
    - Modify permissions on uploads

- name: Check out the latest revision of the codebase
  git: repo=https://github.com/electerious/Lychee.git
       dest={{ app_location }}/current
       version=v2.7.0
  sudo: yes
  sudo_user: deploy
  notify:
    - Symlink the shared directories
    - Modify permissions on uploads
    - restart php-fpm

- name: Generate the database config
  template: src=data-config.php.j2
            dest={{app_location}}/shared/data/config.php
            mode=755

Upgrade to v2.7 of Lychee
Upgrade to v2.7 of Lychee

Adds image resizing. Requires imagemagick.
