Ansible conditionals - Wildcard match string

Solution 1:

From Testing Strings:

To match strings against a substring or a regex, use the “match” or “search” filter

In your case:

when: ec2_tag_Name is match("testhost.*")

Solution 2:

This works as well.

when: "ec2_tag_Name.startswith('testhost')"

You can combine logical operators as well like and and or