smartgic.prepi

Ansible Role: Prepi

This Ansible role helps you set up and optimize a Raspberry Pi 4B board.

prepi means "Prepare Raspberry Pi".

Important Note: You are responsible for the choices you make with this role. You choose the firmware[1] and EEPROM[2] you want. The same goes for overclocking[3]. Remember, overclocking needs good cooling!

This role can do the following tasks (based on your preferences):

  • Update Raspberry Pi OS to the latest version
  • Add a Debian backports repository (you can change this)
  • Update firmware to the next branch, providing kernel 5.10 and edge firmware (you can change this)
  • Update EEPROM to the beta version for new features (you can change this)
  • Speed up boot time by setting initial_turbo
  • Overclock the Raspberry Pi to 2GHz (you can change this)
  • Use a RAMDisk for /tmp
  • Optimize SD card read/write settings for the root partition
  • Manage I2C, SPI & UART interfaces (you can change this)
  • Set the CPU governor to performance mode to avoid interruptions (you can change this)
  • Install and set up PulseAudio (not system-wide) (you can change this)
  • Restart the Raspberry Pi after installing new firmware or EEPROM (you can change this)

This role was designed for a Raspberry Pi 4B using Raspberry Pi OS 64-bit.

Please check the documentation links below before making decisions.

Requirements

Role Variables

Here are the available variables with their default values (found in defaults/main.yml):

---
# System user to add to system groups like gpio, audio, etc...
prepi_pi_user: pi

# Raspberry Pi hostname
prepi_hostname: smartgic-pi4b8-13

# Set the CPU governor
#  - ondemand (saves power but lower performance)
#  - performance (uses more power but better performance)
prepi_cpu_governor: performance

# Use fast DNS nameservers (CloudFlare and Google)
# Note: DHCP may overwrite these changes
prepi_nameservers:
  - 1.1.1.1
  - 8.8.8.8

# Update the firmware
prepi_firmware_update: yes

# Firmware branch to use
#  - master (stable)
#  - next (edge firmware and kernel)
prepi_firmware_branch: next

# EEPROM release to use
#  - critical (rarely updated)
#  - stable (updated when new features are tested)
#  - beta (new features tested here first)
prepi_eeprom: beta

# Overclock CPU/GPU
prepi_overclock: yes

# Caution with this; it allows for a higher voltage
prepi_force_turbo: no

# CPU frequency to overclock
# If unstable, lower this value
prepi_cpu_freq: 2000

# GPU frequency to overclock
prepi_gpu_freq: 650

# Voltage to use; higher CPU clock means higher voltage
# 6 is the limit without setting prepi_force_turbo to yes
prepi_voltage: 6

# Enable I2C interface
prepi_i2c_enable: yes

# Enable SPI interface
prepi_spi_enable: yes

# Disable UART interface
prepi_uart_enable: no

# Install and configure PulseAudio
prepi_pulseaudio: yes

# Keep PulseAudio persistent when user disconnects, start at boot
prepi_pulseaudio_daemon: yes

# Enable Debian backports repository for the latest packages
prepi_backports_enable: yes

# Restart Raspberry Pi when installing new firmware or EEPROM
prepi_reboot: yes

# Disable onboarding screen configuration (for Raspberry Pi OS desktop)
prepi_disable_onboarding_screen: yes

Dependencies

Same requirements as above.

Example Playbook

An inventory file with a rpi group that has one host named rpi4b01 with the IP address 192.168.1.97.

[rpi]
rpi4b01 ansible_host=192.168.1.97 ansible_user=pi

Basic playbook for the rpi group using the pi user to connect via SSH (based on the inventory) with some custom variables.

---
- hosts: rpi
  gather_facts: no
  become: yes

  # Install Python using raw module to ensure requirements are met
  pre_tasks:
    - name: Install Python 3.x Ansible requirement
      raw: apt-get install -y python3
      changed_when: no

- hosts: rpi
  become: yes

  vars:
    prepi_hostname: smartgic-pi4b8-13
    prepi_cpu_freq: 2000
    prepi_cpu_governor: performance
    prepi_force_turbo: yes

  tasks:
    - import_role:
        name: smartgic.prepi
      tags:
        - prepi
        - raspberry

License

MIT

Author Information

I'm Gaëtan Trellu (goldyfruit), feel free to reach out! - 2021

Informazioni sul progetto

Apply some configurations to obtain the best performances from a Raspberry Pi 4 board and later.

Installa
ansible-galaxy install smartgic.prepi
Licenza
apache-2.0
Download
214
Proprietario
Build smart things with magic and love!