diff options
| author | Luke Hoersten <[email protected]> | 2018-01-30 08:41:33 -0600 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2018-01-30 08:41:33 -0600 |
| commit | 2b578ce9283a8d2b7d57a5e220d047f51ef917e1 (patch) | |
| tree | aa60d5970781d008e6da4f857cfaa4b3d399c93a /roles/automationhat | |
| parent | 128d4af632db9b2f8b769e84c495bd462df1ddd8 (diff) | |
Created custom automationhat role.
Diffstat (limited to 'roles/automationhat')
| -rw-r--r-- | roles/automationhat/defaults/main.yaml | 12 | ||||
| -rw-r--r-- | roles/automationhat/tasks/main.yaml | 46 |
2 files changed, 47 insertions, 11 deletions
diff --git a/roles/automationhat/defaults/main.yaml b/roles/automationhat/defaults/main.yaml new file mode 100644 index 0000000..1072549 --- /dev/null +++ b/roles/automationhat/defaults/main.yaml @@ -0,0 +1,12 @@ +--- + +automationhat_apt_packages: + - "python3" + - "raspi-gpio" + - "python3-rpi.gpio" + - "python3-smbus" + - "python3-sn3218" + +automationhat_modules: + - "i2c-bcm2708" + - "i2c-dev" diff --git a/roles/automationhat/tasks/main.yaml b/roles/automationhat/tasks/main.yaml index 405b450..7e9d6c6 100644 --- a/roles/automationhat/tasks/main.yaml +++ b/roles/automationhat/tasks/main.yaml @@ -1,13 +1,37 @@ --- -- name: download automationhat install script - get_url: - url: "https://get.pimoroni.com/automationhat" - dest: "/tmp/automationhat.sh" - mode: 0750 - -- name: install automationhat - shell: "/tmp/automationhat.sh" - args: - chdir: "/tmp" - executable: "/bin/bash" +# 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: 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 |
