mikewiebe.ndfc.dcnm_vrf (2.1.3) — module

Add and remove VRFs from a DCNM managed VXLAN fabric.

| "added in version" 0.9.0 of mikewiebe.ndfc"

Authors: Shrishail Kariyappanavar(@nkshrishail), Karthik Babu Harichandra Babu (@kharicha), Praveen Ramoorthy(@praveenramoorthy)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install mikewiebe.ndfc:==2.1.3


Add to requirements.yml

  collections:
    - name: mikewiebe.ndfc
      version: 2.1.3

Description

Add and remove VRFs and VRF Lite Extension from a DCNM managed VXLAN fabric.

In Multisite fabrics, VRFs can be created only on Multisite fabric

In Multisite fabrics, VRFs cannot be created on member fabric

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# This module supports the following states:
#
# Merged:
#   VRFs defined in the playbook will be merged into the target fabric.
#     - If the VRF does not exist it will be added.
#     - If the VRF exists but properties managed by the playbook are different
#       they will be updated if possible.
#     - VRFs that are not specified in the playbook will be untouched.
#
# Replaced:
#   VRFs defined in the playbook will be replaced in the target fabric.
#     - If the VRF does not exist it will be added.
#     - If the VRF exists but properties managed by the playbook are different
#       they will be updated if possible.
#     - Properties that can be managed by the module but are  not specified
#       in the playbook will be deleted or defaulted if possible.
#     - VRFs that are not specified in the playbook will be untouched.
#
# Overridden:
#   VRFs defined in the playbook will be overridden in the target fabric.
#     - If the VRF does not exist it will be added.
#     - If the VRF exists but properties managed by the playbook are different
#       they will be updated if possible.
#     - Properties that can be managed by the module but are not specified
#       in the playbook will be deleted or defaulted if possible.
#     - VRFs that are not specified in the playbook will be deleted.
#
# Deleted:
#   VRFs defined in the playbook will be deleted.
#   If no VRFs are provided in the playbook, all VRFs present on that DCNM fabric will be deleted.
#
# Query:
#   Returns the current DCNM state for the VRFs listed in the playbook.
#
# rollback functionality:
# This module supports task level rollback functionality. If any task runs into failures, as part of failure
# handling, the module tries to bring the state of the DCNM back to the state captured in have structure at the
# beginning of the task execution. Following few lines provide a logical description of how this works,
# if (failure)
#     want data = have data
#     have data = get state of DCNM
#     Run the module in override state with above set of data to produce the required set of diffs
#     and push the diff payloads to DCNM.
# If rollback fails, the module does not attempt to rollback again, it just quits with appropriate error messages.

# The two VRFs below will be merged into the target fabric.
- name: Merge vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: merged
    config:
    - vrf_name: ansible-vrf-r1
      vrf_id: 9008011
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
      attach:
      - ip_address: 192.168.1.224
        deploy: true
      - ip_address: 192.168.1.225
        deploy: false
    - vrf_name: ansible-vrf-r2
      vrf_id: 9008012
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      service_vrf_template: null
      attach:
      - ip_address: 192.168.1.224
      - ip_address: 192.168.1.225
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# VRF LITE Extension attached
- name: Merge vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: merged
    config:
    - vrf_name: ansible-vrf-r1
      vrf_id: 9008011
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
      attach:
      - ip_address: 192.168.1.224
      - ip_address: 192.168.1.225
        vrf_lite:
         # All parameters under vrf_lite except peer_vrf are optional and
         # will be supplied by DCNM when omitted in the playbook
          - peer_vrf: test_vrf_1 # peer_vrf is mandatory
            interface: Ethernet1/16 # optional
            ipv4_addr: 10.33.0.2/30 # optional
            neighbor_ipv4: 10.33.0.1 # optional
            ipv6_addr: 2010::10:34:0:7/64 # optional
            neighbor_ipv6: 2010::10:34:0:3 # optional
            dot1q: 2 # dot1q can be got from dcnm/optional
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# The two VRFs below will be replaced in the target fabric.
- name: Replace vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: replaced
    config:
    - vrf_name: ansible-vrf-r1
      vrf_id: 9008011
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
      attach:
      - ip_address: 192.168.1.224
        deploy: true
      # Delete this attachment
      # - ip_address: 192.168.1.225
      # deploy: true
      # Create the following attachment
      - ip_address: 192.168.1.226
        deploy: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    # Dont touch this if its present on DCNM
    # - vrf_name: ansible-vrf-r2
    #   vrf_id: 9008012
    #   vrf_template: Default_VRF_Universal
    #   vrf_extension_template: Default_VRF_Extension_Universal
    #   attach:
    #   - ip_address: 192.168.1.224
    #   - ip_address: 192.168.1.225

