consul template {{node}} default value no use?



我的领事模板版本:

# ./consul-template -v
consul-template v0.18.0-rc2 (652183d)

我尝试使用以下模板来测试节点:

{{with node}}{{.Node.Node}} ({{.Node.Address}}){{range .Services}}
  {{.Service}} {{.Port}} ({{.Tags | join ","}}){{end}}
{{end}}

我运行外壳:

./consul-template -log-level debug -once -consul-addr consul-agent:9500 -template "/home/data/consul/templates/test1.tmpl:/home/data/consul/results/test1"

但在那之后,test1 没有结果。输出调试信息如下所示,shell永远等待:

2017/01/19 03:17:29.283638 [INFO] consul-template v0.18.0-rc2 (652183d)
2017/01/19 03:17:29.283660 [INFO] (runner) creating new runner (dry: false, once: true)
2017/01/19 03:17:29.284061 [DEBUG] (runner) final config: {"Consul":{"Address":"consul-agent:9500","Auth":{"Enabled":false,"Username":"","Password":""},"Retry":{"Attempts":5,"Backoff":250000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":false,"Key":"","ServerName":"","Verify":true},"Token":""},"Dedup":{"Enabled":false,"MaxStale":2000000000,"Prefix":"consul-template/dedup/","TTL":15000000000},"Exec":{"Command":"","Enabled":false,"Env":{"Blacklist":null,"Custom":null,"Pristine":false,"Whitelist":null},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":0},"KillSignal":2,"LogLevel":"debug","MaxStale":2000000000,"PidFile":"","ReloadSignal":1,"Syslog":{"Enabled":false,"Facility":"LOCAL0"},"Templates":[{"Backup":false,"Command":"","CommandTimeout":30000000000,"Contents":"","Destination":"/home/data/consul/results/test1","Exec":{"Command":"","Enabled":false,"Env":{"Blacklist":[],"Custom":[],"Pristine":false,"Whitelist":[]},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":30000000000},"Perms":420,"Source":"/home/data/consul/templates/test1.tmpl","Wait":{"Enabled":false,"Min":0,"Max":0},"LeftDelim":"","RightDelim":""}],"Vault":{"Address":"","Enabled":false,"RenewToken":true,"Retry":{"Attempts":5,"Backoff":250000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":true,"Key":"","ServerName":"","Verify":true},"UnwrapToken":false},"Wait":{"Enabled":false,"Min":0,"Max":0}}
2017/01/19 03:17:29.284113 [INFO] (runner) creating watcher
2017/01/19 03:17:29.284311 [INFO] (runner) starting
2017/01/19 03:17:29.284334 [DEBUG] (runner) running initial templates
2017/01/19 03:17:29.284347 [INFO] (runner) initiating run
2017/01/19 03:17:29.284394 [DEBUG] (runner) checking template b0b0ddfdf27b9ee0b190f139850272f6
2017/01/19 03:17:29.284811 [DEBUG] (runner) was not watching 1 dependencies
2017/01/19 03:17:29.284847 [DEBUG] (watcher) adding catalog.node
2017/01/19 03:17:29.284869 [DEBUG] (runner) diffing and updating dependencies
2017/01/19 03:17:29.284886 [DEBUG] (runner) watching 1 dependencies
2017/01/19 03:17:29.288772 [INFO] (runner) initiating run
2017/01/19 03:17:29.288796 [DEBUG] (runner) checking template b0b0ddfdf27b9ee0b190f139850272f6
2017/01/19 03:17:29.289160 [DEBUG] (runner) missing data for 1 dependencies
2017/01/19 03:17:29.289183 [DEBUG] (runner) diffing and updating dependencies
2017/01/19 03:17:29.289197 [DEBUG] (runner) catalog.node(8c163f72e7ac) is still needed
2017/01/19 03:17:29.289210 [DEBUG] (runner) watching 1 dependencies

但是如果我像这样更改模板:

{{with node "8c163f72e7ac"}}{{.Node.Node}} ({{.Node.Address}}){{range .Services}}
  {{.Service}} {{.Port}} ({{.Tags | join ","}}){{end}}
{{end}}

它工作正常!为什么我必须给出节点名称?在领事模板文档 https://github.com/hashicorp/consul-template#node 中,它说

在没有任何参数的情况下调用时,当前代理的节点 被返回。

有什么帮助吗?

在我为此报告问题后,https://github.com/hashicorp/consul-template/pull/856 已修复此问题。谢谢!

相关内容

  • 没有找到相关文章

最新更新