【发布时间】:2021-04-25 18:56:10
【问题描述】:
我正在使用以下 playbook 来检查从目标主机 192.168.153.31 到 8.8.8.8 的连接
---
- hosts: 192.168.153.31
gather_facts: no
tasks:
- name: Ping net1
shell: |
ping -c3 8.8.8.8 >/dev/null
if [ $? -eq 0 ]
then
echo "ok"
else
echo "nok"
fi
ignore_errors: true
register: output
- name: end playbook
meta: end_host
when: output.stdout == 'nok'
根据输出,我还有剩余的任务要执行。有没有更好的方法来验证连接性?
【问题讨论】:
标签: ansible