-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcisco_tdd.yml
62 lines (51 loc) · 1.87 KB
/
cisco_tdd.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
- name: Run traceroute commands
hosts: cisco-devices
gather_facts: false
remote_user: cisco
vars_prompt:
- name: scenario_num
prompt: "Enter scenario number"
default: "1"
private: no
tasks:
- name: extracting scenario name and steps
set_fact:
scenario_steps: "{{ scenarios[scenario_num][1] }}"
scenario_name: "{{ scenarios[scenario_num][0] }}"
# - name: debug hostvars
# when: inventory_hostname == "R1"
# debug: var=scenario_steps[inventory_hostname]
#
# - name: debug hostvars
# when: inventory_hostname == "R1"
# debug: var=scenario_name
- name: run traceroutes as per the defined scenario steps
raw: traceroute {{ hostvars[item.key]['ansible_ssh_host'] }} source Loopback0 probe 1 numeric
when: scenario_steps[inventory_hostname] is defined
with_dict: scenario_steps[inventory_hostname]|default({})
register: trace_result
- name: parse traceroute ouput
cisco_trace_parse:
dest_host: "{{ item.item.key }}"
std_out: "{{ item.stdout }}"
connection: local
when: item.stdout is defined
with_items: trace_result.results
# - name: debug hostvars
# debug: var=hostvars[inventory_hostname]
- name: verify traceroutes against pre-defined scenarios
cisco_tdd_verify:
dest_host: "{{ item.key }}"
src_host: "{{ inventory_hostname }}"
scenario: "{{ scenario_steps }}"
ip2host: "{{ ip2host }}"
path: "{{ hostvars[inventory_hostname][item.key] }}"
scenario_name: "{{ scenario_name }}"
when: scenario_steps[inventory_hostname] is defined
with_dict: scenario_steps[inventory_hostname]|default({})
connection: local
# - name: debug hostvars
# debug: var=hostvars[inventory_hostname]
tags:
- run