Created
May 13, 2021 20:20
-
-
Save langerma/06cdb8039ee56def518a00db8c13379d to your computer and use it in GitHub Desktop.
homeassistant nomad job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hashicorp At Home - A series of blog posts by Mockingbird Consulting | |
# Read the original at https://www.mockingbirdconsulting.co.uk/blog/2019-01-05-hashicorp-at-home/ | |
# | |
# This code is licensed under the MIT License, and remains the copyright of Mockingbird Consulting Ltd. | |
# This configuration will launch homeassistant.io and have it hosted at homeassistant.service.consul | |
# (assuming the default domain of .consul has been retained from the original articles). | |
# | |
# Configuration for HomeAssistant will be saved to the host machine in /srv/home_assistant/config, | |
# so if you have an existing HomeAssistant configuration you should be able to drop the files in to | |
# /srv/home_assistant/config and see all your existing configuration in the HomeAssistant UI. | |
job "homeassistant" { | |
constraint { | |
attribute = "${attr.cpu.arch}" | |
value = "arm64" | |
} | |
datacenters = ["morsegasse"] | |
type = "service" | |
update { | |
max_parallel = 1 | |
min_healthy_time = "10s" | |
healthy_deadline = "30m" | |
progress_deadline = "60m" | |
auto_revert = false | |
canary = 0 | |
} | |
migrate { | |
max_parallel = 1 | |
health_check = "checks" | |
min_healthy_time = "15s" | |
healthy_deadline = "20m" | |
} | |
group "homeassistant" { | |
count = 1 | |
restart { | |
attempts = 2 | |
interval = "30m" | |
delay = "15s" | |
mode = "fail" | |
} | |
network { | |
port "homeassistant_core" { | |
static = 8123 | |
} | |
} | |
task "homeassistant_core" { | |
driver = "docker" | |
config { | |
hostname = "homeassistant" | |
force_pull = true | |
image = "homeassistant/home-assistant:2021.5.2" | |
network_mode = "host" | |
privileged = true | |
volumes = [ | |
"/nfs/home_assistant/config:/config", | |
"/etc/localtime:/etc/localtime:ro" | |
] | |
ports = ["homeassistant_core"] | |
#port_map { | |
# homeassistant_core = 8123 | |
#} | |
} | |
resources { | |
cpu = 500 # 500 MHz | |
memory = 512 # 512 MB | |
} | |
service { | |
name = "homeassistant" | |
tags = ["homeassistant", "homeautomation", "traefik.enable=true"] | |
port = "homeassistant_core" | |
check { | |
name = "alive" | |
type = "tcp" | |
interval = "10s" | |
timeout = "2s" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment