-
Notifications
You must be signed in to change notification settings - Fork 25
/
arubaoss_module_config_example.yml
160 lines (144 loc) · 4.92 KB
/
arubaoss_module_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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- 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 Aruba Switching Ansible Modules to configure ArubaOS-Switches in this Project setup
#
# Use via:
# ansible-playbook aoss_module_config_example.yml -e site=branch1 -e state=STATUS
#
# Repleace STATUS with "configure" to configure the switch and "unconfigure" to undo configuration done by the configuration part
#
---
- 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: False
# This will set the needed overall variables for the modules to use the connection plugin.
# Normally these could be stored in the inventory but we are "migrating" them to keep a similar inventory structure for all workflows.
vars:
ansible_user: "{{ user }}"
ansible_password: "{{ password }}"
ansible_host: "{{ ip }}"
ansible_network_os: arubaoss
tasks:
# Configure Switch with modules
- block:
- name: Updates Hostname
arubaoss_system_attributes:
hostname: "automation_2930M_1"
use_ssl: True
- name: Configure a vlan
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: create
command: config_vlan
use_ssl: True
- name: change loop-protect mode to vlan
arubaoss_loop_protect:
command: update
mode: LPM_VLAN
use_ssl: True
- name: enable loop-prtoect on vlan
arubaoss_loop_protect:
command: update_vlan
vlan: 42
use_ssl: True
- name: update vlan with ports
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: create
command: config_vlan_port
port_id: "1"
port_mode: "POM_TAGGED_STATIC"
use_ssl: True
- name: update vlan with ip address
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: create
command: config_vlan_ipaddress
vlan_ip_address: "172.20.20.1"
version: "IAV_IP_V4"
vlan_ip_mask: "255.255.255.0"
use_ssl: True
- name: update vlan with dhcp helper address
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: create
command: config_vlan_dhcpHelperAddress
helper_addresses: "172.20.20.100"
version: "IAV_IP_V4"
use_ssl: True
when: state == "configure"
# Unconfigure Switch with modules
- block:
- name: change loop-protect mode to default
arubaoss_loop_protect:
command: update
use_ssl: True
- name: delete port from vlan
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: delete
command: config_vlan_port
port_id: "1"
port_mode: "POM_TAGGED_STATIC"
use_ssl: True
- name: delete vlan ip address
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: delete
command: config_vlan_ipaddress
vlan_ip_address: "172.20.20.1"
version: "IAV_IP_V4"
vlan_ip_mask: "255.255.255.0"
use_ssl: True
- name: delete vlan dhcp helper address
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: delete
command: config_vlan_dhcpHelperAddress
helper_addresses: "172.20.20.100"
version: "IAV_IP_V4"
use_ssl: True
- name: delete vlan
arubaoss_vlan:
vlan_id: 42
name: "vlan42"
config: delete
command: config_vlan
use_ssl: True
- name: Updates Hostname to old hostname
arubaoss_system_attributes:
hostname: "branch1_2930M"
use_ssl: True
when: state == "unconfigure"