using tests to match a hostname

141 views
Skip to first unread message

Luke Miller

unread,
Dec 4, 2017, 7:07:48 PM12/4/17
to Ansible Project

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

Pshem Kowalczyk

unread,
Dec 4, 2017, 8:15:13 PM12/4/17
to ansible...@googlegroups.com
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


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b1b87d02-ac11-4fca-95ce-9cbd2ee59729%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages