Automated Raspberry Pi boot drive provisioning with cloud-init.
Platform Support: Currently macOS only. Uses
diskutilandddfor direct drive flashing. Linux and Windows support planned.Why not rpi-imager? Hobby project. Imager 2.x has had issues that broke my workflow, so I automated the flow myself: YAML config, cloud-init provisioning, direct
ddflashing, with platform abstractions for future Linux/Windows support.
- macOS (Darwin)
- Python 3.12+
- uv (package manager)
- OpenSSL (for password hashing)
Package Manager: uv
Dependencies:
typer- CLI frameworkrich- Terminal formattinginquirerpy- Interactive promptsjinja2- Cloud-init template renderingpyyaml- Configuration loadingrequests- Image downloadsplatformdirs- Cross-platform cache directories
Architecture:
- Cloud-init based provisioning (Raspberry Pi OS Trixie+)
- Platform abstraction for future Linux/Windows support
- Direct drive flashing via
dd - Smart caching with hash verification
Install globally as a uv tool:
# From GitHub
uv tool install git+https://github.com/alexan059/pitool.git
# Or from a local clone
uv tool install --from . pitoolThis puts pitool on your PATH (run uv tool update-shell once if it isn't).
For development, clone and sync instead:
git clone https://github.com/alexan059/pitool.git
cd pitool
uv sync --devCreate pitool.yml:
raspberry_pis:
- name: pi
hostname: raspberrypi
wifi:
country_code: DE
ssid: "YourWiFiSSID"
password: "YourWiFiPassword"
user:
name: pi
password: "$6$salt$hashedpassword" # Use `pitool passwd` to generate
ssh_public_key: "ssh-ed25519 AAAA..."
timezone: Europe/Berlin
locale: en_US.UTF-8
update: true
upgrade: true
packages:
- ansible
reboot: trueSee pitool.example.yml for reference.
Generate password hash:
pitool passwdFlash boot drive:
pitool flash
# Clear download cache first
pitool flash --clear-cacheConnect to Pi:
pitool connectWaits for Pi to come online, removes old SSH host key, and connects via SSH.
Trust Pi's mkcert certificates:
pitool trustDownloads and trusts the Pi's mkcert root CA certificate in your macOS keychain. Required for accessing Pi services with local HTTPS certificates. Restart your browser after installation.
Tooling:
- uv (package manager)
- hatchling (build backend)
- Task (task runner, optional, convenience wrapper around
uvcommands)
Install Task (optional):
brew install go-taskAvailable tasks:
| Task | Equivalent | Description |
|---|---|---|
task sync |
uv sync --dev |
Install dependencies |
task install |
uv tool install --from . pitool |
Install pitool globally as a uv tool |
task run -- X |
uv run pitool X |
Run CLI command (e.g. flash) |
task check |
uv run ruff check . |
Lint code |
task format |
uv run ruff format . |
Format code |
See Taskfile.yml for the source of truth.
MIT License - See LICENSE