headless_raspi_config

Headless raspi-config

Performs some raspi-config nonint operations using Ansible intended for minimal headless setup. It can also be used as a basis for multimedia setup.

Requirements

Ansible Core version 2.13.9 or greater is mandatory according to Ansible.

Only 64-bit Debian version 12 (Bookworm) Raspberry Pi OS has been tested and ran successfully. Tested on Raspberry Pi 3, 4, and 5. Raspberry Pi 1 and 2 aren't tested as they apparently lack 64-bit support. Additionally,the performance may be unbearable on the older Pi boards for some. At the time of this writing (Q2 2024), even Raspberry Pi highly recommends using Pi 4 or newer in their Obsolescence Statement below:

Raspberry Pi 2 Model B will remain in production until at least January 2026. This product is not recommended for new designs; for new embedded applications, we recommend Raspberry Pi 4 or newer.

However, you can attempt to use this with the 32-bit version at your discretion.

It's assumed Raspberry Pi has been configured with SSH server enabled, and an existing user account with passwordless sudo ability has been set up on it. Additionally, key-based authentication would also need to be configured for the user.

Role Variables

You can modify any of the following variables as you wish in the role's defaults/main.yml:

  • headless_raspi_config_pi_hostname: Customize your Pi's hostname.
  • headless_raspi_config_pi_timezone: Customize your Pi's timezone.
    • Please note you must use the appropriate timezone format. See the official Debian documentation for more information on the timezone configuration.
  • headless_raspi_config_pi_locale_setting: Customize your Pi's locale's setting.
  • headless_raspi_config_pi_keyboard_layout: Customize your keyboard layout.
  • headless_raspi_config_pi_bootup_behavior: Customize how you want your Pi to log in after bootup.
    • This is the setting that you'd see when you are interactively setting up the Boot Options.
  • headless_raspi_config_pi_disable_onboard_audio: Set your preference whether you would like the audio output to go through the onboard 3.5mm headphone jack (not available on Pi 5 board) or HDMI.

Example Playbook

First, you need to install the role, which you can via ansible-galaxy command.

ansible-galaxy role install bashtheshell.headless_raspi_config

You can verify if it's installed using ansible-galaxy list command.

Assuming you don't have an inventory file for your playbook but only a single Raspberry Pi with the IP address 192.168.1.10, you can run the following playbook with the command:

ansible-playbook --inventory "192.168.1.10," site.yml

---
### site.yml
- name: Main playbook is running...
  hosts: all
  remote_user: pi_user
  tasks:
    - name: Run the "bashtheshell/headless_raspi_config" role
      ansible.builtin.import_role:
        name: bashtheshell.headless_raspi_config
      vars:
        headless_raspi_config_pi_hostname: "hotblueberrypie"
        headless_raspi_config_pi_bootup_behavior: "B2"
        headless_raspi_config_pi_disable_onboard_audio: true

You can also install the role from git this way:

ansible-galaxy role install [email protected]:bashtheshell/headless-raspi-config-ansible.git

Although, when you use git, the name value for ansible.builtin.import_role differs as it should be headless-raspi-config-ansible.

If you prefer to test only the role quickly without the hassle of creating a playbook after git cloning the repo, you can just use the ad-hoc ansible command instead which is the equivalent of the above playbook:

ansible all -i "192.168.1.10," -m import_role -a role='./headless-raspi-config-ansible' -u pi_user -e headless_raspi_config_pi_hostname="hotblueberrypie" -e headless_raspi_config_pi_bootup_behavior="B2" -e headless_raspi_config_pi_disable_onboard_audio=true

Run Time

Below are the average playbook run times using the sample playbook above (YMMV):

  • Raspberry Pi 3 (Model B V1.2): 7:24.15 total
  • Raspberry Pi 4 (Model B V1.1): 4:31.67 total
  • Raspberry Pi 4 (Model B V1.5): 4:22.27 total
  • Raspberry Pi 5 (Model B V1.0): 2:56.79 total

NOTE: The Pi specifications were determined from the pinout command:

License

MIT LICENSE

Questions or Issues

Please submit Issues or Pull requests and I'll get to them the best I can.

About

Performs some `raspi-config nonint` operations using Ansible intended for minimal headless setup.

Install
ansible-galaxy install bashtheshell/headless-raspi-config-ansible
GitHub repository
License
mit
Downloads
8
Owner
Linux system administration enthusiast. Loves to tinker with programming and networking.