roles/hap-nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Tue, 30 Jan 2018 08:41:33 -0600
changeset 9 511e97bd5566
parent 8 e7007d23a144
child 15 6913019b9492
permissions -rw-r--r--
Created custom automationhat role.
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"
9
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    39
  changed_when: false
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
- name: create accessories dir
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    42
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    43
  file:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    44
    path: "{{hap_dest}}/accessories"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    45
    state: "directory"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    46
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    47
    group: "{{hap_user}}"
9
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    48
  changed_when: false
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    49
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    50
- name: install door accessory
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    51
  become: yes
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    52
  copy:
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    53
    src: "../../../src/Door_accessory.js"
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    54
    dest: "{{hap_dest}}/accessories/Door_accessory.js"
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    55
    owner: "{{hap_user}}"
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    56
    group: "{{hap_user}}"
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    57
  notify: restart hap-nodejs service
511e97bd5566 Created custom automationhat role.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    58
  changed_when: false
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    59
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    60
- name: create python dir
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    61
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    62
  file:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    63
    path: "{{hap_dest}}/python"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    64
    state: "directory"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    65
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    66
    group: "{{hap_user}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    67
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    68
- name: install doord.py
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    69
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    70
  copy:
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    71
    src: "../../../src/doord.py"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    72
    dest: "{{hap_dest}}/python/doord.py"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    73
    owner: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    74
    group: "{{hap_user}}"
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    75
    mode: "0755"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    76
  notify: restart hap-nodejs service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    77
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    78
- name: build HAP-NodeJS
8
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    79
  become: yes
e7007d23a144 Created hap-nodejs user.
Luke Hoersten <luke@hoersten.org>
parents: 7
diff changeset
    80
  become_user: "{{hap_user}}"
7
55b8db128364 Removed unneeded npm command module.
Luke Hoersten <luke@hoersten.org>
parents: 1
diff changeset
    81
  npm: path="{{hap_dest}}"
0
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    82
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    83
- name: configure systemd service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    84
  become: yes
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    85
  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
    86
  notify: restart hap-nodejs service
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    87
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    88
- name: ensure hap-nodejs is started
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    89
  become: yes
30d8bcb1ebb4 Initial public commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    90
  systemd: name="hap-nodejs.service" enabled="yes" state="started"