---
- name: Install Node, NPM and nginx
  apt: name={{item}} state=installed
  with_items:
       - nodejs-legacy
       - npm
       - nginx-light
- name: Locally install dependencies
  local_action: command npm install
  args:
    chdir: ../api
  become: false
- name: Sync ipfs-search api
  synchronize: src=../../../api/ dest=/usr/local/libexec/ipfs-search-api times=yes partial=yes archive=no recursive=yes
  notify: restart ipfs-search
- name: Create ipfs-search group.
  group: name=ipfs-search system=true state=present
- name: Create ipfs-search user.
  user: name=ipfs-search comment="ipfs-search api" group=ipfs-search system=true state=present home=/nonexistent shell=/usr/sbin/nologin
- name: Install ipfs-search service
  copy: src=ipfs-search.service dest=/etc/systemd/system/ipfs-search.service
  notify: restart ipfs-search
- name: Enable search service
  service: name=ipfs-search enabled=yes state=started
- name: Install nginx configuration
  copy: src=nginx.conf dest=/etc/nginx/nginx.conf
  notify: restart nginx
- name: Enable nginx service
  service: name=nginx enabled=yes state=started

---
- name: Install Node, NPM and nginx
  apt: name={{item}} state=installed
  with_items:
       - nodejs-legacy
       - npm
       - nginx-light
- name: Locally install dependencies
  local_action: command npm install
  args:
    chdir: ../api
  become: false
- name: Create destination folder for search api
  file: path=/usr/local/libexec/ipfs-search-api state=directory
- name: Sync ipfs-search api
  synchronize: src=../../../api/ dest=/usr/local/libexec/ipfs-search-api times=yes partial=yes archive=no recursive=yes
  notify: restart ipfs-search
- name: Create ipfs-search group.
  group: name=ipfs-search system=true state=present
- name: Create ipfs-search user.
  user: name=ipfs-search comment="ipfs-search api" group=ipfs-search system=true state=present home=/nonexistent shell=/usr/sbin/nologin
- name: Install ipfs-search service
  copy: src=ipfs-search.service dest=/etc/systemd/system/ipfs-search.service
  notify: restart ipfs-search
- name: Enable search service
  service: name=ipfs-search enabled=yes state=started
- name: Install nginx configuration
  copy: src=nginx.conf dest=/etc/nginx/nginx.conf
  notify: restart nginx
- name: Enable nginx service
  service: name=nginx enabled=yes state=started

Make sure destination directory exists.
Make sure destination directory exists.