Consul-template: It should parse "Once" param from the config file

Created on 6 Jan 2021  路  2Comments  路  Source: hashicorp/consul-template

Seems like it ignores "Once" parameter from the config file. Tried to pass -once=true as a cmd parameter and it's working as expected.

Not sure did I miss something, but it parses out successfully all other params from the config file.

Consul Template version

consul-template v0.25.1 (b11fa800)

Command

/usr/local/bin/consul-template -config=/consul/config.json -log-level=debug

Configuration

{
  "consul": [
    {
      "address": "https://intra-consul.service.dev.csnzoo.com",
      "auth": [
        {
          "enabled": false
        }
      ],
      "retry": {
        "attempts": 6,
        "backoff": "250ms",
        "enabled": true,
        "max_backoff": "1m"
      },
      "ssl": {
        "ca_cert": "",
        "ca_path": "",
        "cert": "",
        "enabled": false,
        "key": "",
        "server_name": "",
        "verify": false
      }
    }
  ],
  "deduplicate": [
    {
      "enabled": false
    }
  ],
  "kill_signal": "SIGTERM",
  "log_level": "info",
  "max_stale": "10m",
  "pid_file": "",
  "reload_signal": null,
  "syslog": [
    {
      "enabled": false
    }
  ],
  "template": [
    {
      "backup": false,
      "contents": "---\n  resources:\n    {{- range ls \"kubernetes/config\" }}\n    {{ .Key }}: '{{ .Value | replaceAll \"\\n\" \"\" }}'{{ end }}",
      "create_dest_dirs": false,
      "destination": "/etc/config.yaml",
      "error_on_missing_key": false,
      "function_denylist": null,
      "left_delimiter": "{{",
      "perms": 0,
      "right_delimiter": "}}",
      "sandbox_path": "",
      "source": "",
      "wait": {
        "max": "10s",
        "min": "5s"
      }
    }
  ],
  "wait": [
    {
      "max": "10s",
      "min": "5s"
    }
  ],
  "block_query_wait": "60s"
  "Once": true

Debug output

2021/01/06 12:48:30.532305 [INFO] consul-template v0.25.1 (b11fa800)
2021/01/06 12:48:30.532320 [INFO] (runner) creating new runner (dry: false, once: false)
2021/01/06 12:48:30.532707 [DEBUG] (runner) final config: 
{
   "Consul":{
      "Address":"https://intra-consul.service",
      "Namespace":"",
      "Auth":{
         "Enabled":false,
         "Username":"",
         "Password":""
      },
      "Retry":{
         "Attempts":6,
         "Backoff":250000000,
         "MaxBackoff":60000000000,
         "Enabled":true
      },
      "SSL":{
         "CaCert":"",
         "CaPath":"",
         "Cert":"",
         "Enabled":false,
         "Key":"",
         "ServerName":"",
         "Verify":false
      },
      "Token":"",
      "Transport":{
         "DialKeepAlive":30000000000,
         "DialTimeout":30000000000,
         "DisableKeepAlives":false,
         "IdleConnTimeout":90000000000,
         "MaxIdleConns":100,
         "MaxIdleConnsPerHost":143,
         "TLSHandshakeTimeout":10000000000
      }
   },
   "Dedup":{
      "Enabled":false,
      "MaxStale":2000000000,
      "Prefix":"consul-template/dedup/",
      "TTL":15000000000,
      "BlockQueryWaitTime":60000000000
   },
   "DefaultDelims":{
      "Left":null,
      "Right":null
   },
   "Exec":{
      "Command":"",
      "Enabled":false,
      "Env":{
         "Denylist":[

         ],
         "Custom":[

         ],
         "Pristine":false,
         "Allowlist":[

         ]
      },
      "KillSignal":2,
      "KillTimeout":30000000000,
      "ReloadSignal":null,
      "Splay":0,
      "Timeout":0
   },
   "KillSignal":15,
   "LogLevel":"trace",
   "MaxStale":600000000000,
   "PidFile":"",
   "ReloadSignal":0,
   "Syslog":{
      "Enabled":false,
      "Facility":"LOCAL0",
      "Name":"consul-template"
   },
   "Templates":[
      {
         "Backup":false,
         "Command":"",
         "CommandTimeout":30000000000,
         "Contents":"---\n  resources:\n    {{- range ls \"kubernetes/config\" }}\n    {{ .Key }}: '{{ .Value | replaceAll \"\\n\" \"\" }}'{{ end }}",
         "CreateDestDirs":false,
         "Destination":"/etc/config.yaml",
         "ErrMissingKey":false,
         "Exec":{
            "Command":"",
            "Enabled":false,
            "Env":{
               "Denylist":[

               ],
               "Custom":[

               ],
               "Pristine":false,
               "Allowlist":[

               ]
            },
            "KillSignal":2,
            "KillTimeout":30000000000,
            "ReloadSignal":null,
            "Splay":0,
            "Timeout":30000000000
         },
         "Perms":0,
         "Source":"",
         "Wait":{
            "Enabled":true,
            "Min":5000000000,
            "Max":10000000000
         },
         "LeftDelim":"{{",
         "RightDelim":"}}",
         "FunctionDenylist":[

         ],
         "SandboxPath":""
      }
   ],
   "Vault":{
      "Address":"",
      "Enabled":false,
      "Namespace":"",
      "RenewToken":false,
      "Retry":{
         "Attempts":12,
         "Backoff":250000000,
         "MaxBackoff":60000000000,
         "Enabled":true
      },
      "SSL":{
         "CaCert":"",
         "CaPath":"",
         "Cert":"",
         "Enabled":true,
         "Key":"",
         "ServerName":"",
         "Verify":true
      },
      "Transport":{
         "DialKeepAlive":30000000000,
         "DialTimeout":30000000000,
         "DisableKeepAlives":false,
         "IdleConnTimeout":90000000000,
         "MaxIdleConns":100,
         "MaxIdleConnsPerHost":143,
         "TLSHandshakeTimeout":10000000000
      },
      "UnwrapToken":false
   },
   "Wait":{
      "Enabled":true,
      "Min":5000000000,
      "Max":10000000000
   },
   "Once":false,
   "BlockQueryWaitTime":60000000000
}

Expected behavior

0000},"UnwrapToken":false},"Wait":{"Enabled":true,"Min":5000000000,"Max":10000000000},"Once":true,"BlockQueryWaitTime":60000000000}

Actual behavior

0000},"UnwrapToken":false},"Wait":{"Enabled":true,"Min":5000000000,"Max":10000000000},"Once":false,"BlockQueryWaitTime":60000000000}
question

All 2 comments

Hey @njegosrailic, sorry that the docs are unclear on this point but -once is a command line only option, it has no corresponding config option.

Hey @eikenb, thanks for the answer.

Was this page helpful?
0 / 5 - 0 ratings