Move jobs to modules

This commit is contained in:
IamTheFij 2022-02-27 15:22:09 -08:00
parent 8bc0c53d83
commit 4df773f5d7
10 changed files with 86 additions and 45 deletions

16
nomad/mysql/mysql.tf Normal file
View File

@ -0,0 +1,16 @@
# Create mysql server
resource "nomad_job" "mysql-server" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/mysql.nomad")
}
resource "nomad_job" "adminer" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/adminer.nomad")
}

View File

@ -0,0 +1,15 @@
resource "nomad_job" "nextcloud-bootstrap" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/nextcloud-bootstrap.nomad")
}
resource "nomad_job" "nextcloud" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/nextcloud.nomad")
}

View File

@ -0,0 +1,27 @@
packer {
required_plugins {
docker = {
version = ">= 0.0.7"
source = "github.com/hashicorp/docker"
}
}
}
source "qemu" "focal-arm64" {
iso_url = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-arm64.img"
iso_checksum = "sha256:fee6bc4fcce3267b6a03a2449d5b471b7edf6ef990d6761607bd3960e2df4d9d"
output_directory = "focal_arm64"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
disk_size = "5000M"
format = "qcow2"
ssh_username = "root"
ssh_password = "s0m3password"
ssh_timeout = "20m"
boot_wait = "10s"
boot_command = []
}
build {
sources = ["source.qemu.example"]
}

View File

@ -11,7 +11,6 @@ provider "consul" {
# Get Nomad client from Consul
data "consul_service" "read-nomad-cluster" {
name = "nomad-client"
# name = "nomad-clients"
}
locals {
@ -19,44 +18,31 @@ locals {
nomad_node_address = "http://${local.nomad_node.node_address}:${local.nomad_node.port}"
}
# Configure the Consul provider
# Configure the Nomad provider
provider "nomad" {
# address = "http://services.thefij:4646"
address = local.nomad_node_address
region = "global"
}
# Create mysql server
resource "nomad_job" "mysql-server" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/mysql.nomad")
}
# Define services as modules
# Create mysql server
resource "nomad_job" "adminer" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/adminer.nomad")
module "mysql-server" {
source = "./mysql"
}
# Create Traefik
resource "nomad_job" "traefik" {
hcl2 {
enabled = true
vars = {
"consul_address" = "${var.consul_address}",
}
}
module "traefik" {
source = "./traefik"
jobspec = file("${path.module}/traefik.nomad")
consul_address = var.consul_address
}
module "nextcloud" {
source = "./nextcloud"
depends_on = [module.mysql-server]
}
# Create a sample host
resource "nomad_job" "whoami" {
hcl2 {
enabled = true
@ -67,21 +53,3 @@ resource "nomad_job" "whoami" {
jobspec = file("${path.module}/whoami.nomad")
}
# Create a sample host
resource "nomad_job" "nextcloud-bootstrap" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/nextcloud-bootstrap.nomad")
}
# Create a sample host
resource "nomad_job" "nextcloud" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/nextcloud.nomad")
}

15
nomad/traefik/traefik.tf Normal file
View File

@ -0,0 +1,15 @@
variable "consul_address" {
type = string
}
resource "nomad_job" "traefik" {
hcl2 {
enabled = true
vars = {
"consul_address" = "${var.consul_address}",
}
}
jobspec = file("${path.module}/traefik.nomad")
}