-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcisco_vty_acl.yml
More file actions
executable file
·57 lines (48 loc) · 1.5 KB
/
Copy pathcisco_vty_acl.yml
File metadata and controls
executable file
·57 lines (48 loc) · 1.5 KB
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
---
- name: CORRECT VTY-ACL ON CISCO DEVICES
hosts: all
connection: network_cli
gather_facts: no
tasks:
- name: SAVE RUNNING-CONFIG TO NVRAM FOR RECOVERY IF NEEDED
ios_config:
save_when: always
- name: Set the task_status var
set_fact:
task_status: "OK"
- block:
- name: UPDATE VTY-ACL ACCESS LIST
ios_config:
parents: ip access-list extended VTY-ACL
lines:
- permit tcp 192.168.0.0 0.0.255.255 any eq 22
- permit tcp 10.0.0.0 0.255.255.255 any eq 22 log-input
- deny ip any any log-input
match: exact
replace: block
before:
- line vty 0 15
- NO access-class VTY-ACL in
- NO ip access-list extended VTY-ACL
after:
- line vty 0 15
- access-class VTY-ACL in
- name: CHECK IF SSH IS STILL ACCESSIABLE FROM NETWORK
wait_for:
host: "{{ inventory_hostname }}"
port: 22
state: started
delay: 2
timeout: 6
ignore_errors: no
- name: SSH TEST SUCCESSFUL. SAVING RUNNING-CONFIG
ios_config:
save_when: always
rescue:
- name: UPDATE FAILED. ROLLING BACK CONFIG
ios_command:
commands:
- configure replace nvram:startup-config force
- set_fact:
task_status: "ERROR"
when: task_status == 'OK'