-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy patharubaoss_firmware_example.yml
105 lines (90 loc) · 4.6 KB
/
arubaoss_firmware_example.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
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This Workflow is an example for three different ways of upgrading your Switches and afterwards rebooting them. Remove all Possibilities you do not want.
# Every Possibility will only upload the Firmware if the desired state (upgrade/downgrade/stay) would be reached.
# Furthermore each Possibility returns a value which tells you if the firmware is uploaded and a reboot is possible
# For more documentation see the GitHub Wiki (Readme) or the appropriate Task/Module
#
# Possibility 1: This upgrades the Switch through a custom module which implements CLI via SSH.
# Possibility 2 and 3 are both able to Host a HTTP Server for you or use a hosted HTTP/HTTPS Server. This comes with a few limitations (see tasks for more information).
# Possibility 2: This upgrades the Switch only via the API. This needs a Switch with API Version 3 or higher (Version 16.04 or higher)
# Possibility 3: This upgrades the Switch through CLI (checking) and API (URL Upload). This can be used for any Switch Firmware version.
---
- hosts: localhost
connection: local
tasks:
# Store Global variables. These are also used by other plays in this playbook
- name: Store Global variables in localhost
block:
- set_fact:
site_data: "{{ hostvars[groups[site][0]] }}"
- set_fact:
sw_group_name: "{{ site_data.sw_group_name }}" # Group for the Switches
# This block will execute a set of different configurations via tasks
- hosts: "{{ hostvars.localhost.sw_group_name }}"
connection: local
# Include secrete to host HTTP Server
vars_files:
- vault/secret.yml
tasks:
- name: Firmware Upgrade Test
block:
# Possibility 1 - No Login Required for this Version
- name: Upgrade Firmware via SSH CLI
arubaos_switch_ssh_cli:
ip: "{{ ip }}"
user: "{{ user }}"
password: "{{ password }}"
# path_to_swi, boot_image and enable_sftp have to be given at once otherwise the module will fail.
path_to_swi: "../WC_16_04_0015.swi"
boot_image: "primary"
enable_sftp: True # If True is given, the system will enable ssh filetransfer and disable tftp | If False is given the system has to have ssh filetransfer enable otherwise the module will stop
state: "downgrade"
register: module_result
# Login to ArubaOS switches
- name: Login
include: aruba_task_lists/aos_switch/login_switch.yml
# Possibility 2 - Upgrade Firmware via API only for v3 or higher
- name: Upgrade Firmware
include: aruba_task_lists/aos_switch/firmware_upgrade_api_v3.yml
vars:
boot_image: "primary"
path_to_swi: "../WC_16_05_0007.swi"
state: "downgrade"
#swi_url: "http://10.6.7.11/WC_16_05_0007.swi"
# Possibility 3 - Upgrade Firmware via API + SSH for any API Version
- name: Upgrade Firmware
include: aruba_task_lists/aos_switch/firmware_upgrade.yml
vars:
boot_image: "primary"
path_to_swi: "../WC_16_06_0006.swi"
# swi_url: "http://10.6.7.11/WC_16_06_0006.swi"
# Reboot Switch only when Firmware was uploaded
- name: Reboot Switch via API
include: aruba_task_lists/aos_switch/reboot.yml
vars:
boot_image: "primary"
when: (upload_not_completed is defined and not upload_not_completed) or (module_result is defined and module_result['upload_not_completed'] is defined and not module_result['upload_not_completed'])
always:
# Logout from ArubaOS Switch
- debug:
msg: "Skipping logout because device is rebooting."
when: reboot_not_send is defined and not reboot_not_send
# Logout only when device is not rebooting (no logout needed on reboot)
- name: Logout
include: aruba_task_lists/aos_switch/logout_switch.yml
when: reboot_not_send is undefined or (reboot_not_send is defined and reboot_not_send)