Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Created December 27, 2022 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save geerlingguy/816a5b2c566dc66acc65198ff73a9a69 to your computer and use it in GitHub Desktop.
Save geerlingguy/816a5b2c566dc66acc65198ff73a9a69 to your computer and use it in GitHub Desktop.
Pi Rack Pro setup script for the Pis in the Pi Rack Pro
# Run this playbook with ansible-playbook -i inventory setup.yml
# In the inventory file, create a group named [rpi] with all the Pis in it
---
- hosts: rpi
become: true
vars:
lcd_library_repo: 'https://github.com/geerlingguy/SKU_RM0004.git'
lcd_library_version: 'jeff-custom'
handlers:
- name: reboot pi
ansible.builtin.reboot:
tasks:
- name: Configure boot config file.
ansible.builtin.lineinfile:
line: "{{ item.line }}"
dest: "/boot/config.txt"
regexp: "{{ item.regexp }}"
with_items:
- line: 'dtoverlay=gpio-shutdown,gpio_pin=4,active_low=1,gpio_pull=up'
regexp: "^dtoverlay=gpio-shutdown"
- line: 'dtparam=i2c_arm=on,i2c_arm_baudrate=400000'
regexp: "^#?dtparam=i2c_arm=on"
notify: reboot pi
- name: Ensure PoE fans on Pi are set correctly.
ansible.builtin.blockinfile:
path: /boot/config.txt
block: |
# PoE Hat Fan Speeds
dtparam=poe_fan_temp0=55000
dtparam=poe_fan_temp1=60000
dtparam=poe_fan_temp2=70000
dtparam=poe_fan_temp3=80000
notify: reboot pi
- name: Clone LCD library.
ansible.builtin.git:
repo: '{{ lcd_library_repo }}'
dest: /opt/SKU_RM0004
version: '{{ lcd_library_version }}'
register: lcd_git_checkout
- name: Clean LCD library if repo changed.
community.general.make:
target: clean
chdir: /opt/SKU_RM0004
when: lcd_git_checkout is changed
- name: Compile LCD library.
community.general.make:
chdir: /opt/SKU_RM0004
- name: Configure systemd unit for LCD library.
ansible.builtin.copy:
dest: /usr/lib/systemd/system/lcd_display.service
mode: 0644
content: |
[Unit]
Description=LCD Library
[Service]
WorkingDirectory=/opt/SKU_RM0004
ExecStart=/opt/SKU_RM0004/display
Restart=always
[Install]
WantedBy=multi-user.target
register: systemd_unit
- name: Force a systemd daemon reload if needed.
ansible.builtin.systemd:
daemon_reload: true
when: systemd_unit is changed
- name: Ensure LCD library is started and enabled on boot.
ansible.builtin.systemd:
name: lcd_display
state: started
enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment