首页 > 其他 > 详细

第一个playbook, ansible ping 模块。

时间:2021-03-06 23:56:13      阅读:197      评论:0      收藏:0      [点我收藏+]

用处:

用于测试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
如果data参数里是crash,则返回以下,如果是其他字符,测试和没有一样。
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Exception: boom

第一个playbook, ansible ping 模块。

原文:https://www.cnblogs.com/felix-zong/p/14491825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!