roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 29 Jan 2018 23:19:00 -0600
changeset 8 e7007d23a144
parent 7 55b8db128364
child 9 511e97bd5566
permissions -rw-r--r--
Created hap-nodejs user.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     3
- name: create hap-nodejs user
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     4
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     5
  user:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     6
    name: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     7
    comment: "HAP-NodeJS"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     8
    groups: "spi,i2c,gpio"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
     9
    shell: "/bin/false"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    10
    home: "{{hap_dir}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    11
    move_home: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    12
  notify: restart hap-nodejs service
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    13
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
- name: install homekit apt packages
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
  become: yes
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
  apt: name="{{item}}"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    17
  with_items: "{{hap_ubuntu_apt_packages}}"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
- name: download and unarchive HAP-NodeJS
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    20
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    21
  become_user: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    22
  unarchive:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    23
    src: "{{hap_src}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    24
    dest: "{{hap_dir}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    25
    remote_src: "yes"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    26
    creates: "{{hap_dest}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    27
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    28
    group: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
- name: install npm packages
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    31
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    32
  become_user: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
  npm: name="{{item}}" path="{{hap_dest}}"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
  with_items: "{{hap_npm_packages}}"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
- name: clean up accessory examples
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    37
  become: yes
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
  file: path="{{hap_dest}}/accessories" state="absent"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
- name: create accessories dir
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    41
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    42
  file:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    43
    path: "{{hap_dest}}/accessories"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    44
    state: "directory"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    45
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    46
    group: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    47
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    48
- name: create python dir
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    49
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    50
  file:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    51
    path: "{{hap_dest}}/python"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    52
    state: "directory"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    53
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    54
    group: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    55
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    56
- name: install doord.py
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    57
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    58
  copy:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    59
    src: "../../../src/doord.py"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    60
    dest: "{{hap_dest}}/python/doord.py"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    61
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    62
    group: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    63
    mode: "0755"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    64
  notify: restart hap-nodejs service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    65
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    66
- name: install door accessory
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    67
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    68
  copy:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    69
    src: "../../../src/Door_accessory.js"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    70
    dest: "{{hap_dest}}/accessories/Door_accessory.js"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    71
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    72
    group: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    73
  notify: restart hap-nodejs service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    74
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    75
- name: build HAP-NodeJS
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    76
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    77
  become_user: "{{hap_user}}"
7
55b8db128364 Removed unneeded npm command module.
Luke Hoersten <luke@hoersten.org>
parents: 1
diff changeset
    78
  npm: path="{{hap_dest}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    79
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    80
- name: configure systemd service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    81
  become: yes
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    82
  template: src="hap-nodejs.service.j2" dest="/lib/systemd/system/hap-nodejs.service"
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    83
  notify: restart hap-nodejs service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    84
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    85
- name: ensure hap-nodejs is started
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    86
  become: yes
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    87
  systemd: name="hap-nodejs.service" enabled="yes" state="started"