-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw_config.yml
105 lines (88 loc) · 2.55 KB
/
sw_config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
- name: Configuring switches
hosts: switches
gather_facts: false
tasks:
- name: Set Logging synchronous for line vty
ios_config:
lines:
- logging synchronous
parents: line vty 0 4
tags: console
- name: run 'show vlans' prior executing commands
ios_command:
commands: show vlan brief
register: myvlans
tags: shvlans
- name: display value of "myvlans" variable
ansible.builtin.debug:
var: myvlans["stdout_lines"][0]
tags: shvlans
- name: Configure switch VLANs
cisco.ios.ios_vlans:
config:
- name: "{{ item.name }}"
vlan_id: "{{ item.id }}"
state: active
shutdown: disabled
loop: "{{ vlans }}"
tags: vlans
- name: Turn on interfaces
ios_interfaces:
config:
- name: "{{ item.name }}"
description: "{{ item.description }}"
enabled: false
state: merged
loop: "{{ interfaces }}"
tags: enableintf
- name: Configuring trunks
cisco.ios.ios_l2_interfaces:
config:
- name: "{{ item.name }}"
mode: trunk
trunk:
allowed_vlans: 10-20,40
native_vlan: "{{ item.native }}"
# pruning_vlans: 10,20
encapsulation: "{{ item.encap }}"
state: merged
loop: "{{ interfaces }}"
when: "item.mode is defined and item.mode == 'trunk'"
loop_control:
label: "{{ item.name }}"
tags: trunks
- name: Configuring access ports
cisco.ios.ios_l2_interfaces:
config:
- name: "{{ item.name }}"
mode: access
access:
vlan: "{{ item.access_vlan }}"
voice:
vlan: "{{ item.voice_vlan }}"
state: merged
loop: "{{ interfaces }}"
loop_control:
label: "{{ item.name }}"
when: "item.mode is defined and item.mode == 'access'"
tags: access
- name: run 'show vlans' after changes
ios_command:
commands: show vlan brief
register: myvlans
tags: shvlans
- name: display value of "myvlans" variable
ansible.builtin.debug:
var: myvlans["stdout_lines"][0]
tags: shvlans
- name: run 'show int trunk' trunk
ios_command:
commands: show interfaces trunk
register: mytrunks
tags: shtrunks
- name: display value of "mytrunks" variable
ansible.builtin.debug:
var: mytrunks["stdout_lines"][0]
tags: shtrunks
...