📅  最后修改于: 2023-12-03 14:45:30.385000             🧑  作者: Mango
The Ping module for Ansible allows you to test connectivity to a remote system using the ICMP protocol (ping). This is a simple way to check if a host is online or not. The Ping module is written in Shell-Bash and is included in Ansible by default.
To use the Ping module, simply include it in your Ansible playbook like this:
- name: Ping a remote host
ping:
host: 192.168.1.1
This will ping the host 192.168.1.1
and return a success message if the host responds.
The Ping module supports the following parameters:
host
(required): The IP address or hostname of the remote host to ping.data
(optional): Additional data to include in the ping packet.count
(optional): The number of ping requests to make (default: 5).timeout
(optional): The amount of time to wait for each ping response (default: 1 second).validate_certs
(optional): Whether to validate SSL/TLS certificates for HTTPS-based pings (default: true).Here are some examples of how to use the Ping module in Ansible:
- name: Ping a remote host
ping:
host: 192.168.1.1
- name: Ping multiple hosts
ping:
host: "{{ item }}"
with_items:
- 192.168.1.1
- 192.168.1.2
- 192.168.1.3
- name: Ping a remote host with additional data
ping:
host: 192.168.1.1
data: "hello world"
The Ping module for Ansible is a simple way to test connectivity to remote hosts using the ICMP protocol. It's easy to use and provides a useful way to check if a host is online or not.