{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/consul-template/issues/761","repository_url":"https://api.github.com/repos/hashicorp/consul-template","labels_url":"https://api.github.com/repos/hashicorp/consul-template/issues/761/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/consul-template/issues/761/comments","events_url":"https://api.github.com/repos/hashicorp/consul-template/issues/761/events","html_url":"https://github.com/hashicorp/consul-template/issues/761","id":184622838,"number":761,"title":"Querying across Datacenters","user":{"login":"cprenzberg","id":1010782,"avatar_url":"https://avatars.githubusercontent.com/u/1010782?v=3","gravatar_id":"","url":"https://api.github.com/users/cprenzberg","html_url":"https://github.com/cprenzberg","followers_url":"https://api.github.com/users/cprenzberg/followers","following_url":"https://api.github.com/users/cprenzberg/following{/other_user}","gists_url":"https://api.github.com/users/cprenzberg/gists{/gist_id}","starred_url":"https://api.github.com/users/cprenzberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cprenzberg/subscriptions","organizations_url":"https://api.github.com/users/cprenzberg/orgs","repos_url":"https://api.github.com/users/cprenzberg/repos","events_url":"https://api.github.com/users/cprenzberg/events{/privacy}","received_events_url":"https://api.github.com/users/cprenzberg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-22T10:28:28Z","updated_at":"2016-11-14T16:32:22Z","closed_at":"2016-10-22T21:44:33Z","body":"Hi guys, \n\nI am trying to generate a file containing nginx upstream blocks for all consul services across datacenters. However I am having issues as the template only seems to list services in only one datacenter. I am new to consul-template and would appreciate any pointers.\n\nHere is my template:\n\n``` bash\n{{range $dc := datacenters}}\n        {{$dc}}\n        {{$at_dc := print \"@\" $dc}}\n        {{range services $at_dc}}\n                upstream {{.Name}} {\n                  least_conn;\n                  {{range service .Name}}\n                  server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;\n                  {{else}}\n                  server 127.0.0.1:65535; # force a 502\n                  {{end}}\n                }\n        {{end}}\n{{end}}\n\n```\n\nI am getting the following result:\n\n``` bash\nams2\n\n\n                upstream consul {\n                  least_conn;\n\n                  server 45.55.70.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.131.181.220:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.236.125.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream redis {\n                  least_conn;\n\n                  server 45.55.78.241:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream web {\n                  least_conn;\n\n                  server 45.55.78.241:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:80 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n\n        nyc3\n\n\n                upstream consul {\n                  least_conn;\n\n                  server 45.55.70.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.131.181.220:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.236.125.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream proxy {\n                  least_conn;\n\n                  server 45.55.129.90:80 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream redis {\n                  least_conn;\n\n                  server 45.55.78.241:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream web {\n                  least_conn;\n\n                  server 45.55.78.241:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:80 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n\n        sfo1\n\n\n                upstream consul {\n                  least_conn;\n\n                  server 45.55.70.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.131.181.220:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 104.236.125.32:8300 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream redis {\n                  least_conn;\n\n                  server 45.55.78.241:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:6379 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n\n                upstream web {\n                  least_conn;\n\n                  server 45.55.78.241:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.78.162:80 max_fails=3 fail_timeout=60 weight=1;\n\n                  server 45.55.74.86:80 max_fails=3 fail_timeout=60 weight=1;\n\n                }\n```\n\nAs you can see the template just repeats the list of servers for all datacenters. How can I fix this template?\n\nThanks!\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/consul-template/issues/comments/260385708","html_url":"https://github.com/hashicorp/consul-template/issues/761#issuecomment-260385708","issue_url":"https://api.github.com/repos/hashicorp/consul-template/issues/761","id":260385708,"user":{"login":"dcparker88","id":1847494,"avatar_url":"https://avatars.githubusercontent.com/u/1847494?v=3","gravatar_id":"","url":"https://api.github.com/users/dcparker88","html_url":"https://github.com/dcparker88","followers_url":"https://api.github.com/users/dcparker88/followers","following_url":"https://api.github.com/users/dcparker88/following{/other_user}","gists_url":"https://api.github.com/users/dcparker88/gists{/gist_id}","starred_url":"https://api.github.com/users/dcparker88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcparker88/subscriptions","organizations_url":"https://api.github.com/users/dcparker88/orgs","repos_url":"https://api.github.com/users/dcparker88/repos","events_url":"https://api.github.com/users/dcparker88/events{/privacy}","received_events_url":"https://api.github.com/users/dcparker88/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T16:32:22Z","updated_at":"2016-11-14T16:32:22Z","body":"Might be doing something weird, but when I try fixing the bug in `{{range service .Name}}` I get an error:\r\n\r\n`{{range service $at_dc}}`, `{{range service \".Name@$dc\"}}` both give me the following error:\r\n`error calling service: invalid health service dependency format`. I have been getting that error recently when trying to query a service in a different datacenter and using `.Name`. Am I doing something wrong?\r\n\r\nThanks for any help! :D\r\n"}}
{"actor":{"display_login":"dcparker88"}}