---

- name: Install dependencies
  yum:
    name:
      - nodejs
      - git
  tags: wbo

- name: Clone wbo repo
  git:
    repo: "{{ wbo_git_url }}"
    dest: "{{ wbo_root_dir }}/app"
    force: True
  notify: restart wbo
  become_user: wbo_{{ wbo_id }}
  register: wbo_git
  tags: wbo

- name: Install wbo
  npm:
    path: "{{ wbo_root_dir }}/app"
  become_user: wbo_{{ wbo_id }}
  when: wbo_git.changed
  tags: wbo

- name: Set permissions on server data dir
  file: path={{ wbo_root_dir }}/app/server-data owner=wbo_{{ wbo_id }} mode=700
  tags: wbo

- name: Deploy systemd unit
  template: src=wbo.service.j2 dest=/etc/systemd/system/wbo-{{ wbo_id }}.service
  register: wbo_unit
  tags: wbo

- name: Reload systemd
  systemd: daemon_reload=True
  when: wbo_unit.changed
  tags: wbo

