我只想 ping 一个主机(DNS 主机)来检查可达性。看起来没有正确的方法可以做到这一点?我不确定。下面是我的 net_ping
---
- name: Set User
hosts: web_servers
gather_facts: false
become: false
vars:
ansible_network_os: linux
tasks:
- name: Pinging Host
net_ping
dest: 10.250.30.11
但是,
TASK [Pinging Host] *******************************************************************************************************************
task path: /home/veeru/PycharmProjects/Miscellaneous/tests/ping_test.yml:10
ok: [10.250.30.11] => {
"changed": false,
"msg": "Could not find implementation module net_ping for linux"
}
带ping
模块
---
- name: Set User
hosts: dns
gather_facts: false
become: false
tasks:
- name: Pinging Host
action: ping
看起来它正在尝试 ssh 进入 IP。(在详细模式下检查)。我不知道为什么?如何进行 ICMP ping?我也不想将 DNS IP 放入库存中。
更新1:
hmm,ansible_network_os
中似乎不支持 linux
。
https://www.reddit.com/r/ansible/comments/9dn5ff/possible_values_for_ansible_network_os/
最佳答案
您可以使用 ping 命令:
---
- hosts: all
gather_facts: False
connection: local
tasks:
- name: ping
shell: ping -c 1 -w 2 8.8.8.8
ignore_errors: true
关于ansible - 在 ansible playbook 中 Ping 主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56054563/