-
Notifications
You must be signed in to change notification settings - Fork 0
/
reload-ios-update.yml
105 lines (92 loc) · 2.39 KB
/
reload-ios-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
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
---
##
## sample playbook to reload device after update
## references:
## https://www.linkedin.com/pulse/upgrading-71-cisco-switches-unattended-using-ansible-craig-armstrong/
## https://gist.github.com/craigarms/d553afcc189b142447c128dfc88d286c
##
- hosts: sw_ios
gather_facts: false
vars:
models:
"WS-C2960XR-48FPD-I":
ios_version: "15.2(7)E0a"
ios_path: "IOS/"
ios_archive: "c2960x-universalk9-tar.152-7.E0a.tar"
ios_binary: "c2960x-universalk9-mz.152-7.E0a.bin"
ios_md5: "07195a8c7866ac2a91c64b716465c516"
ios_size_kb: 37489
tasks:
- name: Wait until the lock file is removed
wait_for:
path: playbooks/file.lock
state: absent
tags:
- lock
- name: Email start of process on switch Name
mail:
subject: Reloading {{ inventory_hostname }}
host: my.smtp.local
port: 25
to:
from: [email protected]
delegate_to: localhost
tags:
- email
- reload
- name: Create Lock File
file:
path: playbooks/file.lock
state: touch
tags:
- reload
- lock
- name: Reload Switch
ios_command:
commands:
- command: "reload"
prompt: "Proceed with reload? [confirm]"
answer: '\r'
tags:
- reload
- name: Wait for the switch to return
wait_for:
host: "{{ ansible_host }}"
port: 22
delay: 180
timeout: 600
delegate_to: localhost
tags:
- reload
- check_online
- name: Email switch name back online
mail:
subject: Back Online {{ inventory_hostname }}
host: my.smtp.local
port: 25
to:
from: [email protected]
delegate_to: localhost
tags:
- email
- reload
- name: Gather all legacy facts
ios_facts:
gather_subset: hardware
tags:
- facts
- name: Asset that the IOS version is the correct one
assert:
that:
- ansible_net_version = models[ansible_net_model]["ios_version"]
tags:
- facts
- name: Delete Lock File
file:
path: playbooks/file.lock
state: absent
tags:
- reload
- lock