agent/template: add static_secret_render_interval configurable (#11934)
* agent/template: add default_lease_duration config * go mod tidy * Add changelog * Fix panic * Add documentation * Change to static_secret_render_interval * Update doc * Update command/agent/template/template.go Co-authored-by: Theron Voran <tvoran@users.noreply.github.com> * Update changelog/11934.txt Co-authored-by: Theron Voran <tvoran@users.noreply.github.com> * Update website/content/docs/agent/template-config.mdx Co-authored-by: Theron Voran <tvoran@users.noreply.github.com> Co-authored-by: Theron Voran <tvoran@users.noreply.github.com>
This commit is contained in:
parent
a8cc5e4557
commit
b2b25be0ce
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
agent/template: Added static_secret_render_interval to specify how often to fetch non-leased secrets
|
||||
```
|
|
@ -119,7 +119,9 @@ type Sink struct {
|
|||
|
||||
// TemplateConfig defines global behaviors around template
|
||||
type TemplateConfig struct {
|
||||
ExitOnRetryFailure bool `hcl:"exit_on_retry_failure"`
|
||||
ExitOnRetryFailure bool `hcl:"exit_on_retry_failure"`
|
||||
StaticSecretRenderIntRaw interface{} `hcl:"static_secret_render_interval"`
|
||||
StaticSecretRenderInt time.Duration `hcl:"-"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
@ -585,6 +587,14 @@ func parseTemplateConfig(result *Config, list *ast.ObjectList) error {
|
|||
|
||||
result.TemplateConfig = &cfg
|
||||
|
||||
if result.TemplateConfig.StaticSecretRenderIntRaw != nil {
|
||||
var err error
|
||||
if result.TemplateConfig.StaticSecretRenderInt, err = parseutil.ParseDurationSecond(result.TemplateConfig.StaticSecretRenderIntRaw); err != nil {
|
||||
return err
|
||||
}
|
||||
result.TemplateConfig.StaticSecretRenderIntRaw = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -544,7 +544,8 @@ func TestLoadConfigFile_TemplateConfig(t *testing.T) {
|
|||
"set-true": {
|
||||
"./test-fixtures/config-template_config.hcl",
|
||||
TemplateConfig{
|
||||
ExitOnRetryFailure: true,
|
||||
ExitOnRetryFailure: true,
|
||||
StaticSecretRenderInt: 1 * time.Minute,
|
||||
},
|
||||
},
|
||||
"empty": {
|
||||
|
|
|
@ -7,9 +7,10 @@ vault {
|
|||
|
||||
template_config {
|
||||
exit_on_retry_failure = true
|
||||
static_secret_render_interval = 60
|
||||
}
|
||||
|
||||
template {
|
||||
source = "/path/on/disk/to/template.ctmpl"
|
||||
destination = "/path/on/disk/where/template/will/render.txt"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,6 +240,10 @@ func newRunnerConfig(sc *ServerConfig, templates ctconfig.TemplateConfigs) (*ctc
|
|||
conf.Vault.Namespace = &sc.Namespace
|
||||
}
|
||||
|
||||
if sc.AgentConfig.TemplateConfig != nil && sc.AgentConfig.TemplateConfig.StaticSecretRenderInt != 0 {
|
||||
conf.Vault.DefaultLeaseDuration = &sc.AgentConfig.TemplateConfig.StaticSecretRenderInt
|
||||
}
|
||||
|
||||
conf.Vault.SSL = &ctconfig.SSLConfig{
|
||||
Enabled: pointerutil.BoolPtr(false),
|
||||
Verify: pointerutil.BoolPtr(false),
|
||||
|
|
5
go.sum
5
go.sum
|
@ -113,7 +113,6 @@ github.com/Jeffail/gabs v1.1.1/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/
|
|||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
|
@ -517,7 +516,6 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
|
|||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
|
@ -744,7 +742,6 @@ github.com/huaweicloud/golangsdk v0.0.0-20200304081349-45ec0797f2a4/go.mod h1:WQ
|
|||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
|
||||
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
|
@ -882,8 +879,6 @@ github.com/miekg/dns v1.1.40 h1:pyyPFfGMnciYUk/mXpKkVmeMQjfXqt3FAJ2hy7tPiLA=
|
|||
github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/cli v1.1.1 h1:J64v/xD7Clql+JVKSvkYojLOXu1ibnY9ZjGLwSt/89w=
|
||||
github.com/mitchellh/cli v1.1.1/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/cli v1.1.2 h1:PvH+lL2B7IQ101xQL63Of8yFS2y+aDlsFcsqNc+u/Kw=
|
||||
github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4=
|
||||
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
||||
|
|
|
@ -52,3 +52,8 @@ The top level `template_config` block has the following configuration entries:
|
|||
- `exit_on_retry_failure` `(bool: false)` - This option configures Vault Agent
|
||||
to exit after it has exhausted its number of template retry attempts due to
|
||||
failures.
|
||||
|
||||
- `static_secret_render_interval` `(string or integer: 5m)` - If specified, configures
|
||||
how often Vault Agent Template should render non-leased secrets such as KV v2.
|
||||
This setting will not change how often Vault Agent Templating renders leased
|
||||
secrets.
|
||||
|
|
Loading…
Reference in New Issue