forked from brocade/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zoning_migrate.yml
82 lines (70 loc) · 3.32 KB
/
zoning_migrate.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
---
# Copyright 2019 Broadcom. All rights reserved.
# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries.
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This playbook reads the current zone database from a FOS switch and using the facts
# collected to apply to another FOS switch. f_credential contains ip address, login, and
# connection type for "from FOS" switch. t_credential contains ip address, login, and
# connection type for "to FOS" switch. Migrating will be additive to the "to FOS" switch.
# i.e. Existing aliases, zones and aliases will remain and NOT be deleted. However,
# overlapping aliases, zone, and alises will be overwritten by the "from FOS" copy and
# "from FOS" active cfg will be activated.
#
# Below is san-inventory entry example:
#
# zone_migration_app ansible_connection=local f_fos_ip_addr=10.10.10.10 f_fos_user_name=admin f_fos_password=frompassword f_fos_https=False t_fos_ip_addr=10.10.10.12 t_fos_user_name=admin t_fos_password=topassword t_fos_https=False
- hosts: zone_migration_app
gather_facts: False
vars:
f_credential:
fos_ip_addr: "{{f_fos_ip_addr}}"
fos_user_name: "{{f_fos_user_name}}"
fos_password: "{{f_fos_password}}"
https: "{{f_fos_https}}"
t_credential:
fos_ip_addr: "{{t_fos_ip_addr}}"
fos_user_name: "{{t_fos_user_name}}"
fos_password: "{{t_fos_password}}"
https: "{{t_fos_https}}"
tasks:
- name: gather facts from "from FOS" using f_credential
brocade_facts:
credential: "{{f_credential}}"
vfid: -1
gather_subset:
- brocade_zoning_simple
- name: print ansible_facts gathered
debug:
var: ansible_facts['brocade_zoning_simple']
- name: Create aliases to "to FOS" using t_credential
brocade_zoning_alias:
credential: "{{t_credential}}"
vfid: -1
aliases: "{{ansible_facts['brocade_zoning_simple']['defined-configuration']['aliases']}}"
when: ansible_facts['brocade_zoning_simple']['defined-configuration']['aliases'] | length > 0
- name: Create zones to "to FOS" using t_credential
brocade_zoning_zone:
credential: "{{t_credential}}"
vfid: -1
zones: "{{ansible_facts['brocade_zoning_simple']['defined-configuration']['zones']}}"
when: ansible_facts['brocade_zoning_simple']['defined-configuration']['zones'] | length > 0
- name: Create cfgs to "to FOS" using t_credential
brocade_zoning_cfg:
credential: "{{t_credential}}"
vfid: -1
cfgs: "{{ansible_facts['brocade_zoning_simple']['defined-configuration']['cfgs']}}"
# active_cfg: "{{ansible_facts['brocade_zoning_simple']['effective-configuration']['cfg_name']}}"
when: ansible_facts['brocade_zoning_simple']['defined-configuration']['cfgs'] | length > 0
- name: Enable active cfg on "to FOS" using t_credential
brocade_zoning_cfg:
credential: "{{t_credential}}"
vfid: -1
cfgs: "{{ansible_facts['brocade_zoning_simple']['defined-configuration']['cfgs']}}"
active_cfg: "{{ansible_facts['brocade_zoning_simple']['effective-configuration']['cfg_name']}}"
when: "'cfg_name' in ansible_facts['brocade_zoning_simple']['effective-configuration']"
# - name: Default zoning
# brocade_zoning_default_zone:
# credential: "{{t_credential}}"
# vfid: -1
# default_zone_access: allaccess