I have a simple playbook:
---
- name: cat resolv.conf
telnet:
user: "{{ foxuser }}"
password: "{{ foxpass }}"
login_prompt: "login:"
prompts: "#"
command:
- grep 192.168.178.6 /etc/resolv.conf
register: resolv
changed_when: not( resolv.output | join('') | search('nameserver'))
notify: update resolv.conf
This works, but it throws a deprecation warning;
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|search` use `result is search`. This feature will be removed in version 2.9.
I tried:
changed_when: not('nameserver' in resolv.output )
but that always seems to be true, even when nameserver
is in resolv.output
. Somehow, the join
seems an essential part of the expression.
Note that resolv
contains:
"resolv": {
"changed": false,
"failed": false,
"output": [
" grep 192.168.178.6 /etc/resolv.conf\r\nnameserver 192.168.178.6\r\n[root@foxboard /root]1068#"
]
}
I cannot seem to find a working solution without the filter. What am I missing?
I believe this should work (simulated test does for me):
- name: cat resolv.conf
telnet:
user: "{{ foxuser }}"
password: "{{ foxpass }}"
login_prompt: "login:"
prompts: "#"
command:
- grep 192.168.178.6 /etc/resolv.conf
register: resolv
changed_when: not ( resolv.output | join('') ) is search('nameserver')
notify: update resolv.conf
Using the search function as part of a filter appears to be what triggers the deprecation warning.