kelseyhightower / confd

Manage local application configuration files using templates and data from etcd or consul
MIT License
8.35k stars 1.41k forks source link

Please add confd autoconfiguration using environment variables #545

Open Rudd-O opened 7 years ago

Rudd-O commented 7 years ago

I've had to write a custom program to configure confd prior to starting it in my containers:

https://github.com/teralytics/confd-sidecar

It would be great if the feature I wrote (using variables in the environment to configure confd) could be incorporated into confd.

Thanks for such a wonderful piece of software!

HeavyHorst commented 7 years ago

Have you seen #495 ? Also note: #79 #229 #344

Rudd-O commented 7 years ago

495 is unrelated to what I have asked for here.

Rudd-O commented 7 years ago

Actually, none of those issues track any leg of this feature request. This request is about having confd write its own configuration files, not to have confd expand environment variables in existing configuration files.

I agree it would be quite nice if confd could expand env vars in its config files. It still wouldn't solve the problem I'm looking to solve, which is to dynamically configure confd based on the environment. I don't want to have to write confd config files — I want them to appear as specified by my application's specification.

brandonto commented 7 years ago

Running a tool similar to envplate (https://github.com/kreuzwerker/envplate) prior to confd can accomplish what you want.

Rudd-O commented 7 years ago

Thanks. envplate can't reload a service when confd rewrites a config file, and it seems like the way it sets up config files is more complex than confd-sidecar. It seems to me like at least the second feature should be built into confd. Thanks nonetheless.

schaafito commented 6 years ago

100% agree this would be a super convenient feature for confd. Our environment has slight changes to the installation directory of a program based on the environment. It would be great if we could use the same TOML file and just reference the already existing environment variable that tells us where the installation is

[template]
src="mytemplate.tmpl"
dest="$MYAPP_HOME/configuration/configuration.conf"
hubo1016 commented 6 years ago

Seems the issue should be: TOML configuration should also support (at least partially) template? So it can be written as

[template]
src="mytemplate.tmpl"
dest="{{ getenv "MYAPP_HOME" }}/configuration/configuration.conf"

Currently the check command already has a little support in templating. We can support templating on most of the fields, and evaluate them when they are used.

schaafito commented 6 years ago

That would be an amazing feature to have access to in our TOML configuration files

okushchenko commented 6 years ago

The only thing that makes sense, in my opinion, is to reference the environment variables from the templates definitions, as well as the use of environment variables instead of CLI options.