An open API service indexing awesome lists of open source software.

https://github.com/rayhanadev/iac

Configuration for my Docker Swarm homelab. Uses Ansible and Terraform to provision and orchestrate setup.
https://github.com/rayhanadev/iac

Last synced: 17 days ago
JSON representation

Configuration for my Docker Swarm homelab. Uses Ansible and Terraform to provision and orchestrate setup.

Awesome Lists containing this project

README

        

# ๐Ÿ—๏ธ Homelab Infrastructure-as-Code (IaC)

This repository manages a fully self-hosted, GitOps-style infrastructure stack using **Terraform** for provisioning and **Ansible** for configuration and orchestration.

## Overview

### Provisioning โ€” Terraform
- **GCP VM**: Acts as a public gateway running Caddy
- **Cloudflare**: DNS records and Zero Trust access
- **Tailscale**: Private networking and access control (ACLs)

### Configuration โ€” Ansible
- **Docker Swarm**: Set up across 4 Raspberry Pi nodes
- **MicroCeph**: Lightweight Ceph cluster for shared block/filesystem storage
- **Caddy**: HTTPS ingress on the GCP gateway
- **Tailscale**: Installed and joined to the tailnet on all nodes
- **Stacks**: Docker Swarm apps like Uptime Kuma, Grafana, Umami, etc.

## Directory Structure

```plaintext
.
โ”œโ”€โ”€ scripts # Utility scripts (provisioning, deploying, etc.)
โ”‚ โ”œโ”€โ”€ 01_provison.sh
โ”‚ โ”œโ”€โ”€ 02_configure.sh
โ”‚ โ”œโ”€โ”€ 03_deploy_stacks.sh
โ”‚ โ””โ”€โ”€ 04_deploy_caddy.sh
โ”œโ”€โ”€ ansible # Configuration management
โ”‚ โ”œโ”€โ”€ group_vars
โ”‚ โ”œโ”€โ”€ inventory
โ”‚ โ”œโ”€โ”€ playbooks
โ”‚ โ”œโ”€โ”€ roles
โ”‚ โ”‚ โ”œโ”€โ”€ caddy
โ”‚ โ”‚ โ”œโ”€โ”€ docker
โ”‚ โ”‚ โ”œโ”€โ”€ microceph
โ”‚ โ”‚ โ””โ”€โ”€ stacks
โ””โ”€โ”€ terraform # Infrastructure provisioning
โ”œโ”€โ”€ cloudflare
โ”œโ”€โ”€ gcp
โ”œโ”€โ”€ tailscale
โ”œโ”€โ”€ main.tf
โ””โ”€โ”€ variables.tf
````

## Prerequisites

- [Terraform v1.8+](https://developer.hashicorp.com/terraform/downloads)
- [Ansible v2.16+](https://docs.ansible.com/)

## Scripts

You can automate everything with:

```bash
scripts/01_provision.sh # Terraform: provision infra
scripts/02_configure.sh # Ansible: configure all nodes
scripts/03_deploy_stacks.sh # Ansible: deploy swarm stacks
scripts/04_deploy_caddy.sh # Ansible: deploy Caddy ingress
```

## ๐Ÿงน TODO

* [ ] Add log aggregation (e.g. Loki, Promtail)
* [ ] Add automatic backups