forked from HewlettPackard/oneview-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oneview_fcoe_network.yml
113 lines (103 loc) · 3.62 KB
/
oneview_fcoe_network.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
###
# Copyright (2016-2020) 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.
###
---
- hosts: all
vars:
config: "{{ playbook_dir }}/oneview_config.json"
contents: "{{lookup('file', config)}}"
network_name: "Test FCoE Network"
network_scope_uris:
- '/rest/scopes/d0324c4b-56c9-485b-b7dd-8f6218a4b5bb'
- '/rest/scopes/9422ce05-dc39-4358-b723-c8c825eae412'
tasks:
- name: Get currentVersion from URL
oneview_version_facts:
config: "{{ config }}"
delegate_to: localhost
when: contents.api_version|length == 0
register: version
- name: Print currentVersion if an apiVersion is not specified in config file
set_fact:
currentVersion: "{{ version.ansible_facts.version.currentVersion|int }}"
when: contents.api_version|length == 0
- name: Print currentVersion if an apiVersion is specified in config file
set_fact:
currentVersion: contents.api_version | string
when: contents.api_version|length != 0
- name: Create a FCoE Network
oneview_fcoe_network:
config: "{{ config }}"
state: present
data:
name: '{{ item.name }}'
vlanId: '{{ item.vlanId }}'
delegate_to: localhost
register: fcoe_network1
with_items:
- { name: '{{ network_name }}', vlanId: '201' }
- { name: '{{ network_name }} (1)', vlanId: '202'}
- debug: var=fcoe_network1
- name: Do nothing with the FCoE Network when no changes are provided
oneview_fcoe_network:
config: "{{ config }}"
state: present
data:
name: 'Test FCoE Network'
vlanId: 201
delegate_to: localhost
- name: Update the FCoE Network changing the name attribute
oneview_fcoe_network:
config: "{{ config }}"
state: present
data:
name: 'Test FCoE Network'
newName: 'Test FCoE Network - Changed'
vlanId: 201
delegate_to: localhost
# Below task is supported only with OneView 3.10
- name: Update the FCoE Network with two scopes
oneview_fcoe_network:
config: "{{ config }}"
state: present
data:
name: 'Test FCoE Network - Changed'
scopeUris: "{{ network_scope_uris }}"
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost
- name: Delete the FCoE Network
oneview_fcoe_network:
config: "{{ config }}"
state: absent
data:
name: 'Test FCoE Network - Changed'
delegate_to: localhost
- name: Do nothing when FCoE Network is absent
oneview_fcoe_network:
config: "{{ config }}"
state: absent
data:
name: 'Test FCoE Network - Changed'
delegate_to: localhost
# This feature is available only from OneView 5.20
- name: Delete FCoE Networks in bulk
oneview_fcoe_network:
config: "{{ config }}"
state: absent
data:
networkUris:
- "{{ fcoe_network1.results[1].ansible_facts.fcoe_network.uri }}"
delegate_to: localhost
when: currentVersion >= '1600'