# Nomad-pack job dependencies?

**URL:** <https://discuss.hashicorp.com/t/nomad-pack-job-dependencies/66527>\
**Category:** Nomad\
**Tags:** nomad-pack\
**Created:** [April 29, 2024, 7:12pm UTC](https://discuss.hashicorp.com/t/nomad-pack-job-dependencies/66527 "2024-04-29T19:12:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AAverin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/aaverin/32/40742_2.png) [@AAverin](https://discuss.hashicorp.com/u/AAverin)\
**Post date:** [April 29, 2024, 7:12pm UTC](https://discuss.hashicorp.com/t/nomad-pack-job-dependencies/66527/1 "2024-04-29T19:12:17Z")

</div>

I have a task that reads nomad service address/port getting service name by a variable `prometheus_service_name`:

```auto
{{ range nomadService [[.my.prometheus_service_name | quote]] }}
      url="http://{{ .Address }}:{{ .Port }}/api/v1/write"
{{ end }}

```

How would this work if prometheus task that provides the service with name `prometheus_service_name` restarts, so address and port would change?

Basically service would get disconnected and my task would be failing due to service connection missing.

How can I configure a nomad job to depend on another job? I would like to restart my dependent job when parent job restart to make sure service connections are rebuilt and live again.

---

<div class="post-metadata">

**Author:** ![AAverin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/aaverin/32/40742_2.png) [@AAverin](https://discuss.hashicorp.com/u/AAverin)\
**Post date:** [April 30, 2024, 2:38pm UTC](https://discuss.hashicorp.com/t/nomad-pack-job-dependencies/66527/2 "2024-04-30T14:38:12Z")

</div>

So the proper answer to this and my other questions for Nomad is `Use Consul`. Consul provides dynamic service discovery and template can restart the task when use service changes.

Unfortunately even somewhat simple infra can’t be built on Nomad without Consul.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [July 1, 2024, 2:38pm UTC](https://discuss.hashicorp.com/t/nomad-pack-job-dependencies/66527/3 "2024-07-01T14:38:18Z")

</div>

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.
