roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 11 Jan 2020 18:09:32 -0600
changeset 25 bc6c646f1814
parent 18 3044f32e7f74
permissions -rw-r--r--
Updated to latest ansible syntax for lists.

---

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