How to lookup other hosts in a deployment?

I am trying to understand how to write a Nomad file that can include a template stanza which includes a list of the hosts in the deployment.

The example I have in mind is a minio deployment. I need to provide a variable MINIO_VOLUMES in the form https://<hostname>/<mount path>. Since these do not follow a pattern in my case, I cannot follow the sequential names pattern.

It seems to me then that I need to do a sort of lookup during the run phase to template out a configuration file which contains the list of hosts which the deployment has been run on.

My first thought was to use the Nomad runtime variables, but while I can see how to see the name of the host that the lookup is performed on, I can’t see that the group of hosts is set anywhere.

My next guess was to look up the nodes of a service in consul, e.g.

consul catalog nodes -detailed -service <service-group-task>

but then I remembered that consul will only return healthy services, and I hit a catch-22 (can’t configure the service without knowing the rest of the nodes, which need to know about each other).

Then, I thought, ok what if I register a service with a pre-task and use that to discover the rest of the hosts in the deployment, similar to a pilot job.

Does this reasoning make sense? Am I missing something trivial?

Thanks,
Bruce