Deploy backup jobs to all hosts and dynamically determine jobs per node
This commit is contained in:
parent
9ab300c225
commit
d7fa57864f
@ -5,10 +5,15 @@ variable "nextcloud_backup" {
|
||||
|
||||
job "backup" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
type = "system"
|
||||
|
||||
group "nomad0" {
|
||||
count = 1
|
||||
constraint {
|
||||
attribute = "${node.unique.name}"
|
||||
# Only node with a backup job so far
|
||||
value = "n2"
|
||||
}
|
||||
|
||||
group "backup" {
|
||||
|
||||
network {
|
||||
mode = "bridge"
|
||||
@ -18,22 +23,10 @@ job "backup" {
|
||||
}
|
||||
}
|
||||
|
||||
volume "nextcloud-data" {
|
||||
volume "all-volumes" {
|
||||
type = "host"
|
||||
read_only = true
|
||||
source = "nextcloud-data"
|
||||
}
|
||||
|
||||
volume "gitea-data" {
|
||||
type = "host"
|
||||
read_only = true
|
||||
source = "gitea-data"
|
||||
}
|
||||
|
||||
volume "authentik-data" {
|
||||
type = "host"
|
||||
read_only = true
|
||||
source = "authentik-data"
|
||||
source = "all-volumes"
|
||||
}
|
||||
|
||||
service {
|
||||
@ -73,20 +66,8 @@ job "backup" {
|
||||
driver = "docker"
|
||||
|
||||
volume_mount {
|
||||
volume = "nextcloud-data"
|
||||
destination = "/data/nextcloud"
|
||||
read_only = true
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "gitea-data"
|
||||
destination = "/data/gitea"
|
||||
read_only = true
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "authentik-data"
|
||||
destination = "/data/authentik"
|
||||
volume = "all-volumes"
|
||||
destination = "/data"
|
||||
read_only = true
|
||||
}
|
||||
|
||||
@ -94,7 +75,7 @@ job "backup" {
|
||||
image = "iamthefij/resticscheduler"
|
||||
ports = ["metrics"]
|
||||
args = [
|
||||
"/jobs/nextcloud.hcl",
|
||||
"/jobs/node-jobs.hcl",
|
||||
]
|
||||
|
||||
mount {
|
||||
@ -117,8 +98,15 @@ job "backup" {
|
||||
}
|
||||
|
||||
template {
|
||||
data = var.nextcloud_backup
|
||||
destination = "jobs/nextcloud.hcl"
|
||||
data = <<EOF
|
||||
# Current node is {{ env "node.unique.name" }}
|
||||
{{ range service "nextcloud" }}
|
||||
# Nextcloud .Node {{ .Node }}
|
||||
{{ if eq .Node (env "node.unique.name") }}
|
||||
${var.nextcloud_backup}
|
||||
{{ end }}{{ end }}
|
||||
EOF
|
||||
destination = "jobs/node-jobs.hcl"
|
||||
}
|
||||
|
||||
resources {
|
||||
|
@ -205,6 +205,12 @@
|
||||
group: "root"
|
||||
mode: "0777"
|
||||
read_only: true
|
||||
- name: all-volumes
|
||||
path: /srv/volumes
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0777"
|
||||
read_only: false
|
||||
|
||||
roles:
|
||||
- name: ansible-nomad
|
||||
|
Loading…
Reference in New Issue
Block a user