forked from ksator/openconfig-demo-with-juniper-devices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pb.check.L2.L3.yml
47 lines (41 loc) · 1.45 KB
/
pb.check.L2.L3.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
---
- name: L2 and L3 checks
hosts: Openconfig_Routers
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: check if lldp neighbors are the ones we expect
junos_command:
provider: "{{ credentials }}"
commands:
- show lldp neighbors interface "{{ item.interface }}"
display: 'xml'
waitfor:
- "result[0]['rpc-reply']['lldp-neighbors-information']['lldp-neighbor-information']['lldp-remote-system-name'] == {{ item.neighbor }}"
retries: 5
interval: 2
with_items:
- "{{ topology }}"
when: ansible_version['major'] == 2 and ansible_version['minor']|int >= 4
- name: check if junos devices can ping ip of their neighbors (directly connected)
junos_ping:
host: "{{ junos_host }}"
user: "{{ ADMUSER }}"
passwd: "{{ ADMPASS }}"
dest_ip: "{{ item.address }}"
source_ip: "{{ item.local_address }}"
ttl: 1
with_items:
- "{{ bgp_neighbors }}"
- name: Send Slack notification to the team
local_action:
module: slack
#http://docs.ansible.com/ansible/slack_module.html
username: "Ansible on {{ inventory_hostname }}"
channel: openconfig
token: T2MBN64JX/B2N0Z2MEU/1OoB46XLX6Q1oFf89Xl2X9gq
icon_url: "https://www.ansible.com/hs-fs/hub/330046/file-448313641-png/favicon.png"
msg: "check completed using pb.check.L2.L3.yml"
validate_certs: false