Skip to content

Instantly share code, notes, and snippets.

@mizzy
Created May 30, 2014 02:39
Show Gist options
  • Save mizzy/7c4e0899f66fdf63c491 to your computer and use it in GitHub Desktop.
Save mizzy/7c4e0899f66fdf63c491 to your computer and use it in GitHub Desktop.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment