mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
YAML
46 lines
1.0 KiB
YAML
---
|
|
- debug: msg="START cli/ping.yaml"
|
|
|
|
- name: Get show ip interface GigabitEthernet0/0 output
|
|
ios_command:
|
|
commands:
|
|
- show ip interface GigabitEthernet0/0 | include Internet address
|
|
authorize: yes
|
|
register: show_ip_interface_result
|
|
|
|
- name: Extract the IP address from registered output
|
|
set_fact: management_ip="{{ show_ip_interface_result.stdout[0].split()[-1].split('/')[0] }}"
|
|
|
|
- name: expected successful ping
|
|
ios_ping: &valid_ip
|
|
dest: '{{ management_ip }}'
|
|
authorize: yes
|
|
register: esp
|
|
|
|
- name: unexpected unsuccessful ping
|
|
ios_ping: &invalid_ip
|
|
dest: '10.255.255.250'
|
|
timeout: 45
|
|
authorize: yes
|
|
register: uup
|
|
ignore_errors: yes
|
|
|
|
- name: unexpected successful ping
|
|
ios_ping:
|
|
<<: *valid_ip
|
|
state: 'absent'
|
|
register: usp
|
|
ignore_errors: yes
|
|
|
|
- name: expected unsuccessful ping
|
|
ios_ping:
|
|
<<: *invalid_ip
|
|
state: 'absent'
|
|
register: eup
|
|
|
|
- name: assert
|
|
assert:
|
|
that:
|
|
- esp.failed == eup.failed == false
|
|
- usp.failed == uup.failed == true
|