2017-08-29 17:21:49 +02:00
|
|
|
---
|
2017-12-20 15:03:29 +01:00
|
|
|
- debug: msg="START cli/ping.yaml on connection={{ ansible_connection }}"
|
2017-08-29 17:21:49 +02:00
|
|
|
|
2017-10-25 12:44:25 +02:00
|
|
|
- ios_command:
|
|
|
|
commands: show version
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-10-25 12:44:25 +02:00
|
|
|
register: show_version_result
|
|
|
|
|
|
|
|
- set_fact: management_interface=GigabitEthernet0/0
|
|
|
|
when: "'Cisco IOS' in show_version_result.stdout[0]"
|
|
|
|
|
|
|
|
- set_fact: management_interface=GigabitEthernet1
|
|
|
|
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
|
|
|
|
|
|
|
|
- name: Get show ip management nterface output
|
2017-10-11 12:10:11 +02:00
|
|
|
ios_command:
|
|
|
|
commands:
|
2017-10-25 14:16:28 +02:00
|
|
|
- "show ip interface {{ management_interface }} | include Internet address"
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-10-11 12:10:11 +02:00
|
|
|
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] }}"
|
|
|
|
|
2017-08-29 17:21:49 +02:00
|
|
|
- name: expected successful ping
|
|
|
|
ios_ping: &valid_ip
|
2017-10-11 12:10:11 +02:00
|
|
|
dest: '{{ management_ip }}'
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-08-29 17:21:49 +02:00
|
|
|
register: esp
|
2017-10-11 12:28:10 +02:00
|
|
|
|
2017-08-29 17:21:49 +02:00
|
|
|
- name: unexpected unsuccessful ping
|
|
|
|
ios_ping: &invalid_ip
|
|
|
|
dest: '10.255.255.250'
|
2019-10-15 21:53:51 +02:00
|
|
|
timeout: 45
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-08-29 17:21:49 +02:00
|
|
|
register: uup
|
2017-10-11 12:10:11 +02:00
|
|
|
ignore_errors: yes
|
2017-08-29 17:21:49 +02:00
|
|
|
|
|
|
|
- name: unexpected successful ping
|
|
|
|
ios_ping:
|
|
|
|
<<: *valid_ip
|
|
|
|
state: 'absent'
|
|
|
|
register: usp
|
2017-10-11 12:10:11 +02:00
|
|
|
ignore_errors: yes
|
2017-08-29 17:21:49 +02:00
|
|
|
|
|
|
|
- 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
|