Use apt package for homebridge.
authorLuke Hoersten <luke@hoersten.org>
Wed, 19 Oct 2022 09:17:03 -0500
changeset 196 e07868e39791
parent 195 da34c8d7511d
child 197 1cc658995a70
Use apt package for homebridge.
homebridge/defaults/main.yaml
homebridge/meta/main.yaml
homebridge/tasks/main.yaml
homebridge/templates/homebridge.service.j2
--- a/homebridge/defaults/main.yaml	Sun Sep 11 14:08:17 2022 -0500
+++ b/homebridge/defaults/main.yaml	Wed Oct 19 09:17:03 2022 -0500
@@ -1,11 +1,4 @@
 ---
 
-homebridge_user: "homebridge"
-homebridge_groups: "video"
-homebridge_dir: "/home/{{homebridge_user}}"
-homebridge_restart_sec: "10"
-homebridge_apt_packages: []
-homebridge_npm_packages: []
-
 homebridge_pin: "031-45-154"
 homebridge_port: "51900"
--- a/homebridge/meta/main.yaml	Sun Sep 11 14:08:17 2022 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
----
-
-dependencies:
-  - nodejs
--- a/homebridge/tasks/main.yaml	Sun Sep 11 14:08:17 2022 -0500
+++ b/homebridge/tasks/main.yaml	Wed Oct 19 09:17:03 2022 -0500
@@ -1,54 +1,38 @@
 ---
 
-- name: create homebridge user
+- name: add homebridge apt key
   become: yes
-  user:
-    name: "{{homebridge_user}}"
-    comment: "Homebridge"
-    shell: "/bin/false"
-    home: "{{homebridge_dir}}"
-    groups: "{{homebridge_groups}}"
-    append: yes
-    move_home: yes
+  get_url:
+    url: "https://repo.homebridge.io/KEY.gpg"
+    dest: /etc/apt/trusted.gpg.d/homebridge.asc
+    mode: "0644"
+
+- name: add homebridge apt repo
+  become: yes
+  apt_repository: repo="deb https://repo.homebridge.io stable main"
+
+- name: apt install homebridge
+  become: yes
+  apt: name="homebridge"
   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
-  npm: name="homebridge" global="yes"
-  notify: restart homebridge service
-
-- name: install platform accessories
-  become: yes
-  npm: name="{{item}}" global="yes"
-  loop: "{{homebridge_npm_packages}}"
   notify: restart homebridge service
 
-- name: configure homebridge
-  become: yes
-  template:
-    src: "{{homebridge_config_template}}"
-    dest: "{{homebridge_dir}}/config.json"
-  notify: restart homebridge service
+# - name: install platform accessories
+#   become: yes
+#   npm: name="{{item}}" global="yes"
+#   loop: "{{homebridge_npm_packages}}"
+#   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: configure homebridge
+#   become: yes
+#   template:
+#     src: "{{homebridge_config_template}}"
+#     dest: "{{homebridge_dir}}/config.json"
+#   notify: restart homebridge service
 
 - name: ensure homebridge is started
   become: yes
--- a/homebridge/templates/homebridge.service.j2	Sun Sep 11 14:08:17 2022 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# {{ansible_managed}}
-
-[Unit]
-Description=Homebridge
-
-[Service]
-User={{homebridge_user}}
-Group={{homebridge_user}}
-Restart=always
-RestartSec={{homebridge_restart_sec}}
-
-WorkingDirectory={{homebridge_dir}}
-ExecStart=/usr/bin/node /opt/{{nodejs_dir}}/bin/homebridge -U {{homebridge_dir}}
-
-[Install]
-WantedBy=default.target