community.general/lib/ansible/modules/network/cumulus/_cl_interface.py

212 lines
6.9 KiB
Python
Raw Normal View History

2016-01-25 23:59:45 +00:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Cumulus Networks <ce-ceng@cumulusnetworks.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
2016-01-25 23:59:45 +00:00
2017-08-16 03:16:38 +00:00
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['deprecated'],
'supported_by': 'community'}
2016-12-06 10:35:05 +00:00
DOCUMENTATION = r'''
2016-01-25 23:59:45 +00:00
---
module: cl_interface
version_added: "2.1"
author: "Cumulus Networks (@CumulusNetworks)"
short_description: Configures a front panel port, loopback or
management port on Cumulus Linux.
deprecated:
removed_in: "2.5"
why: The M(nclu) module is designed to be easier to use for individuals who are new to Cumulus Linux by exposing the NCLU interface in an automatable way.
alternative: Use M(nclu) instead.
2016-01-25 23:59:45 +00:00
description:
- Configures a front panel, sub-interface, SVI, management or loopback port
on a Cumulus Linux switch. For bridge ports use the cl_bridge module. For
bond ports use the cl_bond module. When configuring bridge related
features like the "vid" option, please follow the guidelines for
configuring "vlan aware" bridging. For more details review the Layer2
2016-08-04 11:18:06 +00:00
Interface Guide at U(http://docs.cumulusnetworks.com)
2016-01-25 23:59:45 +00:00
options:
name:
description:
2016-08-04 11:18:06 +00:00
- Name of the interface.
2016-01-25 23:59:45 +00:00
required: true
alias_name:
description:
2016-08-04 11:18:06 +00:00
- Description of the port.
2016-01-25 23:59:45 +00:00
ipv4:
description:
2016-08-04 11:18:06 +00:00
- List of IPv4 addresses to configure on the interface.
In the form I(X.X.X.X/YY).
2016-01-25 23:59:45 +00:00
ipv6:
description:
2016-08-04 11:18:06 +00:00
- List of IPv6 addresses to configure on the interface.
In the form I(X:X:X::X/YYY).
2016-01-25 23:59:45 +00:00
addr_method:
description:
2016-08-04 11:18:06 +00:00
- Address method.
choices:
- loopback
- dhcp
2016-01-25 23:59:45 +00:00
speed:
description:
2016-08-04 11:18:06 +00:00
- Set speed of the swp(front panel) or management(eth0) interface.
speed is in MB.
2016-01-25 23:59:45 +00:00
mtu:
description:
2016-08-04 11:18:06 +00:00
- Set MTU. Configure Jumbo Frame by setting MTU to I(9000).
2016-01-25 23:59:45 +00:00
virtual_ip:
description:
2016-08-04 11:18:06 +00:00
- Define IPv4 virtual IP used by the Cumulus Linux VRR feature.
2016-01-25 23:59:45 +00:00
virtual_mac:
description:
2016-08-04 11:18:06 +00:00
- Define Ethernet mac associated with Cumulus Linux VRR feature.
2016-01-25 23:59:45 +00:00
vids:
description:
2016-08-04 11:18:06 +00:00
- In vlan-aware mode, lists VLANs defined under the interface.
2016-01-25 23:59:45 +00:00
mstpctl_bpduguard:
description:
2016-08-04 11:18:06 +00:00
- Enables BPDU Guard on a port in vlan-aware mode.
2016-01-25 23:59:45 +00:00
mstpctl_portnetwork:
description:
2016-08-04 11:18:06 +00:00
- Enables bridge assurance in vlan-aware mode.
2016-01-25 23:59:45 +00:00
mstpctl_portadminedge:
description:
2016-08-04 11:18:06 +00:00
- Enables admin edge port.
2016-01-25 23:59:45 +00:00
clagd_enable:
description:
- Enables the clagd daemon. This command should only be applied to
2016-08-04 11:18:06 +00:00
the clag peerlink interface.
2016-01-25 23:59:45 +00:00
clagd_priority:
description:
- Integer that changes the role the switch has in the clag domain.
The lower priority switch will assume the primary role. The number
2016-08-04 11:18:06 +00:00
can be between 0 and 65535.
2016-01-25 23:59:45 +00:00
clagd_peer_ip:
description:
2016-08-04 11:18:06 +00:00
- IP address of the directly connected peer switch interface.
2016-01-25 23:59:45 +00:00
clagd_sys_mac:
description:
- Clagd system mac address. Recommended to use the range starting
2016-08-04 11:18:06 +00:00
with 44:38:39:ff. Needs to be the same between 2 Clag switches.
2016-01-25 23:59:45 +00:00
pvid:
description:
2016-08-04 11:18:06 +00:00
- In vlan-aware mode, defines vlan that is the untagged vlan.
2016-01-25 23:59:45 +00:00
location:
description:
2016-08-04 11:18:06 +00:00
- Interface directory location
2016-01-25 23:59:45 +00:00
default:
2016-08-04 11:18:06 +00:00
- '/etc/network/interfaces.d'
2016-01-25 23:59:45 +00:00
requirements: [ Alternate Debian network interface manager - \
ifupdown2 @ github.com/CumulusNetworks/ifupdown2 ]
notes:
2016-08-04 11:18:06 +00:00
- As this module writes the interface directory location, ensure that
``/etc/network/interfaces`` has a 'source /etc/network/interfaces.d/\*' or
2016-01-25 23:59:45 +00:00
whatever path is mentioned in the ``location`` attribute.
- For the config to be activated, i.e installed in the kernel,
"service networking reload" needs be be executed. See EXAMPLES section.
'''
EXAMPLES = '''
# Options ['virtual_mac', 'virtual_ip'] are required together
- name: Configure a front panel port with an IP
cl_interface:
name: swp1
ipv4: 10.1.1.1/24
notify: reload networking
2016-01-25 23:59:45 +00:00
- name: Configure front panel to use DHCP
cl_interface:
name: swp2
addr_family: dhcp
notify: reload networking
2016-01-25 23:59:45 +00:00
- name: Configure a SVI for vlan 100 interface with an IP
cl_interface:
name: bridge.100
ipv4: 10.1.1.1/24
notify: reload networking
2016-01-25 23:59:45 +00:00
- name: Configure subinterface with an IP
cl_interface:
name: bond0.100
2016-12-09 11:00:34 +00:00
alias_name: my bond
ipv4: 10.1.1.1/24
notify: reload networking
2016-01-25 23:59:45 +00:00
# define cl_interfaces once in tasks
# then write interfaces in variables file
2016-01-25 23:59:45 +00:00
# with just the options you want.
2017-02-07 21:39:24 +00:00
- name: Create interfaces
cl_interface:
2016-12-09 11:00:34 +00:00
name: '{{ item.key }}'
ipv4: '{{ item.value.ipv4 | default(omit) }}'
ipv6: '{{ item.value.ipv6 | default(omit) }}'
alias_name: '{{ item.value.alias_name | default(omit) }}'
addr_method: '{{ item.value.addr_method | default(omit) }}'
speed: '{{ item.value.link_speed | default(omit) }}'
mtu: '{{ item.value.mtu | default(omit) }}'
clagd_enable: '{{ item.value.clagd_enable | default(omit) }}'
clagd_peer_ip: '{{ item.value.clagd_peer_ip | default(omit) }}'
clagd_sys_mac: '{{ item.value.clagd_sys_mac | default(omit) }}'
clagd_priority: '{{ item.value.clagd_priority | default(omit) }}'
vids: '{{ item.value.vids | default(omit) }}'
virtual_ip: '{{ item.value.virtual_ip | default(omit) }}'
virtual_mac: '{{ item.value.virtual_mac | default(omit) }}'
mstpctl_portnetwork: "{{ item.value.mstpctl_portnetwork | default('no') }}"
mstpctl_portadminedge: "{{ item.value.mstpctl_portadminedge | default('no') }}"
mstpctl_bpduguard: "{{ item.value.mstpctl_bpduguard | default('no') }}"
2017-02-07 21:39:24 +00:00
with_dict: '{{ cl_interfaces }}'
notify: reload networking
2016-01-25 23:59:45 +00:00
# In vars file
# ============
2017-02-07 21:39:24 +00:00
---
2016-01-25 23:59:45 +00:00
cl_interfaces:
2016-12-09 11:00:34 +00:00
swp1:
alias_name: uplink to isp
ipv4: 10.1.1.1/24
swp2:
alias_name: l2 trunk connection
vids:
- 1
- 50
swp3:
speed: 1000
alias_name: connects to 1G link
2016-01-25 23:59:45 +00:00
##########
# br0 interface is configured by cl_bridge
##########
2016-12-09 11:00:34 +00:00
br0.100:
alias_name: SVI for vlan 100
ipv4: 10.2.2.2/24
ipv6: '10:2:2::2/127'
virtual_ip: 10.2.2.254
virtual_mac: 00:00:5E:00:10:10
2016-01-25 23:59:45 +00:00
'''
RETURN = '''
changed:
description: whether the interface was changed
returned: changed
type: bool
sample: True
msg:
description: human-readable report of success or failure
returned: always
type: string
sample: "interface bond0 config updated"
'''
from ansible.module_utils.common.removed import removed_module
2016-01-25 23:59:45 +00:00
if __name__ == '__main__':
removed_module()