-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbe6e13
commit d8a68fa
Showing
4 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Manage backend key for vault addons | ||
|
||
## The problem | ||
|
||
If you are using the `s3` backend configuration for terraformed parts of the vault role, you might encounter | ||
a problem of backend state key overlap. | ||
|
||
If you look into `roles/vault/tasks/main.yml` you will find this section: | ||
|
||
```{code-block} | ||
:caption: roles/vault/tasks/main.yml | ||
:linenos: | ||
:lineno-start: 66 | ||
- name: "Include requested vault addons" | ||
include_tasks: | ||
file: "{{ role_path }}/tasks/tf_addons/_{{ _current_conf_addon }}.yml" | ||
apply: | ||
tags: | ||
- addons | ||
loop: "{{ hs_vault_enabled_addons }}" | ||
loop_control: | ||
loop_var: _current_conf_addon | ||
when: | ||
- __hs_vault_is_master | ||
tags: | ||
- addons | ||
``` | ||
|
||
As you can read, addons are applied in a sequence and there is a `loop_var` statement. | ||
|
||
The idea is to rely on this mechanism to handle your key dynamism. You could configure your vault | ||
role like in this example: | ||
|
||
|
||
```{code-block} | ||
:caption: roles/vault/tasks/main.yml | ||
:linenos: | ||
hs_vault_terraform_backend_type: 's3' | ||
hs_vault_terraform_backend_config: | ||
key: "vault_{{ _current_conf_addon | default('no_current_conf_addon') }}" | ||
bucket: "..." | ||
``` | ||
|
||
In this way, when the `hs_vault_terraform_backend_config` will be evaluated during the applicance loop | ||
the property `key` will have a different value for each loop, directly linked to the current addon being applied. | ||
|
||
The `| default('no_current_conf_addon')` here is only to detect any evaluation outside of the applicance loop | ||
that could occur. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters