286 lines
7.4 KiB
HCL
286 lines
7.4 KiB
HCL
job "hass" {
|
|
# region = "global"
|
|
datacenters = ["dc1"]
|
|
type = "service"
|
|
|
|
# priority = 50
|
|
|
|
constraint {
|
|
attribute = "${attr.kernel.name}"
|
|
value = "linux"
|
|
}
|
|
constraint {
|
|
attribute = "${attr.unique.hostname}"
|
|
operator = "regexp"
|
|
value = "odroid.*"
|
|
}
|
|
// constraint {
|
|
// operator = "distinct_hosts"
|
|
// value = "true"
|
|
// }
|
|
|
|
affinity {
|
|
attribute = "${attr.unique.hostname}"
|
|
value = "odroid2"
|
|
weight = 80
|
|
}
|
|
update {
|
|
# Stagger updates every 60 seconds
|
|
stagger = "10s"
|
|
max_parallel = 1
|
|
}
|
|
group "hass" {
|
|
count = 1
|
|
|
|
restart {
|
|
attempts = 99
|
|
interval = "1h"
|
|
delay = "10s"
|
|
mode = "delay"
|
|
}
|
|
|
|
task "init" {
|
|
driver = "docker"
|
|
lifecycle {
|
|
hook = "prestart"
|
|
sidecar = false
|
|
}
|
|
config {
|
|
memory_hard_limit = "2048"
|
|
image_pull_timeout = "10m"
|
|
force_pull = false
|
|
image = "ghcr.io/sstent/rsync"
|
|
volumes = [
|
|
"/mnt/configs/${NOMAD_GROUP_NAME}:/config",
|
|
"/mnt/Public/config/${NOMAD_GROUP_NAME}:/configbackup",
|
|
"/mnt/Public/config/locks:/locks"
|
|
]
|
|
|
|
}
|
|
env {
|
|
DB_NAME = "home-assistant_v2.db"
|
|
}
|
|
resources {
|
|
cpu = 20 # 500 MHz
|
|
memory = 20 # 128MB
|
|
}
|
|
// template {
|
|
// data = <<EOH
|
|
// dbs:
|
|
// - path: /config/radarr.db
|
|
// replicas:
|
|
// - path: /configbackup
|
|
// EOH
|
|
|
|
// destination = "local/litestream.yml"
|
|
// }
|
|
}
|
|
|
|
|
|
task "finalsync" {
|
|
driver = "docker"
|
|
lifecycle {
|
|
hook = "poststop"
|
|
}
|
|
config {
|
|
memory_hard_limit = "2048"
|
|
|
|
image = "ghcr.io/sstent/rsync"
|
|
volumes = [
|
|
"/mnt/configs/${NOMAD_GROUP_NAME}:/config",
|
|
"/mnt/Public/config/${NOMAD_GROUP_NAME}:/configbackup",
|
|
"/mnt/Public/config/locks:/locks"
|
|
]
|
|
|
|
// args = ["flock", "-x", "/locks/${NOMAD_GROUP_NAME}_rsync.lock", "rsync", "-av","--exclude='8-20 * * *.db8-20 * * *'","--exclude='8-20 * * *.db'","--exclude='8-20 * * *.db-litestream'","--exclude='generations'","/config/","/configbackup/"]
|
|
}
|
|
resources {
|
|
cpu = 20 # 500 MHz
|
|
memory = 128 # 128MB
|
|
}
|
|
}
|
|
|
|
|
|
task "sync" {
|
|
driver = "docker"
|
|
lifecycle {
|
|
hook = "poststart"
|
|
sidecar = true
|
|
}
|
|
config {
|
|
memory_hard_limit = "2048"
|
|
|
|
image = "ghcr.io/sstent/rsync"
|
|
volumes = [
|
|
"/mnt/configs/:/configs",
|
|
"/mnt/Public/config/${NOMAD_GROUP_NAME}:/configbackup",
|
|
]
|
|
args = ["client"]
|
|
}
|
|
env {
|
|
CRON_TASK_1 = "50 8-20 * * *rsync -av --exclude='*.db*' --exclude='*.db' --exclude='.db-litestream' --exclude='generations' /configs/${NOMAD_GROUP_NAME}/ /configbackup/;"
|
|
}
|
|
resources {
|
|
cpu = 20 # 500 MHz
|
|
memory = 20 # 128MB
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
task "hass" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
// image = "homeassistant/armhf-homeassistant:latest"
|
|
image = "ghcr.io/home-assistant/home-assistant:stable"
|
|
ports = ["http","http_8989"]
|
|
memory_hard_limit = "2048"
|
|
network_mode = "host"
|
|
cap_add = ["NET_ADMIN"]
|
|
force_pull = false
|
|
volumes = [
|
|
"/etc/localtime:/etc/localtime",
|
|
"local/configuration.yaml:/config/configuration.yaml",
|
|
"local/ui-lovelace.yaml:/config/ui-lovelace.yaml",
|
|
"/mnt/configs/hass:/config",
|
|
]
|
|
// "local/auth_provider.homeassistant:/config/.storage/auth_provider.homeassistant"
|
|
|
|
|
|
|
|
}
|
|
env {
|
|
JEMALLOC_DISABLE=true
|
|
}
|
|
service {
|
|
name = "${TASKGROUP}"
|
|
tags = ["global", "homeassistant", "tools","logo=home-assistant"]
|
|
port = "http"
|
|
|
|
// check {
|
|
// name = "hass-alive"
|
|
// type = "http"
|
|
// type = "script"
|
|
// command = "curl -sS http://localhost:8123"
|
|
// interval = "120s"
|
|
// timeout = "15s"
|
|
// path = "/api/"
|
|
// port = "http"
|
|
|
|
// check_restart {
|
|
// limit = 10
|
|
// grace = "90s"
|
|
// ignore_warnings = false
|
|
// }
|
|
// }
|
|
}
|
|
|
|
// template {
|
|
// data = <<EOH
|
|
// homeassistant:
|
|
// name: Our_House
|
|
// latitude: 40.7654
|
|
// longitude: -73.8175
|
|
// elevation: 26
|
|
// unit_system: metric
|
|
// time_zone: America/New_York
|
|
// auth_providers:
|
|
// - type: trusted_networks
|
|
// trusted_networks:
|
|
// - 127.0.0.1
|
|
// - ::1
|
|
// - 192.168.1.0/24
|
|
// allow_bypass_login: true
|
|
// - type: homeassistant
|
|
// frontend:
|
|
// lovelace:
|
|
// mode: yaml
|
|
// config:
|
|
// http:
|
|
// sun:
|
|
// automation:
|
|
// - alias: LightsAtSunset
|
|
// trigger:
|
|
// platform: sun
|
|
// event: sunset
|
|
// action:
|
|
// service: switch.turn_on
|
|
// entity_id: switch.lampdrawers
|
|
// wemo:
|
|
// static:
|
|
// - 192.168.99.200 # StuBed
|
|
// - 192.168.99.201 # LampDrawers
|
|
// - 192.168.99.202 # BigLamp
|
|
// - 192.168.99.203 # TallTree
|
|
// - 192.168.99.204 # ShortTree
|
|
// - 192.168.99.205 # TallTree
|
|
// switch:
|
|
// - platform: template
|
|
// switches:
|
|
// living_room_screen_off:
|
|
// friendly_name: 'living_room_screen_off'
|
|
// turn_on:
|
|
// - service: input_boolean.turn_on
|
|
// entity_id: input_boolean.living_room_screen_off
|
|
// - service: webostv.command
|
|
// data:
|
|
// {
|
|
// "entity_id": "media_player.lg_webos_smart_tv",
|
|
// "command": "com.webos.service.tvpower/power/turnOffScreen"
|
|
// }
|
|
// turn_off:
|
|
// - service: input_boolean.turn_off
|
|
// entity_id: input_boolean.living_room_screen_off
|
|
// - service: webostv.command
|
|
// data:
|
|
// {
|
|
// "entity_id": "media_player.lg_webos_smart_tv",
|
|
// "command": "com.webos.service.tvpower/power/turnOnScreen"
|
|
// }
|
|
// EOH
|
|
|
|
// destination = "local/configuration.yaml"
|
|
// }
|
|
|
|
template {
|
|
change_mode = "restart"
|
|
data = "{{ key \"homeassistant/configuration.yml\" }}"
|
|
destination = "local/configuration.yaml"
|
|
}
|
|
|
|
template {
|
|
change_mode = "restart"
|
|
data = "{{ key \"homeassistant/lovelace.yml\" }}"
|
|
destination = "local/ui-lovelace.yaml"
|
|
}
|
|
|
|
resources {
|
|
cpu = 256 # 500 MHz
|
|
memory = 128 # 128MB
|
|
}
|
|
|
|
# Specify configuration related to log rotation
|
|
logs {
|
|
max_files = 10
|
|
max_file_size = 15
|
|
}
|
|
|
|
kill_timeout = "10s"
|
|
}
|
|
|
|
network {
|
|
port "http" {
|
|
static = 8123
|
|
to = 8123
|
|
}
|
|
port "http_8989" {
|
|
static = 8989
|
|
to = 8989
|
|
}
|
|
}
|
|
}
|
|
}
|