Ansible playbooks to quickly setup a homelab. These playbooks are designed to be run on a fresh install of Ubuntu 20.04/22.04 and Debian 11. The playbook will update the system, install Docker, and then deploy the Docker containers.
I have included a bootstrap script that clones the repo, asks the user for the username and IP address of the server, and then runs the playbook. You can run the script like this:
curl https://raw.githubusercontent.com/rishavnandi/ansible_homelab/master/bootstrap.sh -o bootstrap.sh && bash bootstrap.sh
I have written a blog post about this repo, you can find it here: https://www.rishavnandi.com/posts/Ansible_homelab
- Clone the repo to your local machine
git clone https://github.com/rishavnandi/ansible_homelab.git
-
Update the inventory file with the IP address of your server and the user you want to use to connect to the server and add the path to your ssh key, incase you are not using ssh keys (you should always use ssh keys for security) then you can replace the
ansible_ssh_private_key_file
withansible_ssh_pass
and add the password for the user. -
Also update the
group_vars/vars.yml
file with the correct variables for your setup, for the pgid and puid, you can find the correct values by running theid
command on your server and using the values for theuid
andgid
fields. -
Run the playbook
ansible-playbook main.yml
You'll notice that for most apps the ports are not exposed, as I prefer exposing only the neccessary ports and for the rest I add them to a custom Docker network and then use nginx proxy manager to access the apps, a benefit of putting all the containers on a custom Docker network is that you can reference them in nginx proxy manager using their container name instead of the IP address, which makes it easier to manage.
If you don't want to run some of the apps, you can easily remove them from the main.yml
file since all the containers are stored as tasks in the tasks folder and are included in the main.yml
file.
If you want to learn more about any of the apps, you can check out the awesome selfhosted repo.
I have included a Terraform script that I use to quickly spin up an AWS instance to run the playbook on. You can use this script to spin up an instance, or you can use it as a reference to create your own Terraform script. You can find more info about using Terraform with AWS here: https://learn.hashicorp.com/tutorials/terraform/aws-build
- Add support for Ubuntu 22.04
- Add support for Debian 11
- Add support for RedHat based distros (Fedora, CentOS)
- Find a permanent fix for the Docker install issue on Ubuntu 22.04
- Use Ansible to automate some more stuff so there is no need to enter the IP address and PUID/PGID manually
- Add SSH hardening
- Add more apps
- Jeff Geerling for all the awesome Ansible content
- linuxserver.io for the Docker containers
- Ansible docs for the Ansible documentation
- Wolfgang's infra repo for the Docker install fix for Ubuntu 22.04