📜  ping madule for ansible - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:45:30.385000             🧑  作者: Mango

Ping Module for Ansible - Shell-Bash

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.

Usage

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.

Parameters

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).
Examples

Here are some examples of how to use the Ping module in Ansible:

Ping a single host
- name: Ping a remote host
  ping:
    host: 192.168.1.1
Ping multiple hosts
- name: Ping multiple hosts
  ping:
    host: "{{ item }}"
  with_items:
    - 192.168.1.1
    - 192.168.1.2
    - 192.168.1.3
Include additional data in the ping packet
- name: Ping a remote host with additional data
  ping:
    host: 192.168.1.1
    data: "hello world"
Conclusion

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.