# The two VRFs below will be overridden in the target fabric.
- name: Override vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: overridden
    config:
    - vrf_name: ansible-vrf-r1
      vrf_id: 9008011
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
      attach:
      - ip_address: 192.168.1.224
        deploy: true
      # Delete this attachment
      # - ip_address: 192.168.1.225
      #   deploy: true
      # Create the following attachment
      - ip_address: 192.168.1.226
        deploy: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    # Delete this vrf
    # - vrf_name: ansible-vrf-r2
    #   vrf_id: 9008012
    #   vrf_template: Default_VRF_Universal
    #   vrf_extension_template: Default_VRF_Extension_Universal
    #   vlan_id: 2000
    #   service_vrf_template: null
    #   attach:
    #   - ip_address: 192.168.1.224
    #   - ip_address: 192.168.1.225

- name: Delete selected vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: deleted
    config:
    - vrf_name: ansible-vrf-r1
      vrf_id: 9008011
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
    - vrf_name: ansible-vrf-r2
      vrf_id: 9008012
      vrf_template: Default_VRF_Universal
      vrf_extension_template: Default_VRF_Extension_Universal
      vlan_id: 2000
      service_vrf_template: null
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete all the vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: deleted
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query vrfs
  cisco.dcnm.dcnm_vrf:
    fabric: vxlan-fabric
    state: query
    config:
    - vrf_name: ansible-vrf-r1
    - vrf_name: ansible-vrf-r2

Inputs

    
state:
    choices:
    - merged
    - replaced
    - overridden
    - deleted
    - query
    default: merged
    description:
    - The state of DCNM after module completion.
    type: str

config:
    description:
    - List of details of vrfs being managed. Not required for state deleted
    elements: dict
    suboptions:
      attach:
        description:
        - List of vrf attachment details
        elements: dict
        suboptions:
          deploy:
            default: true
            description:
            - Per switch knob to control whether to deploy the attachment
            - This knob has been deprecated from Ansible NDFC Collection Version 2.1.0
              onwards. There will not be any functional impact if specified in playbook.
            type: bool
          ip_address:
            description:
            - IP address of the switch where vrf will be attached or detached
            required: true
            suboptions:
              vrf_lite:
                description:
                - VRF Lite Extensions options
                elements: dict
                required: false
                suboptions:
                  dot1q:
                    description:
                    - DOT1Q Id
                    required: false
                    type: str
                  interface:
                    description:
                    - Interface of the switch which is connected to the edge router
                    required: false
                    type: str
                  ipv4_addr:
                    description:
                    - IP address of the interface which is connected to the edge router
                    required: false
                    type: str
                  ipv6_addr:
                    description:
                    - IPv6 address of the interface which is connected to the edge router
                    required: false
                    type: str
                  neighbor_ipv4:
                    description:
                    - Neighbor IP address of the edge router
                    required: false
                    type: str
                  neighbor_ipv6:
                    description:
                    - Neighbor IPv6 address of the edge router
                    required: false
                    type: str
                  peer_vrf:
                    description:
                    - VRF Name to which this extension is attached
                    required: true
                    type: str
                type: list
            type: str
        type: list
      deploy:
        default: true
        description:
        - Global knob to control whether to deploy the attachment
        - Ansible NDFC Collection Behavior for Version 2.0.1 and earlier
        - This knob will create and deploy the attachment in DCNM only when set to "True"
          in playbook
        - Ansible NDFC Collection Behavior for Version 2.1.0 and later
        - Attachments specified in the playbook will always be created in DCNM. This knob,
          when set to "True",  will deploy the attachment in DCNM, by pushing the configs
          to switch. If set to "False", the attachments will be created in DCNM, but will
          not be deployed
        type: bool
      service_vrf_template:
        default: None
        description:
        - Service vrf template
        type: str
      vlan_id:
        description:
        - vlan ID for the vrf attachment
        - If not specified in the playbook, DCNM will auto-select an available vlan_id
        required: false
        type: int
      vrf_extension_template:
        default: Default_VRF_Extension_Universal
        description:
        - Name of the extension config template to be used
        type: str
      vrf_id:
        description:
        - ID of the vrf being managed
        required: false
        type: int
      vrf_name:
        description:
        - Name of the vrf being managed
        required: true
        type: str
      vrf_template:
        default: Default_VRF_Universal
        description:
        - Name of the config template to be used
        type: str
    type: list

fabric:
    description:
    - Name of the target fabric for vrf operations
    required: true
    type: str