用于测试ansible controller是否可以登录nodes及验证python是否可用的模块。
不是使用ICMP协议的ping, 如果想使用ICMP进行测试,可以使用net_ping模块。
data:
如果data里填写的crash,就会返回错误。
返回值:
成功就会返回‘pong‘
ping.yml
- name: ping test
hosts: test
gather_facts: no
tasks:
- name: ping
ping:
[root@ansible testenv]# ansible-playbook ping.yml
PLAY [ping test] ************************************************************************************************************************
TASK [ping] *****************************************************************************************************************************
ok: [ansible-1]
ok: [ansible-2]
PLAY RECAP ******************************************************************************************************************************
ansible-1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ansible-2 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Exception: boom
原文:https://www.cnblogs.com/felix-zong/p/14491825.html