datacenter = "dc1"
data_dir = "/opt/nomad/data"
plugin_dir = "/opt/nomad/plugins"
log_level = "INFO"
name = "{{ ansible_hostname }}"

bind_addr = "0.0.0.0"

addresses {
  http = "{{ ansible_host }}"
  rpc  = "{{ ansible_host }}"
  serf = "{{ ansible_host }}"
}

advertise {
  http = "{{ ansible_host }}:4646"
  rpc  = "{{ ansible_host }}:4647"
  serf = "{{ ansible_host }}:4648"
}

ports {
  http = 4646
  rpc  = 4647
  serf = 4648
}

server {
  enabled = true
  bootstrap_expect = 3
  server_join {
    retry_join = [
      "semaphore.tailnet-68f9.ts.net:4648",
      "ash1d.tailnet-68f9.ts.net:4648", 
      "ash2e.tailnet-68f9.ts.net:4648",
      "ch2.tailnet-68f9.ts.net:4648",
      "ch3.tailnet-68f9.ts.net:4648",
      "onecloud1.tailnet-68f9.ts.net:4648",
      "de.tailnet-68f9.ts.net:4648",
      "hcp1.tailnet-68f9.ts.net:4648"
    ]
  }
}

{% if ansible_hostname == 'hcp1' %}
client {
  enabled = true
  network_interface = "tailscale0"
  
  servers = [
    "semaphore.tailnet-68f9.ts.net:4647",
    "ash1d.tailnet-68f9.ts.net:4647",
    "ash2e.tailnet-68f9.ts.net:4647",
    "ch2.tailnet-68f9.ts.net:4647",
    "ch3.tailnet-68f9.ts.net:4647",
    "onecloud1.tailnet-68f9.ts.net:4647",
    "de.tailnet-68f9.ts.net:4647",
    "hcp1.tailnet-68f9.ts.net:4647"
  ]
  
  host_volume "traefik-certs" {
    path      = "/opt/traefik/certs"
    read_only = false
  }
  
  host_volume "fnsync" {
    path = "/mnt/fnsync"
    read_only = false
  }
  
  meta {
    consul = "true"
    consul_version = "1.21.5"
    consul_client = "true"
  }
  
  gc_interval = "5m"
  gc_disk_usage_threshold = 80
  gc_inode_usage_threshold = 70
}

plugin "nomad-driver-podman" {
  config {
    socket_path = "unix:///run/podman/podman.sock"
    volumes {
      enabled = true
    }
  }
}
{% endif %}

consul {
  address = "ch4.tailnet-68f9.ts.net:8500,ash3c.tailnet-68f9.ts.net:8500,warden.tailnet-68f9.ts.net:8500"
  server_service_name = "nomad"
  client_service_name = "nomad-client"
  auto_advertise = true
  server_auto_join = false
  client_auto_join = true
}

telemetry {
  collection_interval = "1s"
  disable_hostname = false
  prometheus_metrics = true
  publish_allocation_metrics = true
  publish_node_metrics = true
}