Initial nextcloud
This commit is contained in:
parent
a0c059733c
commit
4a1078d55d
7 changed files with 134 additions and 0 deletions
products/nextcloud
57
products/nextcloud/inputs.tf
Normal file
57
products/nextcloud/inputs.tf
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
variable "enable" {
|
||||||
|
type = bool
|
||||||
|
description = "Whether to enable the service."
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
# Pass-thru variables
|
||||||
|
variable "stack_name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
variable "service_name" {
|
||||||
|
default = "postgres"
|
||||||
|
type = string
|
||||||
|
description = "The name of the service to create."
|
||||||
|
}
|
||||||
|
variable "networks" {
|
||||||
|
type = list(object({
|
||||||
|
name = string
|
||||||
|
id = string
|
||||||
|
}))
|
||||||
|
default = []
|
||||||
|
description = "A list of network names to attach the service to."
|
||||||
|
}
|
||||||
|
variable "ports" {
|
||||||
|
type = list(object({
|
||||||
|
host = optional(number, null)
|
||||||
|
container = number
|
||||||
|
protocol = optional(string, "tcp")
|
||||||
|
publish_mode = optional(string, "ingress")
|
||||||
|
}))
|
||||||
|
default = []
|
||||||
|
description = "A map of port mappings to expose on the host. The key is the host port, and the value is the container port."
|
||||||
|
}
|
||||||
|
variable "postgres_ports" {
|
||||||
|
type = list(object({
|
||||||
|
host = optional(number, null)
|
||||||
|
container = number
|
||||||
|
protocol = optional(string, "tcp")
|
||||||
|
publish_mode = optional(string, "ingress")
|
||||||
|
}))
|
||||||
|
default = []
|
||||||
|
description = "A map of port mappings to expose on the host. The key is the host port, and the value is the container port."
|
||||||
|
}
|
||||||
|
variable "mounts" {
|
||||||
|
type = map(string)
|
||||||
|
default = {}
|
||||||
|
description = "A map of host paths to container paths to mount. The key is the host path, and the value is the container path."
|
||||||
|
}
|
||||||
|
variable "placement_constraints" {
|
||||||
|
default = []
|
||||||
|
type = list(string)
|
||||||
|
description = "Docker Swarm placement constraints"
|
||||||
|
}
|
||||||
|
variable "data_persist_path" {
|
||||||
|
default = null
|
||||||
|
description = "Path on host machine to persist data. Leaving this blank will provision an ephemeral volume."
|
||||||
|
type = string
|
||||||
|
}
|
5
products/nextcloud/network.tf
Normal file
5
products/nextcloud/network.tf
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module "network" {
|
||||||
|
source = "../../docker/network"
|
||||||
|
stack_name = var.stack_name
|
||||||
|
network_name = "nextcloud"
|
||||||
|
}
|
35
products/nextcloud/nextcloud.tf
Normal file
35
products/nextcloud/nextcloud.tf
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
module "nextcloud" {
|
||||||
|
source = "../../docker/service"
|
||||||
|
enable = var.enable
|
||||||
|
stack_name = var.stack_name
|
||||||
|
service_name = "nextcloud"
|
||||||
|
image = "nextcloud:stable"
|
||||||
|
networks = [module.network]
|
||||||
|
ports = var.ports
|
||||||
|
mounts = var.mounts
|
||||||
|
placement_constraints = var.placement_constraints
|
||||||
|
environment_variables = {
|
||||||
|
POSTGRES_HOST = module.postgres.service_name
|
||||||
|
POSTGRES_USER = module.postgres.username
|
||||||
|
POSTGRES_PASSWORD = module.postgres.password
|
||||||
|
POSTGRES_DB = module.postgres.database
|
||||||
|
REDIS_HOST = module.redis.service_name
|
||||||
|
REDIS_HOST_PASSWORD = module.redis.auth
|
||||||
|
#NEXTCLOUD_ADMIN_USER = random_pet.admin_user.id
|
||||||
|
#NEXTCLOUD_ADMIN_PASSWORD = nonsensitive(random_password.admin_password.result)
|
||||||
|
NEXTCLOUD_DATA_DIR = "/mnt/data"
|
||||||
|
#NEXTCLOUD_UPDATE = false
|
||||||
|
#NEXTCLOUD_INIT_HTACCESS = true
|
||||||
|
NC_setup_create_db_user = false
|
||||||
|
}
|
||||||
|
converge_enable = false # @todo: Implement a healthcheck and change this.
|
||||||
|
start_first = false
|
||||||
|
}
|
||||||
|
resource "random_pet" "admin_user" {
|
||||||
|
length = 2
|
||||||
|
separator = ""
|
||||||
|
}
|
||||||
|
resource "random_password" "admin_password" {
|
||||||
|
length = 32
|
||||||
|
special = false
|
||||||
|
}
|
6
products/nextcloud/output.tf
Normal file
6
products/nextcloud/output.tf
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
output "admin" {
|
||||||
|
value = {
|
||||||
|
username = random_pet.admin_user.id
|
||||||
|
password = nonsensitive(random_password.admin_password.result)
|
||||||
|
}
|
||||||
|
}
|
11
products/nextcloud/postgres.tf
Normal file
11
products/nextcloud/postgres.tf
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
module "postgres" {
|
||||||
|
source = "../postgres"
|
||||||
|
enable = var.enable
|
||||||
|
stack_name = var.stack_name
|
||||||
|
database = "nextcloud"
|
||||||
|
username = "nextcloud"
|
||||||
|
networks = [module.network]
|
||||||
|
data_persist_path = "/goliath/nextcloud/postgres"
|
||||||
|
placement_constraints = var.placement_constraints
|
||||||
|
ports = var.postgres_ports
|
||||||
|
}
|
7
products/nextcloud/redis.tf
Normal file
7
products/nextcloud/redis.tf
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module "redis" {
|
||||||
|
source = "../redis"
|
||||||
|
enable = var.enable
|
||||||
|
stack_name = var.stack_name
|
||||||
|
networks = [module.network]
|
||||||
|
placement_constraints = var.placement_constraints
|
||||||
|
}
|
13
products/nextcloud/terraform.tf
Normal file
13
products/nextcloud/terraform.tf
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
terraform {
|
||||||
|
required_version = "~> 1.6"
|
||||||
|
required_providers {
|
||||||
|
docker = {
|
||||||
|
source = "kreuzwerker/docker"
|
||||||
|
version = "~> 3.0"
|
||||||
|
}
|
||||||
|
random = {
|
||||||
|
source = "hashicorp/random"
|
||||||
|
version = "~> 3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue