roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Thu, 01 Mar 2018 17:14:13 -0600
changeset 18 3044f32e7f74
parent 17 69a7d69de562
child 25 bc6c646f1814
permissions -rw-r--r--
Broke out separate hap-door role from hap-nodejs.

---

- name: create hap-nodejs user
  become: yes
  user:
    name: "{{hap_user}}"
    comment: "HAP-NodeJS"
    groups: "spi,i2c,gpio"
    shell: "/bin/false"
    home: "{{hap_dir}}"
    move_home: yes
  notify: restart hap-nodejs service

- name: install homekit apt packages
  become: yes
  apt: name="{{item}}"
  with_items: "{{hap_apt_packages}}"
  notify: restart hap-nodejs service

- name: download and unarchive HAP-NodeJS
  become: yes
  become_user: "{{hap_user}}"
  unarchive:
    src: "{{hap_src}}"
    dest: "{{hap_dir}}"
    remote_src: "yes"
    creates: "{{hap_dest}}"
    owner: "{{hap_user}}"
    group: "{{hap_user}}"
  notify: restart hap-nodejs service

- name: remove example accessories
  become: yes
  file: path="{{hap_dest}}/accessories/{{item}}" state="absent"
  with_items: "{{hap_example_accessories}}"

- name: build HAP-NodeJS
  become: yes
  become_user: "{{hap_user}}"
  npm: path="{{hap_dest}}"

- name: configure systemd service
  become: yes
  template: src="hap-nodejs.service.j2" dest="/lib/systemd/system/hap-nodejs.service"
  notify: restart hap-nodejs service

- name: ensure hap-nodejs is started
  become: yes
  systemd: name="hap-nodejs.service" enabled="yes" state="started"