hashicorp / consul-template

Template rendering, notifier, and supervisor for @HashiCorp Consul and Vault data.
https://www.hashicorp.com/
Mozilla Public License 2.0
4.76k stars 781 forks source link

Consul template error #696

Closed mg03 closed 8 years ago

mg03 commented 8 years ago

Hi

consul-template -v consul-template v0.15.0


vi dnsmasq.ctmpl

{{service "consul@us-east-1"}}

consul-template -config=/etc/consul-template/conf -template "/etc/consul-template/tmpl/dnsmasq.ctmpl:/tmp/result" -dry
2016/08/17 20:37:05 [INFO] consul-template v0.15.0
2016/08/17 20:37:05 [INFO] (runner) creating new runner (dry: true, once: false)
2016/08/17 20:37:05 [DEBUG] (runner) final config (tokens suppressed):

{
  "Path": "/etc/consul-template/conf",
  "Consul": "172.250.31.75:8500",
  "Token": "",
  "Auth": {
    "Enabled": false,
    "Username": "",
    "Password": ""
  },
  "Vault": {
    "Address": "",
    "Token": "",
    "Renew": true,
    "SSL": {
      "Enabled": true,
      "Verify": true,
      "Cert": "",
      "Key": "",
      "CaCert": ""
    }
  },
  "SSL": {
    "Enabled": false,
    "Verify": true,
    "Cert": "",
    "Key": "",
    "CaCert": ""
  },
  "Syslog": {
    "Enabled": false,
    "Facility": "LOCAL0"
  },
  "MaxStale": 600000000000,
  "ConfigTemplates": [
    {
      "Source": "/etc/consul-template/tmpl/dnsmasq.ctmpl",
      "Destination": "/etc/dnsmsq.d/10-consul1",
      "Command": "",
      "CommandTimeout": 30000000000,
      "Perms": 420,
      "Backup": false,
      "LeftDelim": "",
      "RightDelim": "",
      "Wait": {
        "min": 0,
        "max": 0
      }
    },
    {
      "Source": "/etc/consul-template/tmpl/dnsmasq.ctmpl",
      "Destination": "/tmp/result",
      "Command": "",
      "CommandTimeout": 30000000000,
      "Perms": 420,
      "Backup": false,
      "LeftDelim": "",
      "RightDelim": "",
      "Wait": {
        "min": 0,
        "max": 0
      }
    }
  ],
  "Retry": 10000000000,
  "Wait": {
    "min": 0,
    "max": 0
  },
  "PidFile": "",
  "LogLevel": "debug",
  "Deduplicate": {
    "Enabled": false,
    "Prefix": "consul-template/dedup/",
    "TTL": 15000000000
  }
}

2016/08/17 20:37:05 [INFO] (clients) creating consul/api client
2016/08/17 20:37:05 [DEBUG] (clients) setting consul address to "172.250.31.75:8500"
2016/08/17 20:37:05 [INFO] (clients) creating vault/api client
2016/08/17 20:37:05 [DEBUG] (clients) enabling vault SSL
2016/08/17 20:37:05 [INFO] (runner) creating Watcher
2016/08/17 20:37:05 [INFO] (runner) starting
2016/08/17 20:37:05 [DEBUG] (runner) running initial templates
2016/08/17 20:37:05 [INFO] (runner) running
2016/08/17 20:37:05 [DEBUG] (runner) checking template /etc/consul-template/tmpl/dnsmasq.ctmpl
Consul Template returned errors:
**_template: template: dnsmasq.ctmpl:15: function "consul_dns_domain" not defined_**
sethvargo commented 8 years ago

Can you share the contents of /etc/consul-template/tmpl/dnsmasq.ctmpl?

mg03 commented 8 years ago

Hi seth


interface=*
addn-hosts=/etc/hosts
# Never forward addresses in the non-routed address spaces.
bogus-priv
# the followin is needed to prevent anyone from using this as a recursive dns and/or for DNS poisoning
no-resolv
dns-forward-max=0

{{range service "consul@us-east-1"}}
server=/domain/{{.Address}}#8500
{{end}}

It seems to work now. i do not know what happened. But restarting the consul-template service a few times made things work.

I will debug it a bit more since this almost seems like magic and Im not liking it. If I find anything ill let you know.

Thanx