-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
65ff835
commit e500b16
Showing
3 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ConfigMaps | ||
|
||
## configmap-env-vars.j2 | ||
You can use this to create a configmap with key value pairs. This jinja template will require a dict of the following name and format: | ||
```yaml | ||
configmap_env_vars: | ||
key1: config1 | ||
key2: config2 | ||
key3: config3 | ||
``` | ||
Let's generate a configmap from the above: | ||
`ansible -i <inventory> all -m template -a "src=configmap-env-vars.j2 dest=/tmp/configmap.yml" -e name=configmap-env-vars -e @/path/to/my/configmap_env_vars` | ||
The generated configmap now looks like | ||
```yaml | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: configmap-env-vars | ||
data: | ||
key3: config3 | ||
key2: config2 | ||
key1: config1 | ||
``` | ||
|
||
## configmap-files.j2 | ||
You can use this to create a configmap with multiple keys/files. This jinja template will require a dict of the following name and format: | ||
```yaml | ||
configmap_files: | ||
file1.yml: |- | ||
# This is a comment in 'file1.yml' | ||
property1: blue | ||
file2.yml: |- | ||
property2: yellow | ||
``` | ||
Let's generate a configmap from the above: | ||
`ansible -i <inventory> all -m template -a "src=configmap-files.j2 dest=/tmp/configmap.yml" -e name=configmap-files -e @/path/to/my/configmap_files` | ||
The generated configmap now looks like | ||
```yaml | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: configmap-files | ||
data: | ||
file1.yml: | | ||
# This is a comment in 'file1.yml' | ||
property1: blue | ||
file2.yml: | | ||
property2: yellow | ||
``` |
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,8 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ name }} | ||
data: | ||
{% for key, value in configmap_env_vars.items() %} | ||
{{ key }}: {{ value }} | ||
{% endfor %} |
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,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ name }} | ||
data: | ||
{% for filename, content in configmap_files.items() %} | ||
{{ filename }}: | | ||
{% for line in content.split('\n') %} | ||
{{ line }} | ||
{% endfor %} | ||
{% endfor %} |