Hello All,
Anybody can help for the below error. My system was patched recently and ansible version has been upgraded to 2.9.
After that my playbook started to throw below error.:
Hello All,
Anybody can help for the below error. My system was patched recently and ansible version has been upgraded to 2.9.
After that my playbook started to throw below error.:
match
is not a filter, it is what is called a test
. Ansible 2.5 deprecated the syntax to use a test
like a filter
. See https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.5.html#jinja-tests-used-as-filters
This should have been generating a deprecation warning since the 2.5 release. In any case, the most simple fix is just to replace |match
with is match
.
There are 2 problems
1) "match" is a test. See "Testing strings"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings
2) Use "lookup" and "vars" plugin to get value of dynamically created
variable's name. See "vars – Lookup templated value of variables"
https://docs.ansible.com/ansible/latest/plugins/lookup/vars.html#vars-lookup-templated-value-of-variables
For example
- set_fact:
Detrio_has_backup_nic: true
vars:
my_nic: "{{ lookup('vars', 'ansible_' ~ Detrio_backup_nic) }}
when:
- my_nic.ipv4.network is match(Detrio_backup_network)
- _has_backup_nic is undefined
- Detrio_backup_nic is defined
HTH,
-vlado