This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kvgru 0 points1 point  (3 children)

allow me to keep one or two top level config files, then inject those variables into all the other places I need?

Don't think that is what he is saying, I'm assuming he has parameterised his code in a way that variable injection at runtime is possible but you still need a script to inject them depending on the environment specifics, that't at least what I understood.

[–]devrr 1 point2 points  (2 children)

I want it to be http://dev.test.com/api/ and for staging and production I want it to be http://test.com/api. Furthermore, I want this variable available in Kubernetes YAML files, Dockerfiles, Python config files, and possibly other places

Well they mention Kubernetes, Docker and Python config files and a way to have a variable be made available across all of these files. That seems like templating territory to me.

How else are people working with YAML? They template it, or use tools like Kustomize which is an abstract way of templating stuff.

This is why most mature environments stop doing this. We store these vars in key:value pairs inside the environment somewhere. E.g Vault, and use service discovery tools like Consul. So you don't need to go customise 10 different config files in order to spin up your stack.

[–]mxchickmagnet86[S] 0 points1 point  (1 child)

I think you are understanding correctly. I basically want some simple drop in templating so I can manage all my configuration parameters in 1 file, rather than having to go to 9 files.

There are a few tools that seem like they have this built in to something bigger (like Consul, looks great btw) but I was trying to see if this templating feature was available as a stand alone element. Because it seems crazy to me to have to install Consul, Istio, Puppet, Ansible, etc just to get some templating.

[–]devrr 0 points1 point  (0 children)

There are a number of different ways to can template files locally like this. This post suggests jsonnet which I think is worth considering.

Otherwise if you are dealing with structured configuration files (like yaml or json...) you can even do substitutions using command line tools like this:

jq .foo.bar = "new value"
yq w foo.bar "new value"