homebridge/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 09 Feb 2020 12:05:37 -0600
changeset 2 2556522a2a45
parent 0 roles/homebridge/tasks/main.yaml@df042396074e
child 12 80a6e9af6aa9
permissions -rw-r--r--
Moved roles to top level

---

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