Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- job "netbox" {
- datacenters = ["dc1"]
- type = "service"
- group "app" {
- count = 1
- network {
- port "http" { to = 8080 }
- port "psql" { to = 5432 }
- port "redis" { to = 6379 }
- port "redis-cache" { to = 6379 }
- }
- # Service discovery
- service {
- name = "netbox"
- port = "http"
- provider = "consul"
- check {
- name = "netbox-app"
- type = "http"
- port = "http"
- path = "/api"
- interval = "60s"
- timeout = "3s"
- }
- check {
- name = "netbox-postgres"
- type = "tcp"
- port = "psql"
- interval = "10s"
- timeout = "2s"
- }
- check {
- name = "netbox-redis"
- type = "tcp"
- port = "redis"
- interval = "10s"
- timeout = "2s"
- }
- check {
- name = "netbox-redis-cache"
- type = "tcp"
- port = "redis-cache"
- interval = "10s"
- timeout = "2s"
- }
- }
- # Netbox
- task "netbox-app" {
- driver = "docker"
- user = "unit:root"
- config {
- image = "docker.io/netboxcommunity/netbox:v3.6-2.7.0"
- ports = ["http"]
- mount {
- source = "/srv/containers/netbox/configuration"
- target = "/etc/netbox/config"
- type = "bind"
- readonly = true
- }
- mount {
- source = "/srv/containers/netbox/data/media"
- target = "/opt/netbox/netbox/media"
- type = "bind"
- readonly = false
- }
- mount {
- source = "/srv/containers/netbox/data/reports"
- target = "/opt/netbox/netbox/reports"
- type = "bind"
- readonly = false
- }
- mount {
- source = "/srv/containers/netbox/data/scripts"
- target = "/opt/netbox/netbox/scripts"
- type = "bind"
- readonly = false
- }
- }
- template {
- data = <<EOF
- DB_HOST={{ env "NOMAD_HOST_IP_psql" }}
- DB_PORT={{ env "NOMAD_HOST_PORT_psql" }}
- REDIS_CACHE_HOST={{ env "NOMAD_HOST_IP_redis-cache" }}
- REDIS_CACHE_PORT={{ env "NOMAD_HOST_PORT_redis_cache" }}
- REDIS_HOST={{ env "NOMAD_HOST_IP_redis" }}
- REDIS_PORT={{ env "NOMAD_HOST_PORT_redis" }}
- {{ key "nomad/prod/tasks/netbox" }}
- {{ with secret (print "kv/data/nomad/netbox") }}
- {{ range $k, $v := .Data.data }}
- {{ $k }}="{{ $v }}"{{ end }}
- {{ end }}
- EOF
- destination = "local/env"
- env = true
- }
- vault { policies = ["nomad-server"] }
- resources {
- cpu = 2000
- memory = 1024
- }
- }
- # PostgreSQL
- task "netbox-postgres" {
- driver = "docker"
- config {
- image = "docker.io/postgres:14-alpine"
- mount {
- type = "bind"
- source = "/srv/containers/netbox/data/postgres/data"
- target = "/var/lib/postgresql/data"
- readonly = false
- }
- ports = ["psql"]
- }
- template {
- data = <<EOF
- {{ key "nomad/netbox-postgres" }}
- {{ with secret "kv/data/nomad/netbox-postgres" }}
- POSTGRES_PASSWORD={{ .Data.data.POSTGRES_PASSWORD }}
- {{ end }}
- EOF
- destination = "local/env"
- env = true
- }
- vault {
- policies = ["nomad-server"]
- }
- resources {
- cpu = 1000
- memory = 1024
- }
- }
- # Netbox Redis
- task "netbox-redis" {
- driver = "docker"
- config {
- image = "docker.io/redis:6-alpine"
- command = "redis-server"
- args = ["--appendonly","yes","--requirepass","${REDIS_PASSWORD}",]
- ports = ["redis"]
- mount {
- type = "bind"
- source = "/srv/containers/netbox/data/redis/data"
- target = "/data"
- readonly = false
- }
- }
- template {
- data = <<EOF
- REDIS_PASSWORD={{ with secret "kv/nomad/netbox-redis" }}{{ .Data.data.REDIS_PASSWORD }}{{ end }}
- EOF
- destination = "local/env"
- env = true
- }
- vault {
- policies = ["nomad-server"]
- }
- }
- # Netbox Redis Cache
- task "netbox-redis-cache" {
- driver = "docker"
- config {
- image = "docker.io/redis:6-alpine"
- command = "redis-server"
- args = ["--requirepass","${REDIS_PASSWORD}"]
- mount {
- type = "bind"
- source = "/srv/containers/netbox/data/redis-cache/data"
- target = "/data"
- readonly = false
- }
- ports = ["redis-cache"]
- }
- template {
- data = <<EOF
- REDIS_PASSWORD={{ with secret "kv/nomad/netbox-redis-cache" }}{{ .Data.data.REDIS_PASSWORD }}{{ end }}
- EOF
- destination = "local/env"
- env = true
- }
- vault {
- policies = ["nomad-server"]
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement