roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 16 Nov 2019 12:46:02 -0600
changeset 23 a006c668055c
parent 18 3044f32e7f74
child 25 bc6c646f1814
permissions -rw-r--r--
Removed base rpi role.

---

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