-
Notifications
You must be signed in to change notification settings - Fork 25
/
arubaoss_tasks_config_example.yml
121 lines (105 loc) · 4.08 KB
/
arubaoss_tasks_config_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- 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.
# Example on how to use Ansible Aruba Task Lists to configure ArubaOS-Switches
---
- 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
gather_facts: no
tasks:
- name: Configure Switch
block:
# Login to ArubaOS switches
- name: Login
include: aruba_task_lists/aos_switch/login_switch.yml
# Configure ArubaOS switches using anycli rest option
- name: anycli configure
include: aruba_task_lists/aos_switch/anycli.yml command="{{item}}"
with_items:
- "configure terminal"
- "vlan 233"
# Variable uri_result contains the response from anycli task
- name: Use AnyCli - show vlans
include: aruba_task_lists/aos_switch/anycli.yml command="show vlans"
# Decode output from anycli task
- set_fact:
rest_cli_output: "{{uri_result.json.result_base64_encoded| b64decode}}"
# Check if newly created vlan 233 is in cli_output
- debug:
msg: "Vlan 233 was created"
when: rest_cli_output.find("233")
# Configure ArubaOS switches for DNS
- name: Set dns
include: aruba_task_lists/aos_switch/set_dns.yml
vars:
dns_ip1: "10.80.2.219"
dns_name1: "tmelab.net"
# Set SNMP server community
- name: Set SNMP server community
include: aruba_task_lists/aos_switch/create_snmp_community.yml
vars:
community: "Test123"
access_type: "manager"
restricted: False
# Set SNMP server hosts with community
- set_fact:
snmp_host:
host_ip: "10.3.7.5"
community: "Test123"
trap_level: "all" # accespt all/critical/debug/not_info/none
informs: True
use_oobm: True
- name: Set snmp hosts
include: aruba_task_lists/aos_switch/snmp_server_host.yml
vars:
host_data: "{{ snmp_host }}"
# Set Jumbo VLANs
- name: Set Jumbos VLANs
include: aruba_task_lists/aos_switch/set_jumbo.yml
vars:
vlan: "233"
# Configure SpanningTree Globally
- name: Configure SpanningTree Globally
include: aruba_task_lists/aos_switch/spanning_tree_global.yml
vars:
status: "disable" # or "enable"
priority: 8 # Number between 0 and 15
mode: "MSTP" # or "RPVST"
# Configure SpanningTree for port 5
- name: Configure SpanningTree for port
include: aruba_task_lists/aos_switch/spanning_tree_port.yml
vars:
port: "5" # String of port number or name
priority: 10 # Number between 0 and 15
admin_edge_port: True # or False
bpdu_protection: True # or False
bpdu_filter: True # or False
root_guard: True # or False
always:
# Logout from ArubaOS Switch
- name: Logout
include: aruba_task_lists/aos_switch/logout_switch.yml