Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpreted variables in environment variables #448

Closed
bluk opened this issue Nov 18, 2015 · 7 comments · Fixed by #653
Closed

Interpreted variables in environment variables #448

bluk opened this issue Nov 18, 2015 · 7 comments · Fixed by #653

Comments

@bluk
Copy link
Contributor

bluk commented Nov 18, 2015

The Constraint section in the Job Specification has a table with interpreted variables such as $node.id and $meta.<key>. I assume the interpreted variables are meant for just constraints but I want to use them in other parts of the config.

For my use case, I've added some host machine unique metadata to the Nomad client's meta configuration and want to pass that onto a task.

I tried using them in in a task's env section like:

env {
  MY_ENV_NAME = "$node.id"
}

However, the value is set to the literal string $node.id (so not interpreted).

Is there some way to do this? Thanks!

@cbednarski
Copy link
Contributor

@bluk Thanks for opening an issue. This is currently supported only in a limited capacity. We'd like to expand this in a future release.

So we can design and implement this correctly can you describe your use case? For example, I know one use-case is to configure docker container networking via container:<id-of-container-with-networking>. Can you describe what you're trying to do with $node.id?

@bluk
Copy link
Contributor Author

bluk commented Nov 18, 2015

@cbednarski Actually I'm trying to use the Nomad's client meta (used $node.id as a simpler example). Sorry for the misleading example.

I am putting a unique UUID for Vault to use in Nomad's client meta configuration. Then I was hoping to use $meta.uuid to have the variable interpreted by Nomad when the task was run. When a Docker container is run, it would be passed the UUID as an environment variable, and I could use the Auth Backend: App ID to lookup some credentials.

@cbednarski
Copy link
Contributor

@bluk I see. So to clarify, you want to pass a value based on which node the job is placed on?

Thanks for highlighting that use case! I think we can improve this. What I would recommend for now is putting a file on the filesystem on that machine, which you can read in your exec or mount into a container.

@bluk
Copy link
Contributor Author

bluk commented Nov 19, 2015

@cbednarski Yes, exactly! :)

Forgive my ignorance, but how do you mount an arbitrary filesystem into your container via Nomad? I didn't see any way to do that in the documentation.

@cbednarski
Copy link
Contributor

@bluk Ah that's a good question. We don't actually support this yet. Sorry to mislead you about this!

@macb
Copy link

macb commented Nov 21, 2015

For the new system type it would be nice to gather some information for common application configuration, such as hostname or ip. This would be equally useful as args for the fork/exec drivers.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants