hashicorp / hashicorp/nomad-pack

Dependency packs don't load variables

Open
#415 4 comments 0 reactions 0 assignees View on GitHub
hcc/jira stage/needs-investigation theme/pack theme/template/variable
Dominant language
Go
Stars
447
Forks
65
PR merge metrics
No merged PRs in 30d

Description

Hi,

I've started exploring nomad-packs recently and I'm testing whats possible with the current set of features and Im running into some basic, yet important components that I cant get to work.
What I'm trying to do is fairly standard and not that strange.
Have a separate pack that would be used across everything and we import it as dependency and use the templates from the common pack.
Simple right?

I've made that part of the setup:
```
dependency "shared-packs" {
alias = "sp"
source = "git@<>:dkyanakiev/shared-packs.git//packs/common"
}
```
Note: The alias is not a thing yet but thats the last test I had from one of the open MRs I was looking at

I reference a template I have like so: `[[ template "constraints" .sp ]]`
And it works - however the problem I'm running is that variables I have in my main pack are not passed down to my dependency template.

For example: I have a variable called `environment` which has logic built around it.
```
[[ define "constraints" -]]
[[- if (eq (var "environment" . ) "prod") -]]
constraint {
distinct_hosts = true
}
[[- end ]]
```
I have that variable set in my main pack but the dependency pack never finds that variable. I know for a fact the logic works because when I play with the default variables in the shared-pack I can see how the template renders correctly but not when I actually expect to get the variable from the main template.

I tried setting the variable as default in the main pack or running with a var file - same result.
Documentation is limited so I cant follow if this is me missing something or this not working yet

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.