homelab/nomad-job/crowdsec-agent.nomad

86 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

2022-05-26 12:19:32 +00:00
job "crowdsec-agent" {
datacenters = ["homelab","hetzner"]
type = "system"
meta {
forcedeploy = "2"
}
vault{
policies= ["access-tables"]
}
group "crowdsec-agent"{
2022-05-26 16:25:11 +00:00
network {
mode = "host"
port "metric"{
to = 6060
}
}
2022-05-26 12:19:32 +00:00
task "crowdsec-agent" {
2022-05-26 16:25:11 +00:00
service {
name= "crowdsec-metrics"
port = "metric"
tags = [
]
}
2022-05-26 12:19:32 +00:00
driver = "docker"
config {
image = "crowdsecurity/crowdsec"
2022-05-26 16:25:11 +00:00
ports = ["metric"]
2022-05-26 12:19:32 +00:00
volumes = [
"/var/run/docker.sock:/var/run/docker.sock",
"/var/log:/var/log",
"local/acquis.yaml:/etc/crowdsec/acquis.yaml"
]
}
env {
2022-05-26 16:25:11 +00:00
COLLECTIONS= "crowdsecurity/traefik crowdsecurity/home-assistant LePresidente/gitea"
2022-05-26 12:19:32 +00:00
DISABLE_LOCAL_API= "true"
}
template {
data = <<EOH
---
source: docker
container_name_regexp:
- traefik-*
labels:
type: traefik
2022-05-26 16:25:11 +00:00
---
source: docker
container_name_regexp:
- hass-*
labels:
type: homeassistant
---
source: docker
container_name_regexp:
- gitea-*
labels:
2022-08-27 07:34:27 +00:00
type: gitea
2022-05-26 16:25:11 +00:00
2022-05-26 12:19:32 +00:00
EOH
destination = "local/acquis.yaml"
}
template {
data = <<EOH
LOCAL_API_URL = {{- range service "crowdsec-api" }} "http://{{ .Address }}:{{ .Port }}"{{- end }}
AGENT_USERNAME = "{{ env "node.unique.name" }}"
{{with secret "secrets/data/crowdsec"}}
AGENT_PASSWORD = "{{.Data.data.AGENT_PASSWORD}}"
{{end}}
EOH
destination ="secret/agent.env"
env = "true"
}
resources {
memory = 100
}
}
}
}