Skip to content

Commit

Permalink
Roles and example playbooks to create MSD fabric and add fabrics to it
Browse files Browse the repository at this point in the history
  • Loading branch information
allenrobel committed May 4, 2022
1 parent adc5300 commit b65c0ad
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 0 deletions.
18 changes: 18 additions & 0 deletions example_ndfc_rest_fabric_msd_add.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# example_ndfc_rest_fabric_msd_add.yml
# Adds add_fabric (f1 and f2) as a children of msd_fabric (MSD)
---
- hosts: ndfc
gather_facts: false
roles:
- ndfc_rest_fabric_msd_add
vars:
msd_fabric: MSD
add_fabric: f1

- hosts: ndfc
gather_facts: false
roles:
- ndfc_rest_fabric_msd_add
vars:
msd_fabric: MSD
add_fabric: f2
8 changes: 8 additions & 0 deletions example_ndfc_rest_fabric_msd_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# example_ndfc_rest_fabric_msd_create.yml
---
- hosts: ndfc
gather_facts: false
roles:
- ndfc_rest_fabric_msd_create
vars:
fabric_name: MSD
38 changes: 38 additions & 0 deletions roles/ndfc_rest_fabric_msd_add/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ndfc_fabric_create_msd_rest

Create Multi-Site Domain (MSD) fabric ``fabric_name``

### Role Variables

Variable | Type | Description
----------------|-------|----------------------------------------
fabric_name | str() | The fabric to be created

Fabric parameters, including ``fabric_name`, are defined in the following file:

``./roles/ndfc_common/vars/main.yml``)

See the following for details:

[./roles/ndfc_common/README.md](https://github.com/allenrobel/ndfc-roles/tree/master/roles/ndfc_common/README.md)


### Example Playbook

```yaml
---
- hosts: ndfc
gather_facts: false
roles:
- ndfc_fabric_create_msd_rest
vars:
fabric_name: MSD
```
### License
BSD
### Author Information
Allen Robel (@packetcalc)
11 changes: 11 additions & 0 deletions roles/ndfc_rest_fabric_msd_add/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
galaxy_info:
author: Allen Robel
description: Principal Engineer
company: Cisco Systems, Inc.
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
galaxy_tags:
- ndfc
- cisco
dependencies:
- ndfc_common
36 changes: 36 additions & 0 deletions roles/ndfc_rest_fabric_msd_add/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ndfc_rest_fabric_msd_add/tasks/main.yml
---
- name: main REST GET fabrics
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics"
register: result
- name: main set_fact active_fabrics
set_fact:
active_fabrics: "{{ result.response.DATA | json_query(qm1) | to_json }}"
vars:
qm1: "[*].{FabricName: fabricName}"

# query fabric-associations for add_fabric's fabric_parent
- name: main REST GET fabric_associations
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations/"
register: result
- name: main set_fact fabric_parent
set_fact:
fabric_parent: "{{ result.response.DATA | json_query(qm2) }}"
vars:
qm2: "[?fabricName == '{{ add_fabric }}'].{fabricParent: fabricParent}"

# Add add_fabric to msd_fabric if add_fabric's fabric_parent != None and both msd_fabric and add_fabric exists
- name: main REST POST msdAdd MSD_FABRIC {{ msd_fabric }} ADD_FABRIC {{ add_fabric }} FABRIC_PARENT {{ fabric_parent[0].fabricParent }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd"
json_data: "{{ vars_dict | to_json }}"
when: "msd_fabric in active_fabrics and add_fabric in active_fabrics and fabric_parent[0].fabricParent == 'None'"
vars:
vars_dict:
destFabric: "{{ msd_fabric }}"
sourceFabric: "{{ add_fabric }}"
38 changes: 38 additions & 0 deletions roles/ndfc_rest_fabric_msd_create/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ndfc_fabric_create_msd_rest

Create Multi-Site Domain (MSD) fabric ``fabric_name``

### Role Variables

Variable | Type | Description
----------------|-------|----------------------------------------
fabric_name | str() | The fabric to be created

Fabric parameters, including ``fabric_name`, are defined in the following file:

``./roles/ndfc_common/vars/main.yml``)

See the following for details:

