Cheatsheet
Dynamic variables
example1
'{{ lookup('vars', 'somevar_' ~ other_var) }}'
example2
'{{ regex_search('/.+?(?=/' ~ sid ~ ')') }}'
Get file names from find module
- ansible.builtin.find:
paths: "/my/path"
register: my_list
- ansible.builtin.set_fact:
myvar: "{{ my_list['files'] | map(attribute='path') | map('basename') | list }}"
Block jinja2 trim
At beginning of template
#jinja2: trim_blocks:False
Template in K8S manifest
kind: ConfigMap
apiVersion: v1
metadata:
name: myname
data:
sync.yaml: |