🍓 Raspberry Pi 5
Home Server
Powered by Ansible
Features • Requirements • Getting Started • Configuration • Port Forwarding • Security • Backups • License
This Ansible configuration automates the setup of a Home Server running Raspberry Pi OS. It deploys essential services using a modern, secure, and declarative best-practice architecture.
If you find this repository useful, please ⭐️ or fork it!
- fail2ban: IP Address Banning
- UFW: Firewall Configuration
- restic & rclone: Backup Solution with Remote Support
- AdGuard Home: Network-wide Ad Blocker
- AdventureLog: Travel Tracker
- Arcane: Docker Manager
- Authentik: Identity Provider & Single Sign On
- Backrest: Backup Manager (Web GUI for
restic
) - Beszel: Server Monitoring
- Caddy: Reverse Proxy & TLS
- Cloudflare DDNS: Dynamic DNS Updater
- Ente Auth: Two-factor Authenticator
- FreshRSS: Feed Aggregator
- Ghostfolio: Wealth Manager
- Gitea: Development Platform
- Glance: Dashboard
- Immich: Image & Video Manager
- n8n: Workflow Automation
- NextCloud: Cloud
- Vaultwarden: Password Manager
- wger Workout Manager: Fitness Tracker
- WireGuard Easy: VPN (with Web GUI)
- Raspberry Pi OS Lite (64-bit): Ensure your Raspberry Pi is running the latest version.
- Ansible: Install Ansible on your local machine.
- Cloudflare-managed domain: Required for dynamic DNS updates and subdomain routing.
- Ethernet connection: Use a wired connection for your Raspberry Pi for stable performance.
Important
When flashing your SD card, enable SSH and select the Use password authentication
option.
Note
If you choose a custom hostname or user, remember to update the inventory.ini
file accordingly.
-
Clone the repository:
git clone https://github.com/Nitestack/raspberry-pi-5.git ~/raspberry-pi-5
-
Install required Ansible Galaxy collections:
ansible-galaxy install -r requirements.yml
-
Configure Your Server: Follow the steps in the Configuration section below to set up your variables.
-
Run the playbook:
ansible-playbook deploy.yml
Important
This only works if you have set up password-less SSH authentication on your Raspberry Pi. Please look at the Security section for more details.
This project uses Ansible's best practices for variable management, separating public configuration from private secrets.
This file contains all non-sensitive configuration for your server, such as domain names, ports, and feature flags. Open group_vars/all/main.yml
and customize the settings to match your environment.
All sensitive data (API keys, passwords, secrets) is stored in an encrypted Ansible Vault file. For convenience, we will store the vault password in a local, git-ignored file.
To set up your secrets:
- Create your vault password file: Create a file named
.vault_pass
in the project root containing only your vault password.
echo "YOUR_SUPER_SECRET_VAULT_PASSWORD" > .vault_pass
chmod 600 .vault_pass # Set restrictive file permissions (read/write for your user only)
- Create and fill your vault: Copy the
vault.yml.example
file togroup_vars/all/vault.yml
, fill in your secrets, and then encrypt it. Ansible will automatically use your.vault_pass
file.
cp vault.yml.example group_vars/all/vault.yml # copy template
# -- NOW, EDIT group_vars/all/vault.yml AND ADD YOUR SECRETS --
ansible-vault encrypt group_vars/all/vault.yml # encrypt file
To ensure remote access and proper functionality, configure the following port forwarding rules on your router. The playbook will automatically configure the server's firewall (UFW) based on these variables.
# Caddy (handling all websites and APIs)
public:80/tcp -> local:80/tcp
public:443/tcp -> local:443/tcp
public:443/udp -> local:443/udp
# WireGuard
public:51820/udp -> local:51820/udp
# SSH (optional, if you want to access the Pi with a URL)
public:22/tcp -> local:22/tcp
# Gitea
public:222/tcp -> local:222/tcp
To enable secure, password-less SSH access for Ansible, copy your public SSH key to the Raspberry Pi:
ssh-copy-id your_user@your_pi_ip_or_hostname
Edit the /etc/ssh/sshd_config
file on the Raspberry Pi to disable password authentication and strengthen security. Update the following settings:
PasswordAuthentication no
UsePAM no
Apply the changes by reloading the SSH service:
sudo systemctl reload ssh
This setup includes an automated backup solution using Restic and Rclone.
- Remote Backups: Stored on OneDrive or Proton Drive
Backups are performed daily via a cron job and can also be triggered via the "Backup" GitHub Actions workflow.
- Install
rclone
on your local machine. - Configure
rclone
: Runrclone config
and follow the steps to set up a new remote. - Update
vault.yml
: Fill in your secrets (rclone_...
). You can get the config by runningrclone config show <your_remote_name>
.
This project is licensed under the Apache-2.0 license.