Create dummy module

This commit is contained in:
Ben Martin 2024-06-03 21:34:19 +01:00
commit 1c94485587
No known key found for this signature in database
GPG key ID: 11936493893207E4
7 changed files with 156 additions and 0 deletions

15
.gitignore vendored Normal file
View file

@ -0,0 +1,15 @@
/.idea/
**/.terraform/*
*.tfstate
*.tfstate.*
crash.log
crash.*.log
*.tfvars
*.tfvars.json
override.tf
override.tf.json
*_override.tf
*_override.tf.json
.terraform.tfstate.lock.info
.terraformrc
terraform.rc

44
modules/dummy/jobspec.hcl Normal file
View file

@ -0,0 +1,44 @@
job "hello-world" {
datacenters = ["*"]
meta {
foo = "bar"
}
group "servers" {
count = 1
network {
port "www" {
to = 8001
}
}
service {
provider = "nomad"
port = "www"
}
task "web" {
driver = "docker"
config {
image = "busybox:1"
command = "httpd"
args = ["-v", "-f", "-p", "${NOMAD_PORT_www}", "-h", "/local"]
ports = ["www"]
}
template {
data = <<-EOF
<h1>Hello, Nomad!</h1>
<ul>
<li>Task: {{env "NOMAD_TASK_NAME"}}</li>
<li>Group: {{env "NOMAD_GROUP_NAME"}}</li>
<li>Job: {{env "NOMAD_JOB_NAME"}}</li>
<li>Metadata value for foo: {{env "NOMAD_META_foo"}}</li>
<li>Currently running on port: {{env "NOMAD_PORT_www"}}</li>
</ul>
EOF
destination = "local/index.html"
}
resources {
cpu = 50
memory = 64
}
}
}
}

View file

@ -0,0 +1,56 @@
{
"ID": "hello-world",
"Name": "hello-world",
"TaskGroups": [
{
"Name": "servers",
"Tasks": [
{
"Name": "web",
"Driver": "docker",
"Config": {
"image": "busybox:1",
"command": "httpd",
"args": [
"-v",
"-f",
"-p",
"${NOMAD_PORT_www}",
"-h",
"/local"
],
"ports": [
"www"
]
},
"Templates": [
{
"DestPath": "local/index.html",
"EmbeddedTmpl": "<h1>Hello, Ben!</h1>\n"
}
],
"Resources": {
"CPU": 50,
"MemoryMB": 64
}
}
],
"Networks": [
{
"DynamicPorts": [
{
"Label": "www",
"To": 8001
}
]
}
],
"Services": [
{
"PortLabel": "www",
"Provider": "nomad"
}
]
}
]
}

4
modules/dummy/main.tf Normal file
View file

@ -0,0 +1,4 @@
resource "nomad_job" "dummy" {
jobspec = file("${path.module}/jobspec.json")
json = true
}

22
prod/.terraform.lock.hcl generated Normal file
View file

@ -0,0 +1,22 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/nomad" {
version = "2.2.0"
constraints = "2.2.0"
hashes = [
"h1:BAjqzVkuXxHtRKG+l9unaZJPk2kWZpSTCEcQPRcl2so=",
"zh:052f909d25121e93dc799290216292fca67943ccde12ba515068b838a6ff8c66",
"zh:20e29aeb9989f7a1e04bb4093817c7acc4e1e737bb21a3066f3ea46f2001feff",
"zh:2326d101ef427599b72cce30c0e0c1d18ae783f1a897c20f2319fbf54bab0a61",
"zh:3420cbe4fd19cdc96d715d0ae8e79c272608023a76033bbf582c30637f6d570f",
"zh:41ec570f87f578f1c57655e2e4fbdb9932d94cf92dc9cd11828cccedf36dd4a4",
"zh:5f90dcc58e3356ffead82ea211ecb4a2d7094d3c2fbd14ff85527c3652a595a2",
"zh:64aaa48609d2db868fcfd347490df0e12c6c3fcb8e4f12908c5d52b1a0adf73f",
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
"zh:86b4923e10e6ba407d1d2aab83740b702058e8b01460af4f5f0e4008f40e492c",
"zh:ae89dcba33097af33a306344d20e4e25181f15dcc1a860b42db5b7199a97c6a6",
"zh:ce56d68cdfba60891765e94f9c0bf69eddb985d44d97db9f91874bea027f08e2",
"zh:e993bcde5dbddaedf3331e3014ffab904f98ab0f5e8b5d6082b7ca5083e0a2f1",
]
}

3
prod/main.tf Normal file
View file

@ -0,0 +1,3 @@
module "dummy" {
source = "../modules/dummy"
}

12
prod/provider.tf Normal file
View file

@ -0,0 +1,12 @@
terraform {
required_providers {
nomad = {
source = "hashicorp/nomad"
version = "2.2.0"
}
}
}
provider "nomad" {
address = "http://hestia.lan:4646"
}