As far as I know the documentation there is no filter regex_match, at least as of v2.9 and later.
it should come as false
but I dont know why it is coming true
Since a simple test construct
var:
DeviceName: "switch.example.com"
- name: Valdiate device name
set_fact:
switchname: "{{'false' if DeviceName | regex_search('switch') else 'true'}}"
delivers true
for a switch
and false
for a server
it seems to be your regular expression.
After I've found Use Jinja match filter instead of regex_match
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead
of using result|match
use result is match
. This feature will be
removed in version 2.9.
I've tested with
var:
DeviceName: "switch.example.com"
- name: Valdiate device name
set_fact:
switchname: "{{ DeviceName is match ('server*') }}"
and found it also working properly. As of Ansible 2.9 this should be the preferred solution.