How pass custom values file to consul-template

As we know, consul-template is getting values from consul server. I have values in my local file. I want consul-template should use this local file instead of consul server.

Please help me.

Thanks, Rabbani

Hey @gaddamrabbani, thanks for the question.

Consul-template can monitor a file for changes and use the contents of that file as raw data, including them in a rendered template output, but it cannot read Consul like KV values from it.

If you need more fine grained values maybe you could use Environment variables? You can access any environment variables in your templates and could set them in a wrapping script. They cannot be updated normally, so they are limited.

Perhaps if you described your use case we could come up with other options?

Hope this helps.

Thanks @eikenb for the support.
My requirement is it should use this file contents as KV instead of consul server.

Thanks, Rabbani

Sorry but consul-template doesn’t support that feature. It currently only supports reading from Consul, Vault and Nomad server APIs.

My best stab at a hack for this using consul-template would be to write a script that reads in that file and loads the values into environment variables then starts a consul-template which uses those environment variables. If it needs to be updated when that file changes you could use another consul-template process to run that script (and run a 2nd consul-template) and monitor the KV file for changes, restarting the child consul-template when updates are found. Very much a hack job but I’m pretty sure something like that could work.

Good luck.

Thanks @eikenb for suggesting work around.