# HG changeset patch # User Luke Hoersten # Date 1517323293 21600 # Node ID 511e97bd55661cc41544046e06b15ba2dcd69018 # Parent e7007d23a14458724b1a5e90de9aa99299368929 Created custom automationhat role. diff -r e7007d23a144 -r 511e97bd5566 roles/automationhat/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/automationhat/defaults/main.yaml Tue Jan 30 08:41:33 2018 -0600 @@ -0,0 +1,12 @@ +--- + +automationhat_apt_packages: + - "python3" + - "raspi-gpio" + - "python3-rpi.gpio" + - "python3-smbus" + - "python3-sn3218" + +automationhat_modules: + - "i2c-bcm2708" + - "i2c-dev" diff -r e7007d23a144 -r 511e97bd5566 roles/automationhat/tasks/main.yaml --- a/roles/automationhat/tasks/main.yaml Mon Jan 29 23:19:00 2018 -0600 +++ b/roles/automationhat/tasks/main.yaml Tue Jan 30 08:41:33 2018 -0600 @@ -1,13 +1,37 @@ --- -- name: download automationhat install script - get_url: - url: "https://get.pimoroni.com/automationhat" - dest: "/tmp/automationhat.sh" - mode: 0750 +# Based on https://get.pimoroni.com/automationhat script + +- name: install automationhat apt packages + become: yes + apt: name="{{item}}" + with_items: "{{automationhat_apt_packages}}" + +- name: configure i2c boot config + become: yes + lineinfile: + path: "/boot/config.txt" + line: "dtparam=i2c_arm=on" + insertafter: "^#dtparam=i2c_arm=on" -- name: install automationhat - shell: "/tmp/automationhat.sh" - args: - chdir: "/tmp" - executable: "/bin/bash" +- name: configure i2c kernel modules + become: yes + lineinfile: + path: "/etc/modules" + line: "{{item}}" + with_items: "{{automationhat_modules}}" + +- name: modprobe kernel modules + become: yes + modprobe: name="{{item}}" + with_items: "{{automationhat_modules}}" + +- name: dtparam i2c + become: yes + command: "dtparam i2c_arm=on" + changed_when: false + +- name: enable i2c with raspi-config + become: yes + command: "raspi-config nonint do_i2c 0" + changed_when: false diff -r e7007d23a144 -r 511e97bd5566 roles/hap-nodejs/tasks/main.yaml --- a/roles/hap-nodejs/tasks/main.yaml Mon Jan 29 23:19:00 2018 -0600 +++ b/roles/hap-nodejs/tasks/main.yaml Tue Jan 30 08:41:33 2018 -0600 @@ -36,6 +36,7 @@ - name: clean up accessory examples become: yes file: path="{{hap_dest}}/accessories" state="absent" + changed_when: false - name: create accessories dir become: yes @@ -44,6 +45,17 @@ state: "directory" owner: "{{hap_user}}" group: "{{hap_user}}" + changed_when: false + +- name: install door accessory + become: yes + copy: + src: "../../../src/Door_accessory.js" + dest: "{{hap_dest}}/accessories/Door_accessory.js" + owner: "{{hap_user}}" + group: "{{hap_user}}" + notify: restart hap-nodejs service + changed_when: false - name: create python dir become: yes @@ -63,15 +75,6 @@ mode: "0755" notify: restart hap-nodejs service -- name: install door accessory - become: yes - copy: - src: "../../../src/Door_accessory.js" - dest: "{{hap_dest}}/accessories/Door_accessory.js" - owner: "{{hap_user}}" - group: "{{hap_user}}" - notify: restart hap-nodejs service - - name: build HAP-NodeJS become: yes become_user: "{{hap_user}}" diff -r e7007d23a144 -r 511e97bd5566 roles/rpi-base/defaults/main.yaml --- a/roles/rpi-base/defaults/main.yaml Mon Jan 29 23:19:00 2018 -0600 +++ b/roles/rpi-base/defaults/main.yaml Tue Jan 30 08:41:33 2018 -0600 @@ -1,7 +1,7 @@ --- -ubuntu_base_apt_packages: - - emacs-nox - - python3 - - htop - - jq +rpi_base_apt_packages: + - "emacs-nox" + - "python3" + - "htop" + - "jq" diff -r e7007d23a144 -r 511e97bd5566 roles/rpi-base/tasks/main.yml --- a/roles/rpi-base/tasks/main.yml Mon Jan 29 23:19:00 2018 -0600 +++ b/roles/rpi-base/tasks/main.yml Tue Jan 30 08:41:33 2018 -0600 @@ -23,7 +23,7 @@ - name: install extra apt packages become: yes apt: name="{{item}}" - with_items: "{{ubuntu_base_apt_packages}}" + with_items: "{{rpi_base_apt_packages}}" - name: authorize admin ssh keys become: yes diff -r e7007d23a144 -r 511e97bd5566 rpi-door.yaml --- a/rpi-door.yaml Mon Jan 29 23:19:00 2018 -0600 +++ b/rpi-door.yaml Tue Jan 30 08:41:33 2018 -0600 @@ -3,5 +3,5 @@ - hosts: raspberrypi roles: - rpi-base - # - automationhat + - automationhat - hap-nodejs