homelab/nomad-job/batch-seedboxsync.nomad

78 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2022-10-12 19:18:43 +00:00
2023-11-25 17:57:32 +00:00
job "batch-seedboxsync" {
2022-10-12 19:18:43 +00:00
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 {
2023-11-01 07:42:04 +00:00
crons = ["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-12-06 18:13:46 +00:00
image = "ducampsv/rsync: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",
2023-11-23 19:57:56 +00:00
"--remove-source-files",
2022-11-21 18:41:03 +00:00
"-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
}
}
}
}