我正在尝试验证通过dig完成的查找结果,但是收到错误。
有人可以帮助我吗?
- name: Simple A record (IPV4 address) lookup for {{ kubeapi_server }}
debug: msg="{{ lookup('dig', '{{ kubeapi_server }}' )}}"
- debug:
msg:
- "DNS A Record for {{ lookup('dig', '{{ kubeapi_server }}' )}}"
failed_when: msg.stdout != ""
输出
TASK [0_test : debug] ******************************************************
fatal: [target1]: FAILED! => {"msg": "The conditional check 'msg.stdout != ""' failed. The error was: error while evaluating conditional (msg.stdout != ""): 'msg' is undefined"}
简单地将整个查找分配给变量,然后==以查看其是否为空来解决它。
- name: Validate DNS record lookup for {{ kubeapi_server }}
debug: msg="{{ lookup('dig', '{{ kubeapi_server }}' )}}"
vars:
variable: "{{ lookup('dig', '{{ kubeapi_server }}' )}}"
failed_when: variable == ''
```