- name: base packages
  sudo: yes
  apt:
    name={{ item }}
    state=present
  with_items:
    - build-essential
    - cmake
    - git
    - redis-server

- name: ensure docroot exists
  sudo: yes
  file:
    path="{{ cdash_install_path }}"
    state=directory
    owner=vagrant
    group=vagrant

- name: add apache user to the vagrant group
  sudo: yes
  user:
    name=www-data
    groups=vagrant
    append=yes

- name: make vagrant the apache run user
  sudo: yes
  replace:
    dest=/etc/apache2/envvars
    regexp='www\-data'
    replace='vagrant'

- name: clone cdash
  git:
    repo=https://github.com/Kitware/CDash.git
    version={{ cdash_version }}
    dest="{{ cdash_install_path }}"

- name: install php dependencies
  command: "composer install"
  args:
    chdir: "{{ cdash_install_path }}"

- name: install npm dependencies
  shell: "source /home/vagrant/.profile && npm install"
  args:
    chdir: "{{ cdash_install_path }}"
    executable: /bin/bash

- name: run gulp
  shell: "source /home/vagrant/.profile && ./node_modules/.bin/gulp"
  args:
    chdir: "{{ cdash_install_path }}"
    executable: /bin/bash
