|
|
@ -60,6 +60,7 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- If C(mode=trunk), used as the VLAN range to ADD or REMOVE
|
|
|
|
- If C(mode=trunk), used as the VLAN range to ADD or REMOVE
|
|
|
|
from the trunk.
|
|
|
|
from the trunk.
|
|
|
|
|
|
|
|
aliases: trunk_add_vlans
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
default: null
|
|
|
|
default: null
|
|
|
|
state:
|
|
|
|
state:
|
|
|
@ -70,8 +71,8 @@ options:
|
|
|
|
choices: ['present','absent', 'unconfigured']
|
|
|
|
choices: ['present','absent', 'unconfigured']
|
|
|
|
trunk_allowed_vlans:
|
|
|
|
trunk_allowed_vlans:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- if mode=trunk, these are the only VLANs that should be
|
|
|
|
- if C(mode=trunk), these are the only VLANs that will be
|
|
|
|
configured on the trunk
|
|
|
|
configured on the trunk, i.e. "2-10,15"
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
version_added: 2.2
|
|
|
|
version_added: 2.2
|
|
|
|
default: null
|
|
|
|
default: null
|
|
|
@ -289,7 +290,6 @@ def remove_switchport_config_commands(interface, existing, proposed, module):
|
|
|
|
existing_vlans = existing.get('trunk_vlans_list')
|
|
|
|
existing_vlans = existing.get('trunk_vlans_list')
|
|
|
|
proposed_vlans = proposed.get('trunk_vlans_list')
|
|
|
|
proposed_vlans = proposed.get('trunk_vlans_list')
|
|
|
|
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
|
|
|
|
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
|
|
|
|
# module.exit_json(ex=existing, pr=proposed, vlans_to_remove=list(vlans_to_remove))
|
|
|
|
|
|
|
|
if vlans_to_remove:
|
|
|
|
if vlans_to_remove:
|
|
|
|
command = 'switchport trunk allowed vlan remove {0}'.format(
|
|
|
|
command = 'switchport trunk allowed vlan remove {0}'.format(
|
|
|
|
proposed.get('trunk_vlans', proposed.get('trunk_allowed_vlans')))
|
|
|
|
proposed.get('trunk_vlans', proposed.get('trunk_allowed_vlans')))
|
|
|
@ -331,7 +331,6 @@ def get_switchport_config_commands(interface, existing, proposed, module):
|
|
|
|
elif proposed_mode == 'trunk':
|
|
|
|
elif proposed_mode == 'trunk':
|
|
|
|
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
|
|
|
|
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
|
|
|
|
if not tv_check:
|
|
|
|
if not tv_check:
|
|
|
|
# module.exit_json(aaaa=existing, tvtv=tv_check, pr=proposed)
|
|
|
|
|
|
|
|
if proposed.get('allowed'):
|
|
|
|
if proposed.get('allowed'):
|
|
|
|
command = 'switchport trunk allowed vlan {0}'.format(proposed.get('trunk_allowed_vlans'))
|
|
|
|
command = 'switchport trunk allowed vlan {0}'.format(proposed.get('trunk_allowed_vlans'))
|
|
|
|
commands.append(command)
|
|
|
|
commands.append(command)
|
|
|
@ -605,7 +604,6 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
commands = []
|
|
|
|
commands = []
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
|
# module.exit_json(ex=existing, pr=proposed)
|
|
|
|
|
|
|
|
command = get_switchport_config_commands(interface, existing, proposed, module)
|
|
|
|
command = get_switchport_config_commands(interface, existing, proposed, module)
|
|
|
|
commands.append(command)
|
|
|
|
commands.append(command)
|
|
|
|
elif state == 'unconfigured':
|
|
|
|
elif state == 'unconfigured':
|
|
|
|