Here is my playbook
---
- name: This is a hello-world example
hosts: localhost
vars:
mystr: "I.To.Be.war"
tasks:
- name: Hi
debug:
msg: "{{ mystr.split('.') | first | trim }}"
Output:
I
The trim filter is to get rid of \r\n at the end of the variable incase it has.
However, I wish a generic solution that should print everything before the last element of the split delimiter, i.e.: ..
Expected output:
I.To.Be
Note: I do not want a solutions like "{{ mystr.split('.')[0][1][2] }}" as it is not generic in nature.