Created
July 31, 2014 00:46
-
-
Save carmstrong/088e06b19b0b762a8810 to your computer and use it in GitHub Desktop.
confd 0.6.x templating woes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -q https://s3-us-west-2.amazonaws.com/opdemand/confd-0.6.x-json-firstsecondlastpart-rand -O ./confd | |
chmod +x ./confd | |
etcdctl set /deis/domains/upright-banana foo.bar.ca whoami.com | |
etcdctl set /deis/services/upright-banana/upright-banana_v2 1.2.3.4:4445 | |
etcdctl set /deis/services/downright-tropico/downright-tropico_v2 2.3.4.5:1233 | |
etcdctl set /deis/builder/users/carmstrong/deis PRIVATE_KEY_MATERIAL | |
etcdctl set /deis/builder/users/carmstrong/too PRIVATE_KEY_MATERIAL | |
etcdctl set /deis/builder/users/gabrtv/gabriel PRIVATE_KEY_MATERIAL | |
etcdctl set /deis/builder/users/gabrtv/gabrtv PRIVATE_KEY_MATERIAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[template] | |
src = "sample.conf.tmpl" | |
dest = "/home/core/sample.conf" | |
keys = [ | |
"/domains", | |
"/builder/users", | |
"/services", | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ range $key := gets "/builder/users/*/*" }} | |
command="/usr/local/bin/gitreceive run {{ part $key.Key 2 }} {{ part $key.Key 3 }}",no-agent-forwarding,no-pty,no-user-rc,no-X11-forwarding,no-port-forwarding {{ $key.Value }} | |
{{ end }} | |
{{ range $service := gets "/services/*/*" }}{{ if $service.Value }} | |
upstream {{ second $service.Key }} { | |
{{ with $str := second $service.Key }}{{ with $path := "/services/"+ $str +"/*" }}{{ range $upstream := gets $path }}server {{ $upstream.Value }}; | |
{{ end }}{{ end }}{{ end }} | |
} | |
server { | |
server_name ~^{{ second $service.Key }}\.(?<domain>.+)${{ with $str := second $service.Key }}{{ with $path := "/domains/"+ $str }}{{ getv $path }}{{ end }}{{ end }}; | |
server_name_in_redirect off; | |
port_in_redirect off; | |
location / { | |
proxy_buffering off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_redirect off; | |
proxy_connect_timeout 10s; | |
proxy_send_timeout 1200s; | |
proxy_read_timeout 1200s; | |
proxy_next_upstream error timeout http_502 http_503 http_504; | |
add_header X-Deis-Upstream $upstream_addr; | |
proxy_pass http://{{ second $service.Key }}; | |
} | |
} | |
{{ end }}{{ end }} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./confd -onetime -backend etcd -confdir /home/core -prefix '/deis' -node 127.0.0.1:4001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment