Conditional substring in a Jinja2 template


When deploying with ansible, There’s 1 specific case where I need to strip a string of a trailing -p substring.

The string somemachine-prod-p should become somemachine-prod only if the -p is at the end.

The substring function I saw I can use with Jinja does not fulfill my needs as I need to strip the end of the string, not the start.



Found it.

If anyone wants to know:

Leave a Reply