homelab/nomad-job/seedboxsync.nomad

77 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-10-12 19:18:43 +00:00
job "seedboxsync" {
datacenters = ["homelab"]
2022-10-29 08:40:01 +00:00
priority = 50
type = "batch"
2022-10-12 19:18:43 +00:00
meta {
forcedeploy = "0"
}
2022-10-23 15:32:01 +00:00
constraint {
attribute = "${attr.cpu.arch}"
2022-10-29 08:40:01 +00:00
value = "amd64"
2022-10-23 15:32:01 +00:00
}
2022-10-12 19:18:43 +00:00
periodic {
2022-10-29 08:40:01 +00:00
cron = "0,30 * * * *"
2022-10-12 19:18:43 +00:00
prohibit_overlap = true
}
2022-10-29 08:40:01 +00:00
group "seedboxsync" {
2022-10-12 19:18:43 +00:00
network {
mode = "host"
}
2022-10-29 08:40:01 +00:00
vault {
2022-10-30 08:33:39 +00:00
policies = ["seedbox"]
2022-10-12 19:18:43 +00:00
}
2022-11-21 18:41:03 +00:00
task "rsync" {
2022-10-12 19:18:43 +00:00
driver = "docker"
service {
2022-11-21 18:41:03 +00:00
name = "seedboxsync"
2022-10-12 19:18:43 +00:00
}
config {
2022-11-21 18:41:03 +00:00
image = "ducampsv/rsync-docker:latest"
2022-10-12 19:18:43 +00:00
volumes = [
2022-11-21 18:41:03 +00:00
"/mnt/diskstation/media/download:/media",
"local/id_rsa:/home/rsyncuser/.ssh/id_rsa"
2022-10-12 19:18:43 +00:00
]
2022-11-21 18:41:03 +00:00
command = "rsync"
2022-10-29 08:40:01 +00:00
args = [
2022-11-21 18:41:03 +00:00
"--info=progress2",
"-e" , "ssh -p23 -o StrictHostKeyChecking=no",
"-a",
"${USERNAME}@${REMOTE_SERVER}:${REMOTE_PATH}",
"/media",
"--exclude=seed",
"-v"
2022-10-12 19:18:43 +00:00
]
}
2022-10-23 15:32:01 +00:00
env {
2022-11-21 18:41:03 +00:00
RSYNC_UID = 1000001
RSYNC_GID = 1000007
2022-10-23 15:32:01 +00:00
}
2022-10-12 19:18:43 +00:00
template {
2022-10-29 08:40:01 +00:00
data = <<EOH
2022-10-30 08:33:39 +00:00
{{ with secret "secrets/data/nomad/seedbox"}}
2022-10-12 19:18:43 +00:00
USERNAME = "{{ .Data.data.username }}"
2022-11-21 18:41:03 +00:00
REMOTE_PATH = "{{ .Data.data.remote_rsync_path }}"
2022-10-12 19:18:43 +00:00
REMOTE_SERVER = "{{ .Data.data.remote_server }}"
{{end}}
EOH
destination = "secrets/sample.env"
2022-10-29 08:40:01 +00:00
env = true
2022-10-12 19:18:43 +00:00
}
2022-11-21 18:41:03 +00:00
template {
data = "{{ with secret \"secrets/data/nomad/seedbox\"}}{{ .Data.data.private_key }}{{end}}"
destination = "local/id_rsa"
uid=1000001
perms= "600"
}
2022-10-12 19:18:43 +00:00
resources {
2022-11-21 18:41:03 +00:00
memory = 500
2022-10-12 19:18:43 +00:00
}
}
}
}