Move jobs to modules
This commit is contained in:
parent
50ecca2b06
commit
6d378b2d1f
16
mysql/mysql.tf
Normal file
16
mysql/mysql.tf
Normal 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")
|
||||
}
|
15
nextcloud/nextcloud.tf
Normal file
15
nextcloud/nextcloud.tf
Normal 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")
|
||||
}
|
27
packer/ubuntu-cloud-init.hcl
Normal file
27
packer/ubuntu-cloud-init.hcl
Normal 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"]
|
||||
}
|
58
services.tf
58
services.tf
@ -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
traefik/traefik.tf
Normal file
15
traefik/traefik.tf
Normal 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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user