chore: update README
This commit is contained in:
36
README.md
36
README.md
@@ -27,7 +27,7 @@ This OpenTofu configuration manages various self-hosted services primarily as Do
|
|||||||
|
|
||||||
Before you begin, ensure you have the following installed and configured:
|
Before you begin, ensure you have the following installed and configured:
|
||||||
|
|
||||||
* **OpenTofu:** Version `1.6.0` or higher (see `versions.tf`). [Installation Guide](https://opentofu.org/docs/intro/install/)
|
* **OpenTofu:** Version `1.6.0` or higher. [Installation Guide](https://opentofu.org/docs/intro/install/)
|
||||||
* **Git:** For version control.
|
* **Git:** For version control.
|
||||||
* **Docker:** Installed and running on the target host(s) (initially "casa", later on VMs within Proxmox).
|
* **Docker:** Installed and running on the target host(s) (initially "casa", later on VMs within Proxmox).
|
||||||
* **(Optional) Cloudflare Account:** If using the Cloudflare provider for DNS management or Tunnels. You'll need your Zone ID and an API Token.
|
* **(Optional) Cloudflare Account:** If using the Cloudflare provider for DNS management or Tunnels. You'll need your Zone ID and an API Token.
|
||||||
@@ -50,12 +50,7 @@ homelab/
|
|||||||
├── versions.tf # Root module: OpenTofu & provider version constraints
|
├── versions.tf # Root module: OpenTofu & provider version constraints
|
||||||
├── terraform.tfvars.example # Example variables file
|
├── terraform.tfvars.example # Example variables file
|
||||||
│
|
│
|
||||||
├── environments/
|
├── modules/ # Local modules for different components
|
||||||
│ ├── core/ # Core infrastructure (monitoring, globals)
|
|
||||||
│ ├── network/ # Network infrastructure (Docker networks, Cloudflare)
|
|
||||||
│ └── services/ # Application services (Docker containers)
|
|
||||||
│
|
|
||||||
└── modules/ # Local modules for different components
|
|
||||||
├── 00-globals/ # Optional: Global data sources/locals
|
├── 00-globals/ # Optional: Global data sources/locals
|
||||||
├── 01-networking/
|
├── 01-networking/
|
||||||
│ ├── docker-network/
|
│ ├── docker-network/
|
||||||
@@ -69,6 +64,8 @@ homelab/
|
|||||||
├── jellyfin/
|
├── jellyfin/
|
||||||
├── affine/
|
├── affine/
|
||||||
└── ... # Other application modules
|
└── ... # Other application modules
|
||||||
|
│
|
||||||
|
└── services/ # Application services (Docker containers)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -82,19 +79,12 @@ homelab/
|
|||||||
2. **Provider Configuration:**
|
2. **Provider Configuration:**
|
||||||
Review `providers.tf` and ensure provider configurations are suitable. For providers requiring authentication (like Cloudflare or Proxmox later), API tokens and other sensitive data should be supplied via variables.
|
Review `providers.tf` and ensure provider configurations are suitable. For providers requiring authentication (like Cloudflare or Proxmox later), API tokens and other sensitive data should be supplied via variables.
|
||||||
|
|
||||||
3. **Create a `terraform.tfvars` file:**
|
3. **Create a `.env` file:**
|
||||||
Copy `terraform.tfvars.example` to `terraform.tfvars`:
|
Copy `.env.example` to `.env`:
|
||||||
```bash
|
```bash
|
||||||
cp terraform.tfvars.example terraform.tfvars
|
cp .env.example .env
|
||||||
```
|
```
|
||||||
**Edit `terraform.tfvars` to set your specific values.** This file is included in `.gitignore` by default if it's expected to contain secrets.
|
**Edit `.env` to set your specific values.** This file is included in `.gitignore` by default as it's expected to contain secrets.
|
||||||
Common variables to configure might include:
|
|
||||||
* `cloudflare_api_token`
|
|
||||||
* `cloudflare_zone_id`
|
|
||||||
* `docker_host_data_path_base` (e.g., `/srv/docker_data` on "casa")
|
|
||||||
* `domain_name` (e.g., `homelab.yourdomain.com`)
|
|
||||||
* Specific application settings (ports, image tags, paths for persistent data).
|
|
||||||
* (Future) Proxmox API details.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -110,18 +100,12 @@ Make sure you are in the root directory of the project (`homelab/`).
|
|||||||
This command shows you what OpenTofu will do to reach the desired state defined in your configuration files. Review the plan carefully.
|
This command shows you what OpenTofu will do to reach the desired state defined in your configuration files. Review the plan carefully.
|
||||||
```bash
|
```bash
|
||||||
tofu plan
|
tofu plan
|
||||||
# To use a specific .tfvars file:
|
|
||||||
# tofu plan -var-file="terraform.tfvars"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Apply Changes:**
|
3. **Apply Changes:**
|
||||||
This command applies the changes outlined in the plan. You will be prompted for confirmation.
|
This command applies the changes outlined in the plan. You will be prompted for confirmation.
|
||||||
```bash
|
```bash
|
||||||
tofu apply
|
tofu apply
|
||||||
# To use a specific .tfvars file:
|
|
||||||
# tofu apply -var-file="terraform.tfvars"
|
|
||||||
# To auto-approve (use with caution):
|
|
||||||
# tofu apply -auto-approve -var-file="terraform.tfvars"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **View Outputs:**
|
4. **View Outputs:**
|
||||||
@@ -134,8 +118,6 @@ Make sure you are in the root directory of the project (`homelab/`).
|
|||||||
This command will attempt to destroy all resources managed by this OpenTofu configuration.
|
This command will attempt to destroy all resources managed by this OpenTofu configuration.
|
||||||
```bash
|
```bash
|
||||||
tofu destroy
|
tofu destroy
|
||||||
# To use a specific .tfvars file:
|
|
||||||
# tofu destroy -var-file="terraform.tfvars"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Module Overview
|
## Module Overview
|
||||||
@@ -143,7 +125,7 @@ Make sure you are in the root directory of the project (`homelab/`).
|
|||||||
This project aims for a high degree of modularity:
|
This project aims for a high degree of modularity:
|
||||||
|
|
||||||
* **`modules/01-networking/`**: Contains modules for creating Docker networks, managing Cloudflare DNS records, and deploying `cloudflared` tunnels.
|
* **`modules/01-networking/`**: Contains modules for creating Docker networks, managing Cloudflare DNS records, and deploying `cloudflared` tunnels.
|
||||||
* **`modules/10-services-generic/docker-service/`**: A reusable module to deploy any generic Docker container with common configurations (ports, volumes, environment variables, etc.).
|
* **`modules/10-services-generic/`**: A reusable module to deploy any generic module with common configurations (Docker container setup, etc.).
|
||||||
* **`modules/20-services-apps/`**: Contains "wrapper" modules for specific applications (e.g., Jellyfin, Affine, Nginx Proxy Manager). These modules typically call the generic `docker-service` module with pre-filled defaults and simpler inputs specific to that application.
|
* **`modules/20-services-apps/`**: Contains "wrapper" modules for specific applications (e.g., Jellyfin, Affine, Nginx Proxy Manager). These modules typically call the generic `docker-service` module with pre-filled defaults and simpler inputs specific to that application.
|
||||||
* **`modules/02-compute/`**: (Planned for future Proxmox integration) Will contain modules for provisioning Virtual Machines or LXC containers on Proxmox VE, which can then serve as hosts for Docker or other services.
|
* **`modules/02-compute/`**: (Planned for future Proxmox integration) Will contain modules for provisioning Virtual Machines or LXC containers on Proxmox VE, which can then serve as hosts for Docker or other services.
|
||||||
|
|
||||||
|
|||||||
@@ -39,15 +39,19 @@ module "homelab_tunnel" {
|
|||||||
container_name = "cloudflared-homelab"
|
container_name = "cloudflared-homelab"
|
||||||
|
|
||||||
ingress_rules = [
|
ingress_rules = [
|
||||||
{
|
|
||||||
hostname = "budget.example.com"
|
|
||||||
service = "http://actualbudget:5006"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
hostname = "dashboard.example.com"
|
hostname = "dashboard.example.com"
|
||||||
service = "http://homepage:3000"
|
service = "http://homepage:3000"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
service_definitions = [
|
||||||
|
{
|
||||||
|
name = "homepage"
|
||||||
|
subdomains = ["dashboard"]
|
||||||
|
endpoint = "http://homepage:3000"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -58,11 +62,6 @@ For cleaner code organization, use the globals module:
|
|||||||
```hcl
|
```hcl
|
||||||
module "cloudflare_globals" {
|
module "cloudflare_globals" {
|
||||||
source = "./modules/00-globals/cloudflare"
|
source = "./modules/00-globals/cloudflare"
|
||||||
|
|
||||||
cloudflare_api_token = var.cloudflare_api_token
|
|
||||||
cloudflare_account_id = var.cloudflare_account_id
|
|
||||||
cloudflare_zone_id = var.cloudflare_zone_id
|
|
||||||
domain = "example.com"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module "homelab_tunnel" {
|
module "homelab_tunnel" {
|
||||||
@@ -70,9 +69,7 @@ module "homelab_tunnel" {
|
|||||||
|
|
||||||
cloudflare_account_id = module.cloudflare_globals.cloudflare_account_id
|
cloudflare_account_id = module.cloudflare_globals.cloudflare_account_id
|
||||||
cloudflare_zone_id = module.cloudflare_globals.cloudflare_zone_id
|
cloudflare_zone_id = module.cloudflare_globals.cloudflare_zone_id
|
||||||
|
|
||||||
tunnel_name = "homelab-tunnel"
|
tunnel_name = "homelab-tunnel"
|
||||||
|
|
||||||
ingress_rules = [
|
ingress_rules = [
|
||||||
{
|
{
|
||||||
hostname = "budget.${module.cloudflare_globals.domain}"
|
hostname = "budget.${module.cloudflare_globals.domain}"
|
||||||
@@ -85,14 +82,15 @@ module "homelab_tunnel" {
|
|||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
| Name | Description | Type | Default |
|
| Name | Description | Type | Default |
|
||||||
|------|-------------|------|---------|
|
| ----------------------- | --------------------------------------- | ------------ | -------------------------------------------- |
|
||||||
| `cloudflare_account_id` | Cloudflare account ID | string | (required) |
|
| `cloudflare_account_id` | Cloudflare account ID | string | (required) |
|
||||||
| `cloudflare_zone_id` | Cloudflare zone ID for your domain | string | (required) |
|
| `cloudflare_zone_id` | Cloudflare zone ID for your domain | string | (required) |
|
||||||
| `container_name` | Name of the Cloudflare tunnel container | string | "" (defaults to "cloudflared-{tunnel_name}") |
|
| `container_name` | Name of the Cloudflare tunnel container | string | "" (defaults to "cloudflared-{tunnel_name}") |
|
||||||
| `image_tag` | Docker image tag for cloudflared | string | "latest" |
|
| `image_tag` | Docker image tag for cloudflared | string | "latest" |
|
||||||
| `tunnel_name` | Name of the tunnel | string | (required) |
|
| `tunnel_name` | Name of the tunnel | string | (required) |
|
||||||
| `tunnel_secret` | Secret for the tunnel | string | "" (auto-generated if empty) |
|
| `tunnel_secret` | Secret for the tunnel | string | "" (auto-generated if empty) |
|
||||||
| `ingress_rules` | List of ingress rules | list(object) | (required) |
|
| `ingress_rules` | List of ingress rules | list(object) | (optional) |
|
||||||
|
| `service_definitions` | List of service definitions. Tunnel will create DNS records for each service with a subdomain. | list(object) | (optional) |
|
||||||
| `monitoring` | Enable monitoring via Watchtower | bool | true |
|
| `monitoring` | Enable monitoring via Watchtower | bool | true |
|
||||||
|
|
||||||
### Ingress Rules Object Structure
|
### Ingress Rules Object Structure
|
||||||
@@ -111,7 +109,7 @@ ingress_rules = [
|
|||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|------|-------------|
|
| ---------------- | --------------------------------------- |
|
||||||
| `tunnel_id` | ID of the created tunnel |
|
| `tunnel_id` | ID of the created tunnel |
|
||||||
| `tunnel_name` | Name of the tunnel |
|
| `tunnel_name` | Name of the tunnel |
|
||||||
| `tunnel_token` | Token for the tunnel (sensitive) |
|
| `tunnel_token` | Token for the tunnel (sensitive) |
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ terraform {
|
|||||||
docker = {
|
docker = {
|
||||||
source = "kreuzwerker/docker"
|
source = "kreuzwerker/docker"
|
||||||
}
|
}
|
||||||
|
dotenv = {
|
||||||
|
source = "germanbrew/dotenv"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -80,7 +83,7 @@ See the `variables.tf` file for a complete list of input variables and their des
|
|||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|------|-------------|
|
| --------------- | ------------------------------------------- |
|
||||||
| container_name | Name of the Docker container |
|
| container_name | Name of the Docker container |
|
||||||
| container_id | ID of the Docker container |
|
| container_id | ID of the Docker container |
|
||||||
| image_id | ID of the Docker image |
|
| image_id | ID of the Docker image |
|
||||||
|
|||||||
@@ -10,39 +10,6 @@ This module deploys a Watchtower container which automatically updates your runn
|
|||||||
- Notification support via shoutrrr
|
- Notification support via shoutrrr
|
||||||
- Container monitoring options
|
- Container monitoring options
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
To use this module in your root module, add the following code:
|
|
||||||
|
|
||||||
```hcl
|
|
||||||
module "watchtower" {
|
|
||||||
source = "./modules/20-services-apps/watchtower"
|
|
||||||
|
|
||||||
# Basic configuration
|
|
||||||
container_name = "watchtower"
|
|
||||||
image_tag = "latest"
|
|
||||||
timezone = "Australia/Sydney"
|
|
||||||
|
|
||||||
# Update settings
|
|
||||||
poll_interval = 86400 # Check once per day (in seconds)
|
|
||||||
cleanup = true # Remove old images after updating
|
|
||||||
rolling_restart = true # Update containers one by one
|
|
||||||
|
|
||||||
# Optional notification settings
|
|
||||||
enable_notifications = false
|
|
||||||
# notification_url = "discord://webhook-id/webhook-token"
|
|
||||||
|
|
||||||
# Additional settings as needed
|
|
||||||
# additional_env_vars = {
|
|
||||||
# WATCHTOWER_MONITOR_ONLY = "true"
|
|
||||||
# }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Required Resources
|
|
||||||
|
|
||||||
This module leverages the generic `docker-service` module, which handles the Docker container deployment.
|
|
||||||
|
|
||||||
## Input Variables
|
## Input Variables
|
||||||
|
|
||||||
| Name | Description | Type | Default |
|
| Name | Description | Type | Default |
|
||||||
|
|||||||
Reference in New Issue
Block a user