[ASK] Vault Agent Templating Error 'exec' expected a map, got 'slice'

Hi,

we have vault agent template stanza like :

template {
  source               = "/opt/vault/secrets/templates/consul-systemd.service.ctmpl"
  destination          = "/etc/systemd/system/consul.service"
  create_dest_dirs     = false
  error_on_missing_key = true
  perms                = 0644
  backup               = true
  exec = {
    command = ["/opt/vault/scripts/systemd-reloader", "consul"]
    timeout = "30s"
  }
}

error log :

root@ip-10-9-216-18:/opt/vault# /opt/vault/bin/vault agent -config /opt/vault/config/default.hcl -log-level=info
Error loading configuration from /opt/vault/config/default.hcl: error parsing 'template': 1 error(s) decoding:

* 'exec' expected a map, got 'slice'

trying another template :

...
template {
  source               = "/opt/vault/secrets/templates/consul-systemd.service.ctmpl"
  destination          = "/etc/systemd/system/consul.service"
  create_dest_dirs     = false
  error_on_missing_key = true
  perms                = 0644
  backup               = true
  exec {
    command = "/opt/vault/scripts/systemd-reloader consul"
    timeout = "30s"
  }
}

...

still have same error too,
anyone can help us to configure correct exec config ?

based on the docs https://www.vaultproject.io/docs/agent/template#exec seem the former is the correct one, but no luck

exec {
  command = ["/usr/bin/app"]
}

whats that mean @aram , could you elaborate more?

per my understanding, it will not work if we use flag ? in the exec.command section?

but in the docs consul-template/modes.md at v0.28.1 · hashicorp/consul-template · GitHub and consul-template/configuration.md at v0.28.1 · hashicorp/consul-template · GitHub , it can use flag

This seems to be a bug. I just ran into the same problem and am also looking for the solution.

Issue submitted to GH:

1 Like

Fix PR merged to main – should be fixed in the next GA release.

Thank you very much for reporting this to us on GitHub, John!

1 Like