using tests to match a hostname

I am trying to use tests to match a hostname, I want hostnames that end in the letter “d”, they are non-production hosts, here is what I have:

- name: Register to Foreman Redhat non-Prod
  redhat_subscription:
    state: present
    activationkey: "Non-Prod-Redhat-7"
    org_id: "Default_Organization"
  when: inventory_hostname_short | match("*d")

and I am getting this error:

TASK [Register to Foreman Redhat non-Prod] ***********************************************************************************************************************************************
fatal: [slpatch001d]: FAILED! => {“failed”: true, “msg”: “The conditional check ‘inventory_hostname_short | match("*d")’ failed. The error was: nothing to repeat\n\nThe error appears to have been in ‘/Users/millerlu/misc/foreman.yml’: line 10, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Register to Foreman Redhat non-Prod\n ^ here\n”}

What am I doing wrong here?

Thanks,
Luke

The match is a regular expression match (not a wildcard match). If you want something ending in ‘d’ try this:

search(‘d$’)

kind regards
Pshem