hashicorp / hashicorp/nomad

Recognize nomadVar alloc index under job

Open
#22,235 1 comment 0 reactions 0 assignees View on GitHub
stage/needs-discussion theme/variables type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal

Today, it's possible to store variable in Nomad and we can ACL's variable based on the path

```
{{ with nomadVar "nomad/jobs/group_name/task_name" }}
```

My proposal is to add a 4th layer of the alloc_index

```
{{ with nomadVar "nomad/jobs/job_name/group_name/task_name/1" }}
{{ with nomadVar "nomad/jobs/job_name/group_name/task_name/2" }}
{{ with nomadVar "nomad/jobs/job_name/group_name/task_name/${NOMAD_ALLOC_INDEX}" }}
```

### Use-cases

Having a group with multiple tasks don't means to have the same variables.

### Attempted Solutions

The only solution to keep ACL's working is to have the index in the variable names.

I can trick using something like

```
{{- define "custom" }}MY_VALUE_{{ NOMAD_ALLOC_INDEX }}{{ end }}
{{ executeTemplate "custom" }}: {{ env (executeTemplate "custom") }}
```

Because if you do

```
nomad/jobs/job_name/group_name/task_name/1
```

You lost the the ACL permission on the task name

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the nomadVar template entry point and reading how variable paths and ACL permissions are handled. Trace the existing job/group/task path behavior, then determine how alloc indices 1, 2, and NOMAD_ALLOC_INDEX should be recognized without losing task-level permissions. Done means the proposed paths work consistently and preserve the intended ACL scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.