-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPingTest.yml
44 lines (37 loc) · 1.08 KB
/
PingTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- name: Ping sweep play
hosts: all
connection: local
vars_files:
- ./pinghosts.yml
tasks:
- name: Ping the hosts
tags: ping
eos_command:
commands:
- "ping {{ item }}"
with_items: "{{ pinghosts }}"
register: pingresult
- name: Get length of Ping Result output
tags: ping
set_fact:
totalpings: "{{ pingresult.results | length }}"
- name: Set Fact - Ping Result output length converted to integer
tags: ping
set_fact:
totalpingsint: "{{ totalpings | int - 1 }}"
- name: Create list of ping iterations
tags: ping
set_fact:
foo: "{{ foo | default([]) + [item | int] }}"
with_sequence: "start=0 end={{totalpingsint}} stride=1"
- name: Validate Ping Results
tags: ping
assert:
that:
- "'{{item.0}}' in pingresult.results[{{item.1}}].stdout[0]"
- "' 0% packet loss' in pingresult.results[{{item.1}}].stdout[0]"
fail_msg: "nope, not there"
with_together:
- "{{ pinghosts }}"
- "{{ foo }}"