[./roles/ndfc_common/README.md](https://github.com/allenrobel/ndfc-roles/tree/master/roles/ndfc_common/README.md)


### Example Playbook

```yaml
---
- hosts: ndfc
gather_facts: false
roles:
- ndfc_fabric_create_msd_rest
vars:
fabric_name: MSD
```
### License
BSD
### Author Information
Allen Robel (@packetcalc)
11 changes: 11 additions & 0 deletions roles/ndfc_rest_fabric_msd_create/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
galaxy_info:
author: Allen Robel
description: Principal Engineer
company: Cisco Systems, Inc.
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
galaxy_tags:
- ndfc
- cisco
dependencies:
- ndfc_common
80 changes: 80 additions & 0 deletions roles/ndfc_rest_fabric_msd_create/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ndfc_rest_fabric_msd_create/tasks/main.yml
---
- name: main REST GET fabrics
cisco.dcnm.dcnm_rest:
method: GET
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics"
register: result
- name: main set_fact active_fabrics
set_fact:
active_fabrics: "{{ result.response.DATA | json_query(query) | to_json }}"
vars:
query: "[*].{FabricName: fabricName}"
# TODO: add relevant user-configurable parameters to common_vars and update the
# below accordingly.
# - name: main set_fact FABRIC {{ fabric_name }}
# set_fact:
# BGP_AS: "{{ fabrics | json_query(q1) }}"
# ANYCAST_RP_IP_RANGE: "{{ fabrics | json_query(q2) }}"
# LOOPBACK0_IP_RANGE: "{{ fabrics | json_query(q3) }}"
# LOOPBACK1_IP_RANGE: "{{ fabrics | json_query(q4) }}"
# SUBNET_RANGE: "{{ fabrics | json_query(q5) }}"
# FABRIC_MTU: "{{ fabrics | json_query(q6) }}"
# REPLICATION_MODE: "{{ fabrics | json_query(q7) }}"
# vars:
# q1: "[?name == '{{ fabric_name }}'].BGP_AS | [0]"
# q2: "[?name == '{{ fabric_name }}'].ANYCAST_RP_IP_RANGE | [0]"
# q3: "[?name == '{{ fabric_name }}'].LOOPBACK0_IP_RANGE | [0]"
# q4: "[?name == '{{ fabric_name }}'].LOOPBACK1_IP_RANGE | [0]"
# q5: "[?name == '{{ fabric_name }}'].SUBNET_RANGE | [0]"
# q6: "[?name == '{{ fabric_name }}'].FABRIC_MTU | [0]"
# q7: "[?name == '{{ fabric_name }}'].REPLICATION_MODE | [0]"

- name: main REST POST MSD FABRIC {{ fabric_name }} ACTIVE_FABRICS {{ active_fabrics }}
cisco.dcnm.dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/"
json_data: "{{ vars_dict | to_json }}"
when: "fabric_name not in active_fabrics"
vars:
vars_dict:
fabricName: "{{ fabric_name }}"
templateName: "MSD_Fabric"
nvPairs:
FABRIC_NAME: "{{ fabric_name }}"
L2_SEGMENT_ID_RANGE: "30000-49000"
L3_PARTITION_ID_RANGE: "50000-59000"
default_vrf: "Default_VRF_Universal"
default_network: "Default_Network_Universal"
vrf_extension_template: "Default_VRF_Extension_Universal"
network_extension_template: "Default_Network_Extension_Universal"
ANYCAST_GW_MAC: 2020.0000.00aa
MS_LOOPBACK_ID: 100
TOR_AUTO_DEPLOY: false
FABRIC_TYPE: MFD
FF: MSD
MSO_CONTROLER_ID: ""
MSO_SITE_GROUP_NAME: ""
PREMSO_PARENT_FABRIC: ""
DCNM_ID: ""
MS_IFC_BGP_PASSWORD_ENABLE_PREV: ""
MS_IFC_BGP_AUTH_KEY_TYPE_PREV: ""
MS_IFC_BGP_PASSWORD_PREV: ""
BORDER_GWY_CONNECTIONS: "Direct_To_BGWS"
RP_SERVER_IP: ""
BGP_RP_ASN: ""
MS_UNDERLAY_AUTOCONFIG: false
DELAY_RESTORE: 300
CLOUDSEC_AUTOCONFIG: false
CLOUDSEC_KEY_STRING: ""
CLOUDSEC_ALGORITHM: ""
CLOUDSEC_ENFORCEMENT: ""
CLOUDSEC_REPORT_TIMER: ""
MS_IFC_BGP_PASSWORD_ENABLE: false
MS_IFC_BGP_PASSWORD: ""
MS_IFC_BGP_AUTH_KEY_TYPE: ""
LOOPBACK100_IP_RANGE: 10.100.0.0/24
DCI_SUBNET_RANGE: 10.100.1.0/24
DCI_SUBNET_TARGET_MASK: 30
enableScheduledBackup: ""
scheduledTime: ""

0 comments on commit b65c0ad

Please sign in to comment.