Skip to main content

Hashicorp Nomad to set up an OSTicket Helpdesk - Part II

Shen Zhen, China

Github Repository

I have a Docker-Compose File that allows me to provision an instance of the OSTicket Helpdesk with a MariaDB backend. I then ported it to Nomad. But I am still struggling with connecting the OSTicket Frontend to the MariaDB backend. The following solution uses the host network stack to allow both services to connect (the next step is to use Consul Connect). I am using the Sidecar Pattern to combine both tasks - frontend and backend - into a single Nomad Job:

Hashicorp Nomad to set up an OSTicket Helpdesk

Hashicorp Nomad to set up an OSTicket Helpdesk

The Nomad Service Stanza allows me to monitor both application and make sure they remain running:

Hashicorp Nomad to set up an OSTicket Helpdesk

Hashicorp Nomad to set up an OSTicket Helpdesk

Complete Nomad Job File

job "osticket" {
datacenters = ["mydatacenter"]
group "osticket" {

network {
mode = "host"
port "tcp" {
static = 3306
}
port "http" {
static = 8080
}
}

update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "5m"
progress_deadline = "10m"
auto_revert = true
auto_promote = true
canary = 1
}

volume "osticket_db" {
type = "host"
read_only = false
source = "osticket_db"
}

restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}

service {
name = "osticket-db"
port = "tcp"
tags = [
"database"
]

check {
name = "DB Health"
port = "tcp"
type = "tcp"
interval = "30s"
timeout = "4s"
}
}

service {
name = "osticket-frontend"
port = "http"
tags = [
"frontend"
]

check {
name = "HTTP Health"
path = "/"
type = "http"
protocol = "http"
interval = "10s"
timeout = "2s"
}
}

task "osticket-db" {
driver = "docker"

config {
image = "mariadb:latest"
ports = ["tcp"]
network_mode = "host"
force_pull = false
}

volume_mount {
volume = "osticket_db"
destination = "/var/lib/mysql" #<-- in the container
read_only = false
}

env {
MYSQL_ROOT_PASSWORD = "secret"
MYSQL_USER = "osticket"
MYSQL_PASSWORD = "secret"
MYSQL_DATABASE = "osticket"
CONTAINER_NAME = "127.0.0.1"
}
}

task "osticket-frontend" {
driver = "docker"

config {
image = "my.gitlab.com:12345/server_management/osticket-docker:latest"
ports = ["http"]
network_mode = "host"
force_pull = false

auth {
username = "mygitlabuser"
password = "asecretpassword"
}
}

env {
MYSQL_USER = "osticket"
MYSQL_HOST = "127.0.0.1"
MYSQL_PASSWORD = "secret"
MYSQL_DATABASE = "osticket"
}
}
}
}