Ansible 2.2
I want to get to the slices of the below variable, how would I do so ?
hostvars[inventory_hostname]['ansible_hostname']|list
basically I have a hostname, hostname001
that I wish to retrieve the last two characters on.
How do I split it and slice it?
Try ansible_hostname[-3:]
.
Why do you use hostvars[inventory_hostname]['ansible_hostname']
instead of simply ansible_hostname
?
For strings and lists you may use Python slicing technics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With