Consul-template stuck on all templates rendered

Hello,

I am trying to render a consul template for HAProxy. The template renders from the log but never exits, so I interrupt. But when I check the output file it’s still the same as template and doesn’t have the contents populated. Am I missing something?

/usr/local/bin/consul-template -consul-addr=127.0.0.1:8500 -template=/etc/haproxy/consul-haproxy.cfg.ctmpl:/etc/haproxy/tmp/haproxy.cfg -log-level debug

Thanks for the help in advance!

Here’s the log

2022/05/12 17:06:00.656020 [INFO] (runner) creating watcher
2022/05/12 17:06:00.656542 [INFO] (runner) starting
2022/05/12 17:06:00.656595 [DEBUG] (runner) running initial templates
2022/05/12 17:06:00.656637 [DEBUG] (runner) initiating run
2022/05/12 17:06:00.656667 [DEBUG] (runner) checking template b7888b8f45580a699b849605b324be7a
2022/05/12 17:06:00.656864 [DEBUG] (runner) rendering "/etc/haproxy/consul-haproxy.cfg.ctmpl" => "/etc/haproxy/tmp/haproxy.cfg"
2022/05/12 17:06:00.656932 [DEBUG] (runner) diffing and updating dependencies
2022/05/12 17:06:00.656964 [DEBUG] (runner) watching 0 dependencies
2022/05/12 17:06:00.657004 [DEBUG] (runner) all templates rendered
^C2022/05/12 17:09:38.037288 [DEBUG] (cli) receiving signal "interrupt"
Cleaning up...
2022/05/12 17:09:38.037302 [INFO] (runner) stopping
2022/05/12 17:09:38.037305 [DEBUG] (runner) stopping watcher
2022/05/12 17:09:38.037307 [DEBUG] (watcher) stopping all views

By default consul-template runs as a daemon to monitor changes in consul and re-render the template. If you just want to run it one-off you’ll need to add the -once flag.

For debugging I find it helpful to use -template=/etc/haproxy/consul-haproxy.cfg.ctmpl:- -once to render to stdout.

Hey @karthmnz, thanks for asking.

This shows that consul-template did not find anything to trigger a data lookup in the template it is rendering. The function calls in the template should trigger those dependency lookups/watches it is talking about here.

Could you post the contents of the consul-haproxy.cfg.ctmpl you used above? If you can we might be able to help you figure out why it isn’t triggering any values to be looked up.