homebridge/tasks/main.yaml
changeset 2 2556522a2a45
parent 0 df042396074e
child 12 80a6e9af6aa9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homebridge/tasks/main.yaml	Sun Feb 09 12:05:37 2020 -0600
@@ -0,0 +1,56 @@
+---
+
+- name: create homebridge user
+  become: yes
+  user:
+    name: "{{homebridge_user}}"
+    comment: "Homebridge"
+    shell: "/bin/false"
+    home: "{{homebridge_dir}}"
+    groups: "video,spi,i2c,gpio"
+    move_home: yes
+  notify: restart homebridge service
+
+- name: create homebridge directory
+  become: yes
+  file:
+    path: "{{homebridge_dir}}"
+    state: "directory"
+    owner: "{{homebridge_user}}"
+    group: "{{homebridge_user}}"
+    mode: "0755"
+
+- name: install homebridge apt deps
+  become: yes
+  apt: name="{{homebridge_apt_packages}}"
+
+- name: install homebridge
+  become: yes
+  become_user: "{{homebridge_user}}"
+  npm: name="homebridge" global="yes"
+  notify: restart homebridge service
+
+- name: install platform accessories
+  become: yes
+  become_user: "{{homebridge_user}}"
+  npm: name="{{item}}" global="yes"
+  notify: restart homebridge service
+  with_items: "{{homebridge_npm_packages}}"
+
+- name: configure homebridge
+  become: yes
+  template:
+    src: "config.json.j2"
+    dest: "{{homebridge_dir}}/config.json"
+  notify: restart homebridge service
+
+- name: configure systemd service
+  become: yes
+  template:
+    src: "homebridge.service.j2"
+    dest: "/lib/systemd/system/homebridge.service"
+  notify: restart homebridge service
+
+- name: ensure homebridge is started
+  become: yes
+  systemd: name="homebridge.service" enabled="yes" state="started"