I have the following string in an ansible variable, xyz
xyz = "/u01/dbbackup_nfs/orabackups/odaserver-c/database/857970682/akash_2/db"
I want to split this string such that I stop at orabackups and do a set_fact of the variable abc , such that abc will have the following value.
set_fact:
abc: "/u01/dbbackup_nfs"
Any suggestions on this would be really helpful
>Solution :
The declaration below
abc: "/{{ xyz.split('/')[1:3]|join('/') }}"
gives what you want
abc: /u01/dbbackup_nfs