Looking for an Ansible task that will fail the playbook if a variable does not match a given regex. Something like:
# fail when hostname doesn't match a regex
- fail:
msg: "The inventory hostname must match regex"
when: {{ inventory_hostname }} not matches [a-z](([-0-9a-z]+)?[0-9a-z])?(\.[a-z0-9](([-0-9a-z]+)?[0-9a-z])?)*