An alternative is to use Jsonnet [0] (a JSON/YAML templating language).
You can define an inheritance relationship, where your template inherits pretty much everything EXCEPT the environment variables. Or the jsonnet cli lets you specify variables to be replaced in the template.
There's some kubernetes flavored examples in [1].
[1] https://github.com/google/jsonnet/tree/master/case_studies/k...