Question:
I have this Ansible as a String:
1 2 |
FUBAR={{ PREFIX }}_{{ CNAME }}{{ VERSION }} |
I want to replace all .
in the concatenated string with ''
, like this:
1 2 |
FUBAR={{ {{ PREFIX }}_{{ CNAME }}{{ VERSION }} | replace('.','') }} |
I get the message:
1 2 |
expected token ':', got '}' |
Could anyone give me a suggestion what’s wrong?
Answer:
1 2 |
FUBAR="{{ ( PREFIX + '_' + CNAME + VERSION ) | replace('.','') }}" |
Resolving a few problems:
- too many ‘{{}}’s
- need quotes around the whole expression
- the replace will only act on the last element unless it is all surrounded by ‘()’s