-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollback.pb.yml
More file actions
55 lines (51 loc) · 1.45 KB
/
Copy pathrollback.pb.yml
File metadata and controls
55 lines (51 loc) · 1.45 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
---
- name: Rollback Junos software to previous version
hosts: all
serial: 1
roles:
- Juniper.junos
connection: local
gather_facts: no
vars:
netconf_port: 830
wait_time: 3600
log_dir: "./"
tasks:
- name: request system software rollback
juniper_junos_rpc:
host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
rpc: request-package-rollback
port: "{{ netconf_port }}"
timeout: 60
logdir: "{{ log_dir }}"
register: juniper_junos_rpc_result
- debug:
var: juniper_junos_rpc_result['parsed_output']
- name: request system reboot
juniper_junos_system:
host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
action: "reboot"
port: "{{ netconf_port }}"
timeout: 60
logdir: "{{ log_dir }}"
register: result
notify:
- update_user
- pause_for_reboot
- wait_reboot
- debug:
var: result
handlers:
- name: update_user
debug:
msg: "Junos software successfully rolled back for device {{ inventory_hostname }}. Rebooted and waiting for device to come back online..."
- name: pause_for_reboot
pause:
seconds: 120
when: result.reboot
- name: wait_reboot
wait_for:
host: "{{ ansible_host }}"
port: "{{ netconf_port }}"
timeout: "{{ wait_time }}"
when: result.reboot