You have to use the "split" function and specify the delimiter. Depending on which part of the "exploded" string you need, you can use positive or negative values as a parameter.
For example, when trying to get the IOS image from a router you may get something like the following:
"ansible_net_image": "unix:/opt/unetlab/addons/iol/bin/i86bin-linux-l3-adventerprisek9-15.4"
{{ ansible_net_image.split('/')[-1] }}
{{ ansible_net_image.split('/')[0] }}
No comments:
Post a Comment