Playbook: icmp - Helmigreg/ant GitHub Wiki
Technical Documentation: ICMP Ping Playbook
Overview
This Ansible playbook is used to execute ICMP ping tests against specified destination IP addresses or hostnames from the group of machines defined under the icmp
inventory group. It is typically used in automated network test setups, such as in the ANT (Automated NFT Testing) framework, to verify reachability between machines.
The playbook leverages the built-in Ansible shell
module to execute the ping
command on remote hosts and prints out the results.
Structure
Hosts
- icmp: This playbook runs against all hosts listed under the
icmp
group in the Ansible inventory file.
Playbook Tasks
1. Run the ping script
- Module:
ansible.builtin.shell
- Command:
ping -c 4 {{ item }}
- Loop: Iterates over the list defined by the
destination
variable, which should be a list of IP addresses or hostnames to ping. - Register: The results of all ping commands are saved in the
ping_result
variable.
2. Print result
- Module:
debug
- Variable: Prints the contents of
ping_result.results
, which contains the result of eachping
command executed.
Dependencies
- Ansible: This playbook must be run in an environment where Ansible is installed.
- ICMP Permissions: The remote hosts must have permission to execute
ping
, which may require elevated privileges depending on the system configuration. - Inventory: A valid inventory file with a host group named
icmp
.
Example Inventory Snippet
icmp:
hosts:
test-vm-1:
ansible_host: 192.168.1.10
ansible_user: testuser
ansible_password: testpass