certs = {'.*thinking.*': 'akash', '.*sleeping.*': 'akashthakur'}

def map_regex(value, mapping=certs):
    for k, v in list(mapping.items()):
        if re.match(k, value):
            return v
using regex in jinja 2 for ansible playbooks