-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcisco_autoqos_update.yml
executable file
·65 lines (55 loc) · 2.16 KB
/
cisco_autoqos_update.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
63
64
65
---
- name: UPDATE AUTO-QOS
hosts: switches
connection: network_cli
gather_facts: no
tasks:
- name: BACKING UP RUNNING CONFIG
ios_config:
backup: true
- name: FINDING ACCESS PORTS WITH Phone IN DESCRIPTION
ios_command:
commands:
- show interface description | include [Pp]hone
register: access_ports
- name: FINDING TRUNK PORTS. EXCLUDING MATCH Port-Channel PORTS
ios_command:
commands:
- show interface status | include ^[Fa|Gi|Te|Fo|Eth].*trunk # Excludes Port-channel interfaces
register: trunk_ports
- name: FINDING PORTS BELONGING TO A PORT CHANNEL
ios_command:
commands:
- show etherchannel port | include ^Port._ # Matches Port:
register: etherchannel_ports
- debug:
msg: '{{ item.split()[0] }}'
with_items: "{{ access_ports.stdout_lines[0] }}"
verbosity: 2
- name: ENSURING AUTO-QOS IS ON ACCESS PORTS
ios_config:
lines:
- auto qos trust dscp
parents: interface {{ item.split()[0] |
regex_replace('^Gi','GigabitEthernet') |
regex_replace('^Fa','FastEthernet') |
regex_replace('^Te','TenGigabitEthernet') |
regex_replace('^Fo','FortyGigabitEthernet') |
regex_replace('^Eth','Ethernet') }}
with_items: "{{ access_ports.stdout_lines[0] }}"
- name: ENSURING AUTO-QOS IS ON TRUNK PORTS. SKIPING PORTS BELONGING TO A PORT CHANNEL
ios_config:
lines:
- auto qos trust dscp
parents: interface {{ item.split()[0] |
regex_replace('^Gi','GigabitEthernet') |
regex_replace('^Fa','FastEthernet') |
regex_replace('^Te','TenGigabitEthernet') |
regex_replace('^Fo','FortyGigabitEthernet') |
regex_replace('^Eth','Ethernet') }}
when: 'item.split()[0] not in etherchannel_ports.stdout[0]'
with_items: "{{ trunk_ports.stdout_lines[0] }}"
- name: CHANGES MADE. SAVING CONFIG.
ios_config:
save_when: changed
...