Skip to content

Commit

Permalink
Merge branch 'main' into less-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 authored Oct 6, 2024
2 parents 4c6103f + bfc1cbc commit 2958405
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 76 deletions.
87 changes: 15 additions & 72 deletions jobs/http.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,29 @@ job "http" {
datacenters = ["dc1"]

group "http" {
dynamic "volume" {
for_each = local.main ? [{}] : []
labels = ["caddycerts"]
content {
type = "csi"
source = "caddycerts"
read_only = false
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
volume "caddycerts" {
type = "csi"
source = local.main ? "caddycerts" : "caddycerts_green"
read_only = false
access_mode = "single-node-writer"
attachment_mode = "file-system"
}

task "http" {
driver = "docker"

dynamic "volume_mount" {
for_each = local.main ? [{}] : []
content {
volume = "caddycerts"
destination = "/etc/caddycerts"
read_only = false
}
volume_mount {
volume = "caddycerts"
destination = "/etc/caddycerts"
read_only = false
}

dynamic "artifact" {
for_each = local.main ? [{}] : []

content {
source = "https://github.com/femiwiki/nomad/raw/main/caddy/Caddyfile"
destination = "local/Caddyfile"
mode = "file"

options { checksum = "md5:ee0300e384afa6aca74f09a44323ee6e" }
}
}
dynamic "template" {
for_each = var.test ? [{}] : []
artifact {
source = "https://github.com/femiwiki/nomad/raw/main/caddy/Caddyfile"
destination = "local/Caddyfile"
mode = "file"

content {
data = var.caddyfile_for_test
destination = "local/Caddyfile"
}
options { checksum = "md5:ee0300e384afa6aca74f09a44323ee6e" }
}

artifact {
Expand Down Expand Up @@ -184,41 +165,3 @@ job "http" {
auto_revert = true
}
}

variable "caddyfile_for_test" {
type = string
default = <<EOF
{
# Global options
auto_https off
order mwcache before rewrite
}
http://127.0.0.1:80 http://localhost:80 http://{$TEST_NOMAD_PUBLIC_IP}:80
root * /srv/femiwiki.com
php_fastcgi {$FASTCGI_ADDR}
file_server
encode gzip
mwcache {
ristretto {
num_counters 100000
max_cost 10000
buffer_items 64
}
purge_acl {
10.0.0.0/8
127.0.0.1
}
}
header {
# Enable XSS filtering for legacy browsers
X-XSS-Protection "1; mode=block"
# Block content sniffing, and enable Cross-Origin Read Blocking
X-Content-Type-Options "nosniff"
# Avoid clickjacking
X-Frame-Options "DENY"
}
rewrite /w/api.php /api.php
rewrite /w/* /index.php
EOF
}
8 changes: 4 additions & 4 deletions terraform/mediawiki.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ resource "nomad_job" "http" {
resource "nomad_job" "test_http" {
provider = nomad.test
# TODO Replace EBS CSI with S3 CSI or something
# depends_on = [
# data.nomad_plugin.ebs,
# nomad_csi_volume_registration.caddycerts,
# ]
depends_on = [
data.nomad_plugin.ebs_green,
nomad_csi_volume_registration.caddycerts_green,
]

jobspec = file("../jobs/http.nomad")
detach = false
Expand Down
38 changes: 38 additions & 0 deletions terraform/volumes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,35 @@ resource "nomad_job" "plugin-ebs-nodes" {
}
}

resource "nomad_job" "plugin_ebs_controller_green" {
provider = nomad.test
jobspec = file("../jobs/plugin-ebs-controller.nomad")

hcl2 {
allow_fs = true
}
}

resource "nomad_job" "plugin_ebs_nodes_green" {
provider = nomad.test
jobspec = file("../jobs/plugin-ebs-nodes.nomad")

hcl2 {
allow_fs = true
}
}

data "nomad_plugin" "ebs" {
plugin_id = "aws-ebs0"
wait_for_healthy = true
}

data "nomad_plugin" "ebs_green" {
provider = nomad.test
plugin_id = "aws-ebs0"
wait_for_healthy = true
}

import {
id = "mysql@default"
to = nomad_csi_volume_registration.mysql
Expand Down Expand Up @@ -52,3 +76,17 @@ resource "nomad_csi_volume_registration" "caddycerts" {
attachment_mode = "file-system"
}
}

resource "nomad_csi_volume_registration" "caddycerts_green" {
provider = nomad.test
depends_on = [data.nomad_plugin.ebs_green]
plugin_id = "aws-ebs0"
volume_id = "caddycerts_green"
name = "caddycerts_green"
external_id = data.terraform_remote_state.aws.outputs.ebs_caddycerts_green_id

capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
}

0 comments on commit 2958405

Please sign in to comment.