What is the syntax within the regex_search() to match against a variable?
For below, vcsourcekit = 10, I want to match regex ^10. It doesn't evaluate the variable, rather interprets literally.
- name: Do something awesome
vmware_guest:
hostname: "{{ vcenterhostname }}"
...
when:
- item.key | regex_search('^(vcsourcekit)')
with_dict: "{{ vmfacts.virtual_machines }}"
Thanks!
Best Answer
Not the most beautiful thing but this works:
Without the cast to string, I get a
cannot concatenate 'str' and 'int' objects
on ansible 2.2.0.0 and I don't have time to update just now.