hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.63k stars 1.92k forks source link

Allow cascading/Inheritance for env {} #2811

Open jippi opened 7 years ago

jippi commented 7 years ago

Similar to update stanza in #2806 - it would be nice if an env{) stanza could be put in

When an allocation is created the final env will be the result of:

The most specific env (closer to the task) will always "win" in the merge.

job "example" {

    env {
        FOO = "bar"
        BAR = "baz"
        BAZ = "qux"
    }

    group "sample" {
        env {
            FOO = "groupBar"
            BAR = "groupBaz"
        }

        task "demo1" {
            env {
                FOO = "taskBar"
                # FOO will be taskBAR
                # BAR will be groupBaz
                # BAZ will be qux
            }
        }

        task "demo2" {
            env {
                # FOO will be groupBar
                # BAR will be groupBaz
                # BAZ will be qux
            }
        }
    }
}

Similar would be great for template{}

theilgaard commented 3 years ago

This would be really nice. I'm currently running the same binary with many shared environment variables, and there is no pretty way of organizing this at the moment.