# My VPS Setup **This is still very much un-stable, and very much a work-in-progress.** So I decided to migrate *most* of my remote VPS to a self-hosted private server. There are 3 reasons for this: 1. Cost savings. VPS SSD storage can get quite [expensive](https://racknerd.com/kvm-vps) as your storage demands increase. Meanwhile I have a few SSDs lying my house around not being utilized. 2. Learning experience. There are many parts of the self-hosting stack that I'm not familiar with, and I am hoping to get more familiar with them as part of this exercise. 3. I want to be able to be to reproduce all of the tooling I use, as quickly as possible in a "doomsday" scenario, so I need it automated. My requirements are as follows: | Status | Feature | Choice | | ------------------ | ------------------------------------------- | --------------------------------------- | | | Email | n/a | | :heavy_check_mark: | Hosting/Sharing files, calender, tasks etc. | [Nextcloud](https://nextcloud.com/) | | :heavy_check_mark: | Hosting misc. static websites | [Nginx](https://www.nginx.com/) | | :heavy_check_mark: | Media (pictures, tv, movies) Server | [Jellyfin](https://jellyfin.org/) | | :heavy_check_mark: | Music Server | [Navidrome](https://www.navidrome.org/) | | :heavy_check_mark: | Network accessible storage for media | [Samba](https://www.samba.org/) | | :heavy_check_mark: | Password Hosting/Share | [Bitwarden](https://bitwarden.com/) | | :heavy_check_mark: | VPN | [Wireguard](https://www.wireguard.com/) | > Consider items marked as :heavy_check_mark: above to be implemented in this repo. > You may notice more [roles](./roles) than listed here. This is due to me trying other options for that feature, eg. "seafile" for file hosting. Feel free to use that instead. ## Architecture ![Architecture](./architecture.png) Notice that this setup requires a very small VPS since we are just running a wireguard client on it. All storage, and compute is being done by the Home Server. This means that my cost went from ~ $13/mo to ~ $1/mo for the VPS service, *while* increasing my SSD storage capacity from 50GB to 2TB (or whatever you have lying around)! And this does not incude the cost savings from self-hosting many of these services in the first place. ### Tradeoffs * I haven't factored in the cost of the hardware I'm putting to use or the cost of future replacement hardware, or the utility (power) cost of running these locally. * VPS service providers have certain uptime guarantees that factors into their end-user pricing, especially with extra storage. No such guarantees exist with this setup, but things can be done to get most of the way there (which has its own time/effort, and equipment costs). * Maintenance of these self-hosted services. But the way I see it, having it automated allows me to 1. minimize the time/effort spent on maintenance, and 2. to potentially turn this into a profitable venture for a growing privacy-minded audience - which at ~$13/mo would be a lot less profitable. There are many cheap VPS providers out there. I use Racknerd now. I have used Vultr previously. Both are good in-terms of technical support. ## Monitoring ![Dashboard](https://grafana.com/api/dashboards/15980/images/11892/image) You can get this dashboard [here](https://grafana.com/grafana/dashboards/15980). ## Install 1. Fork this repo. 2. Clone you fork with `git clone` 3. Change directory to this repo `cd vps`. 4. Setup repo by running all of the following: ``` python3 -m venv ~/venv/vps source $HOME/venv/vps/bin/activate pip install --upgrade pip pip install 'ansible<2.10' 'jmespath' ansible-galaxy install -r requirements.yml ansible-galaxy collection install -r requirements.yml cp -a vaultid.example vaultid cp -a hosts.example hosts cp -a group_vars/all/vault.example group_vars/all/vault ``` ## Develop 1. Modify the [playbooks](./playbooks/) per your needs. 2. Modify the vault per your needs: `ansible-vault edit group_vars/all/vault --vault-id vaultid`. 3. Modify the [hosts](./hosts/) file per your needs. 4. Modify the [vars](./group_vars/all/vars.yaml/) file per your needs. ## Execute ``` ansible-playbook -i hosts playbooks/deploy.yaml --vault-id vaultid ansible-playbook -i hosts playbooks/vps.yaml --vault-id vaultid ``` ## Future Plans 1. Simplify install. 2. Documentation for each role. 3. Backups. 4. Redundancy.