roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 30 Jul 2018 21:19:20 -0500
changeset 21 6ad3cf1d57c3
parent 18 3044f32e7f74
child 25 bc6c646f1814
permissions -rw-r--r--
Nodejs-legacy ubuntu package removed.

---

- 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"