consul 起動
$ consul agent -data-dir /tmp/consul -server -bootstrap
confd 用設定ファイル
$ cat ~/confd/conf.d/myconfig.toml
[template]
src = "myconfig.conf.tmpl"
dest = "/tmp/myconfig.conf"
keys = [
"consul",
]
confd で生成するファイルのテンプレート
$ cat ~/confd/templates/myconfig.conf.tmpl [gosuke-miyashita@P255]
# This a comment
[myconfig]
{{ range .consul }}consul_server = {{ .Node }}{{ end }}
confd でファイル生成
$ confd -verbose -onetime -backend=consul -confdir ~/confd
2014-05-30T11:39:04+09:00 P255.local confd[6169]: WARNING Skipping confd config file.
2014-05-30T11:39:04+09:00 P255.local confd[6169]: NOTICE Starting confd
2014-05-30T11:39:04+09:00 P255.local confd[6169]: NOTICE Backend set to consul
2014-05-30T11:39:04+09:00 P255.local confd[6169]: NOTICE Consul address set to 127.0.0.1:8500
2014-05-30T11:39:04+09:00 P255.local confd[6169]: INFO Target config /tmp/myconfig.conf out of sync
2014-05-30T11:39:04+09:00 P255.local confd[6169]: INFO Target config /tmp/myconfig.conf has been updated