nxos bugfixes cherry-pick (#38091)

* Fix nxos_switchport (#37328)

(cherry picked from commit ff57fd0bb4)

* Fix nxos_l2_interface and test typo (#37336)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit ba5e562c76)

* fix ios_l2_interface (#37389)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit dd37857884)

* fix required args for nxos_snapshot and docs improvement (#37232)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit a10df8b0b5)

* add nxos_snapshot test for missing required param (#37248)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 2501834c42)

* Ensure network_cli nxos test is run only once - remove unnecessary files (#37462)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 957ab02e52)

* Integration Tests only: nxos_user (#37852)

* add new integration file to nxos_user

* fix shippable error

* change nxapi to connection

* review comments

(cherry picked from commit 63da50e1d8)

* fix UnboundLocalError nxos_bgp_af module (#37610)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 00abe6dbe7)

* Fix nxos_vrf issues (#37092)

* fix nxos_vrf issues

* fix doc

(cherry picked from commit dc61f4c6b1)

* fix nxos_vrf_af issues (#37211)

(cherry picked from commit 74e79d9f5e)

* fix nxos_udld issues (#37418)

(cherry picked from commit 05b266cc66)

* fix nxos_vlan issues (#38008)

(cherry picked from commit 6f2cb28bb9)

* add changelog

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/37668/merge
Trishna Guha 7 years ago committed by GitHub
parent 60e7aa0dbd
commit a716fe97e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ios_l2_interface - fix removal of trunk vlans (https://github.com/ansible/ansible/pull/37389)

@ -0,0 +1,11 @@
bugfixes:
- _nxos_switchport - fix removal of trunk vlans (https://github.com/ansible/ansible/pull/37328)
- nxos_l2_interface - fix removal of trunk vlans (https://github.com/ansible/ansible/pull/37336)
- nxos_snapshot - fix documentation and add required parameter logic (https://github.com/ansible/ansible/pull/37232, https://github.com/ansible/ansible/pull/37248)
- Improve integration test - Ensure each transport test runs only once (https://github.com/ansible/ansible/pull/37462)
- nxos_user - Integration test (https://github.com/ansible/ansible/pull/37852)
- nxos_bgp_af - Fix UnboundLocalError (https://github.com/ansible/ansible/pull/37610)
- nxos_vrf - Fix nxos_vrf issues (https://github.com/ansible/ansible/pull/37092)
- nxos_vrf_af - Fix nxos_vrf_af issues (https://github.com/ansible/ansible/pull/37211)
- nxos_udld - Fix nxos_udld issues (https://github.com/ansible/ansible/pull/37418)
- nxos_vlan - Fix nxos_vlan issues (https://github.com/ansible/ansible/pull/38008)

@ -185,18 +185,21 @@ def remove_switchport_config_commands(name, existing, proposed, module):
commands.append(command)
elif mode == 'trunk':
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
if not tv_check:
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
# Supported Remove Scenarios for trunk_vlans_list
# 1) Existing: 1,2,3 Proposed: 1,2,3 - Remove all
# 2) Existing: 1,2,3 Proposed: 1,2 - Remove 1,2 Leave 3
# 3) Existing: 1,2,3 Proposed: 2,3 - Remove 2,3 Leave 1
# 4) Existing: 1,2,3 Proposed: 4,5,6 - None removed.
# 5) Existing: None Proposed: 1,2,3 - None removed.
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
native_check = existing.get('native_vlan') == proposed.get('native_vlan')
if native_check and proposed.get('native_vlan'):
@ -291,7 +294,7 @@ def vlan_range_to_list(vlans):
result = []
if vlans:
for part in vlans.split(','):
if part == 'none':
if part.lower() == 'none':
break
if '-' in part:
start, stop = (int(i) for i in part.split('-'))

@ -269,18 +269,23 @@ def remove_switchport_config_commands(interface, existing, proposed, module):
commands.append(command)
elif mode == 'trunk':
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
if tv_check:
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
# Supported Remove Scenarios for trunk_vlans_list
# 1) Existing: 1,2,3 Proposed: 1,2,3 - Remove all
# 2) Existing: 1,2,3 Proposed: 1,2 - Remove 1,2 Leave 3
# 3) Existing: 1,2,3 Proposed: 2,3 - Remove 2,3 Leave 1
# 4) Existing: 1,2,3 Proposed: 4,5,6 - None removed.
# 5) Existing: None Proposed: 1,2,3 - None removed.
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
native_check = existing.get('native_vlan') == proposed.get('native_vlan')
if native_check and proposed.get('native_vlan'):

@ -543,14 +543,16 @@ def get_network_command(existing, key, value):
command = '{0} {1}'.format(key, inet[0])
elif len(inet) == 2:
command = '{0} {1} route-map {2}'.format(key, inet[0], inet[1])
commands.append(command)
if command:
commands.append(command)
for enet in existing_networks:
if enet not in value:
if len(enet) == 1:
command = 'no {0} {1}'.format(key, enet[0])
elif len(enet) == 2:
command = 'no {0} {1} route-map {2}'.format(key, enet[0], enet[1])
commands.append(command)
if command:
commands.append(command)
return commands
@ -568,7 +570,8 @@ def get_inject_map_command(existing, key, value):
command = ('inject-map {0} exist-map {1} '
'copy-attributes'.format(maps[0],
maps[1]))
commands.append(command)
if command:
commands.append(command)
for emaps in existing_maps:
if emaps not in value:
if len(emaps) == 2:
@ -578,7 +581,8 @@ def get_inject_map_command(existing, key, value):
command = ('no inject-map {0} exist-map {1} '
'copy-attributes'.format(emaps[0],
emaps[1]))
commands.append(command)
if command:
commands.append(command)
return commands

@ -252,18 +252,15 @@ def remove_switchport_config_commands(name, existing, proposed, module):
commands.append(command)
elif mode == 'trunk':
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
if tv_check:
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
if vlans_to_remove:
proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
commands.append(command)
native_check = existing.get('native_vlan') == proposed.get('native_vlan')
if native_check and proposed.get('native_vlan'):

@ -69,7 +69,7 @@ options:
default: null
comparison_results_file:
description:
- Name of the file where snapshots comparison will be store.
- Name of the file where snapshots comparison will be stored when C(action=compare).
required: false
default: null
compare_option:
@ -354,7 +354,13 @@ def main():
argument_spec.update(nxos_argument_spec)
required_if = [("action", "compare", ["snapshot1", "snapshot2", "comparison_results_file"]),
("action", "create", ["snapshot_name", "description"]),
("action", "add", ["section", "show_command", "row_id", "element_key1"]),
("action", "delete", ["snapshot_name"])]
module = AnsibleModule(argument_spec=argument_spec,
required_if=required_if,
supports_check_mode=True)
warnings = list()
@ -363,33 +369,10 @@ def main():
action = module.params['action']
comparison_results_file = module.params['comparison_results_file']
CREATE_PARAMS = ['snapshot_name', 'description']
ADD_PARAMS = ['section', 'show_command', 'row_id', 'element_key1']
COMPARE_PARAMS = ['snapshot1', 'snapshot2', 'comparison_results_file']
if not os.path.isdir(module.params['path']):
module.fail_json(msg='{0} is not a valid directory name.'.format(
module.params['path']))
if action == 'create':
for param in CREATE_PARAMS:
if not module.params[param]:
module.fail_json(msg='snapshot_name and description are '
'required when action=create')
elif action == 'add':
for param in ADD_PARAMS:
if not module.params[param]:
module.fail_json(msg='section, show_command, row_id '
'and element_key1 are required '
'when action=add')
elif action == 'compare':
for param in COMPARE_PARAMS:
if not module.params[param]:
module.fail_json(msg='snapshot1 and snapshot2 are required '
'when action=create')
elif action == 'delete' and not module.params['snapshot_name']:
module.fail_json(msg='snapshot_name is required when action=delete')
existing_snapshots = invoke('get_existing', module)
action_results = invoke('action_%s' % action, module, existing_snapshots)

@ -34,8 +34,6 @@ author:
- Jason Edelman (@jedelman8)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- When C(state=absent), it unconfigures existing settings C(msg_time) and set it
to its default value of 15. It is cleaner to always use C(state=present).
- Module will fail if the udld feature has not been previously enabled.
options:
aggressive:
@ -46,18 +44,20 @@ options:
choices: ['enabled','disabled']
msg_time:
description:
- Message time in seconds for UDLD packets.
- Message time in seconds for UDLD packets or keyword 'default'.
required: false
default: null
reset:
description:
- Ability to reset UDLD down interfaces.
- Ability to reset all ports shut down by UDLD. 'state' parameter
cannot be 'absent' when this is present.
required: false
default: null
choices: ['true','false']
choices: ['true']
state:
description:
- Manage the state of the resource.
- Manage the state of the resource. When set to 'absent',
aggressive and msg_time are set to their default values.
required: false
default: present
choices: ['present','absent']
@ -117,6 +117,11 @@ from ansible.module_utils.network.nxos.nxos import get_capabilities, nxos_argume
from ansible.module_utils.basic import AnsibleModule
PARAM_TO_DEFAULT_KEYMAP = {
'msg_time': '15',
}
def execute_show_command(command, module, command_type='cli_show'):
device_info = get_capabilities(module)
network_api = device_info.get('network_api', 'nxapi')
@ -156,42 +161,32 @@ def apply_key_map(key_map, table):
return new_dict
def get_commands_config_udld_global(delta, reset):
config_args = {
'enabled': 'udld aggressive',
'disabled': 'no udld aggressive',
'msg_time': 'udld message-time {msg_time}'
}
def get_commands_config_udld_global(delta, reset, existing):
commands = []
for param, value in delta.items():
if param == 'aggressive':
if value == 'enabled':
command = 'udld aggressive'
elif value == 'disabled':
command = 'no udld aggressive'
else:
command = config_args.get(param, 'DNE').format(**delta)
if command and command != 'DNE':
command = 'udld aggressive' if value == 'enabled' else 'no udld aggressive'
commands.append(command)
command = None
elif param == 'msg_time':
if value == 'default':
if existing.get('msg_time') != PARAM_TO_DEFAULT_KEYMAP.get('msg_time'):
commands.append('no udld message-time')
else:
commands.append('udld message-time ' + value)
if reset:
command = 'udld reset'
commands.append(command)
return commands
def get_commands_remove_udld_global(delta):
config_args = {
'aggressive': 'no udld aggressive',
'msg_time': 'no udld message-time {msg_time}',
}
def get_commands_remove_udld_global(existing):
commands = []
for param, value in delta.items():
command = config_args.get(param, 'DNE').format(**delta)
if command and command != 'DNE':
commands.append(command)
command = None
if existing.get('aggressive') == 'enabled':
command = 'no udld aggressive'
commands.append(command)
if existing.get('msg_time') != PARAM_TO_DEFAULT_KEYMAP.get('msg_time'):
command = 'no udld message-time'
commands.append(command)
return commands
@ -222,7 +217,6 @@ def main():
argument_spec.update(nxos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
required_one_of=[['aggressive', 'msg_time', 'reset']],
supports_check_mode=True)
warnings = list()
@ -232,20 +226,8 @@ def main():
reset = module.params['reset']
state = module.params['state']
if (aggressive or reset) and state == 'absent':
module.fail_json(msg="It's better to use state=present when "
"configuring or unconfiguring aggressive mode "
"or using reset flag. state=absent is just for "
"when using msg_time param.")
if msg_time:
try:
msg_time_int = int(msg_time)
if msg_time_int < 7 or msg_time_int > 90:
raise ValueError
except ValueError:
module.fail_json(msg='msg_time must be an integer'
'between 7 and 90')
if reset and state == 'absent':
module.fail_json(msg="state must be present when using reset flag.")
args = dict(aggressive=aggressive, msg_time=msg_time, reset=reset)
proposed = dict((k, v) for k, v in args.items() if v is not None)
@ -259,13 +241,12 @@ def main():
commands = []
if state == 'present':
if delta:
command = get_commands_config_udld_global(dict(delta), reset)
command = get_commands_config_udld_global(dict(delta), reset, existing)
commands.append(command)
elif state == 'absent':
common = set(proposed.items()).intersection(existing.items())
if common:
command = get_commands_remove_udld_global(dict(common))
command = get_commands_remove_udld_global(existing)
if command:
commands.append(command)
cmds = flatten_list(commands)

@ -45,9 +45,10 @@ options:
- Name of VLAN.
required: false
default: null
- Name of VLAN or keyword 'default'.
interfaces:
description:
- List of interfaces that should be associated to the VLAN.
- List of interfaces that should be associated to the VLAN or keyword 'default'.
version_added: "2.5"
associated_interfaces:
description:
@ -79,10 +80,8 @@ options:
state:
description:
- Manage the state of the resource.
Active and Suspend will assume the vlan is present.
required: false
default: present
choices: ['present','absent', 'active', 'suspend']
choices: ['present','absent']
mode:
description:
- Set VLAN mode to classical ethernet or fabricpath.
@ -173,19 +172,28 @@ def search_obj_in_list(vlan_id, lst):
def get_diff(w, obj):
c = deepcopy(w)
entries = ('interfaces', 'associated_interfaces', 'name', 'delay', 'vlan_range')
entries = ('interfaces', 'associated_interfaces', 'delay', 'vlan_range')
for key in entries:
if key in c:
del c[key]
o = deepcopy(obj)
del o['interfaces']
del o['name']
if o['vlan_id'] == w['vlan_id']:
diff_dict = dict(set(c.items()) - set(o.items()))
return diff_dict
def is_default_name(obj, vlan_id):
cname = obj['name']
if ('VLAN' in cname):
vid = int(cname[4:])
if vid == int(vlan_id):
return True
return False
def map_obj_to_commands(updates, module, os_platform):
commands = list()
want, have = updates
@ -219,13 +227,13 @@ def map_obj_to_commands(updates, module, os_platform):
if not obj_in_have:
commands.append('vlan {0}'.format(vlan_id))
if name:
if name and name != 'default':
commands.append('name {0}'.format(name))
if mode:
commands.append('mode {0}'.format(mode))
if vlan_state:
commands.append('state {0}'.format(vlan_state))
if mapped_vni != 'None':
if mapped_vni != 'None' and mapped_vni != 'default':
commands.append('vn-segment {0}'.format(mapped_vni))
if admin_state == 'up':
commands.append('no shutdown')
@ -233,7 +241,7 @@ def map_obj_to_commands(updates, module, os_platform):
commands.append('shutdown')
commands.append('exit')
if interfaces:
if interfaces and interfaces[0] != 'default':
for i in interfaces:
commands.append('interface {0}'.format(i))
commands.append('switchport')
@ -241,7 +249,38 @@ def map_obj_to_commands(updates, module, os_platform):
commands.append('switchport access vlan {0}'.format(vlan_id))
else:
if interfaces:
diff = get_diff(w, obj_in_have)
if diff:
commands.append('vlan {0}'.format(vlan_id))
for key, value in diff.items():
if key == 'name':
if name != 'default':
if name is not None:
commands.append('name {0}'.format(value))
else:
if not is_default_name(obj_in_have, vlan_id):
commands.append('no name')
if key == 'vlan_state':
commands.append('state {0}'.format(value))
if key == 'mapped_vni':
if value == 'default':
if obj_in_have['mapped_vni'] != 'None':
commands.append('no vn-segment')
elif value != 'None':
commands.append('vn-segment {0}'.format(value))
if key == 'admin_state':
if value == 'up':
commands.append('no shutdown')
elif value == 'down':
commands.append('shutdown')
if key == 'mode':
commands.append('mode {0}'.format(value))
if len(commands) > 1:
commands.append('exit')
else:
del commands[:]
if interfaces and interfaces[0] != 'default':
if not obj_in_have['interfaces']:
for i in interfaces:
commands.append('vlan {0}'.format(vlan_id))
@ -270,24 +309,15 @@ def map_obj_to_commands(updates, module, os_platform):
commands.append('switchport mode access')
commands.append('no switchport access vlan {0}'.format(vlan_id))
else:
diff = get_diff(w, obj_in_have)
if diff:
commands.append('vlan {0}'.format(vlan_id))
for key, value in diff.items():
if key == 'vlan_state':
commands.append('state {0}'.format(value))
if key == 'mapped_vni':
if value != 'None':
commands.append('vn-segment {0}'.format(value))
if key == 'admin_state':
if value == 'up':
commands.append('no shutdown')
elif value == 'down':
commands.append('shutdown')
if key == 'mode':
commands.append('mode {0}'.format(value))
commands.append('exit')
elif interfaces and interfaces[0] == 'default':
if obj_in_have['interfaces']:
for i in obj_in_have['interfaces']:
commands.append('vlan {0}'.format(vlan_id))
commands.append('exit')
commands.append('interface {0}'.format(i))
commands.append('switchport')
commands.append('switchport mode access')
commands.append('no switchport access vlan {0}'.format(vlan_id))
return commands
@ -504,9 +534,9 @@ def main():
interfaces=dict(type='list'),
associated_interfaces=dict(type='list'),
vlan_state=dict(choices=['active', 'suspend'], required=False, default='active'),
mapped_vni=dict(required=False, type='int'),
mapped_vni=dict(required=False),
delay=dict(default=10, type='int'),
state=dict(choices=['present', 'absent', 'active', 'suspend'], default='present', required=False),
state=dict(choices=['present', 'absent'], default='present', required=False),
admin_state=dict(choices=['up', 'down'], required=False, default='up'),
mode=dict(choices=['ce', 'fabricpath'], required=False, default='ce'),
)

@ -74,7 +74,7 @@ options:
interfaces:
description:
- List of interfaces to check the VRF has been
configured correctly.
configured correctly or keyword 'default'.
version_added: 2.5
associated_interfaces:
description:
@ -98,7 +98,7 @@ options:
choices: ['present','absent']
description:
description:
- Description of the VRF.
- Description of the VRF or keyword 'default'.
required: false
default: null
delay:
@ -257,7 +257,7 @@ def map_obj_to_commands(updates, module):
commands.append('vrf context {0}'.format(name))
for item in args:
candidate = w.get(item)
if candidate:
if candidate and candidate != 'default':
cmd = item + ' ' + str(candidate)
commands.append(cmd)
if admin_state == 'up':
@ -266,7 +266,7 @@ def map_obj_to_commands(updates, module):
commands.append('shutdown')
commands.append('exit')
if interfaces:
if interfaces and interfaces[0] != 'default':
for i in interfaces:
commands.append('interface {0}'.format(i))
commands.append('no switchport')
@ -280,7 +280,11 @@ def map_obj_to_commands(updates, module):
for item in args:
candidate = w.get(item)
if candidate and candidate != obj_in_have.get(item):
if candidate == 'default':
if obj_in_have.get(item):
cmd = 'no ' + item + ' ' + obj_in_have.get(item)
commands.append(cmd)
elif candidate and candidate != obj_in_have.get(item):
cmd = item + ' ' + str(candidate)
commands.append(cmd)
if admin_state and admin_state != obj_in_have.get('admin_state'):
@ -293,7 +297,7 @@ def map_obj_to_commands(updates, module):
commands.insert(0, 'vrf context {0}'.format(name))
commands.append('exit')
if interfaces:
if interfaces and interfaces[0] != 'default':
if not obj_in_have['interfaces']:
for i in interfaces:
commands.append('vrf context {0}'.format(name))
@ -318,6 +322,14 @@ def map_obj_to_commands(updates, module):
commands.append('interface {0}'.format(i))
commands.append('no switchport')
commands.append('no vrf member {0}'.format(name))
elif interfaces and interfaces[0] == 'default':
if obj_in_have['interfaces']:
for i in obj_in_have['interfaces']:
commands.append('vrf context {0}'.format(name))
commands.append('exit')
commands.append('interface {0}'.format(i))
commands.append('no switchport')
commands.append('no vrf member {0}'.format(name))
if purge:
existing = get_existing_vrfs(module)

@ -124,14 +124,14 @@ def main():
if current:
have = 'route-target both auto evpn' in current
want = bool(module.params['route_target_both_auto_evpn'])
if want and not have:
commands.append('address-family %s unicast' % module.params['afi'])
commands.append('route-target both auto evpn')
elif have and not want:
commands.append('address-family %s unicast' % module.params['afi'])
commands.append('no route-target both auto evpn')
if module.params['route_target_both_auto_evpn'] is not None:
want = bool(module.params['route_target_both_auto_evpn'])
if want and not have:
commands.append('address-family %s unicast' % module.params['afi'])
commands.append('route-target both auto evpn')
elif have and not want:
commands.append('address-family %s unicast' % module.params['afi'])
commands.append('no route-target both auto evpn')
else:
commands.append('address-family %s unicast' % module.params['afi'])

@ -88,23 +88,52 @@
- assert: *false
- name: Ensure these VLANs are not being tagged on the trunk
- name: Remove full trunk vlan range 2-50
ios_l2_interface: &no_tag
name: "{{ test_interface }}"
mode: trunk
trunk_vlans: 30-4094
trunk_vlans: 2-50
state: absent
provider: "{{ cli }}"
register: result
- assert: *true
- name: "no tag vlan Idempotence"
- name: Check Idempotence Remove full trunk vlan range 2-50
ios_l2_interface: *no_tag
register: result
- assert: *false
- name: Reconfigure interface trunk port and ensure 2-50 are being tagged
ios_l2_interface: *tag
register: result
- assert: *true
- name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
ios_l2_interface: *tag
register: result
- assert: *false
- name: Remove partial trunk vlan range 30-4094 are removed
ios_l2_interface: &partial
name: "{{ test_interface }}"
mode: trunk
trunk_vlans: 30-4094
state: absent
provider: "{{ cli }}"
register: result
- assert: *true
- name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
ios_l2_interface: *partial
register: result
- assert: *false
- name: put interface default state
ios_l2_interface: *def_swi
register: result

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_hsrp/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_hsrp/tests/common/sanity.yaml

@ -20,6 +20,7 @@
nxos_interface:
interface: "{{ intname }}"
mode: layer2
provider: "{{ connection }}"
- name: "Setup vlans"
nxos_vlan:
@ -91,7 +92,7 @@
- assert: *false
- name: Ensure these VLANs are not being tagged on the trunk
- name: Remove full trunk vlan range 2-50
nxos_l2_interface: &no_tag
name: "{{ intname }}"
mode: trunk
@ -102,12 +103,41 @@
- assert: *true
- name: "no tag vlan Idempotence"
- name: Check Idempotence Remove full trunk vlan range 2-50
nxos_l2_interface: *no_tag
register: result
- assert: *false
- name: Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_l2_interface: *tag
register: result
- assert: *true
- name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_l2_interface: *tag
register: result
- assert: *false
- name: Remove partial trunk vlan range 30-4094 are removed
nxos_l2_interface: &partial
name: "{{ intname }}"
mode: trunk
trunk_vlans: 30-4094
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
nxos_l2_interface: *partial
register: result
- assert: *false
- name: put interface default state
nxos_l2_interface: *def_swi
register: result

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_ntp/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_ntp/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_ospf_vrf/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_ospf_vrf/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_snapshot/tests/common/sanity.yaml

@ -36,6 +36,22 @@
path: '.'
provider: "{{ connection }}"
- name: FAIL compare snapshots
nxos_snapshot:
action: compare
snapshot1: test_snapshot1
snapshot2: test_snapshot2
compare_option: summary
path: '.'
provider: "{{ connection }}"
register: result
ignore_errors: yes
- assert:
that:
- 'result.failed == True'
- '"action is compare but all of the following are missing: comparison_results_file" in result.msg'
when: snapshot_run
always:

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_snapshot/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_snmp_user/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_snmp_user/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_static_route/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_static_route/tests/common/sanity.yaml

@ -88,7 +88,7 @@
- assert: *false
- name: Ensure these VLANs are not being tagged on the trunk
- name: Remove full trunk vlan range 2-50.
nxos_switchport: &no_tag
interface: "{{ intname }}"
mode: trunk
@ -99,12 +99,41 @@
- assert: *true
- name: "no tag vlan Idempotence"
- name: Check Idempotence Remove full trunk vlan range 2-50.
nxos_switchport: *no_tag
register: result
- assert: *false
- name: Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_switchport: *tag
register: result
- assert: *true
- name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_switchport: *tag
register: result
- assert: *false
- name: Remove partial trunk vlan range 30-4094 are removed
nxos_switchport: &partial
interface: "{{ intname }}"
mode: trunk
trunk_vlans: 30-4094
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
nxos_switchport: *partial
register: result
- assert: *false
- name: put interface default state
nxos_switchport: *def_swi
register: result

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_udld/tests/common/sanity.yaml

@ -5,7 +5,7 @@
- set_fact: udld_run="true"
- set_fact: udld_run="false"
when: (( platform is search('N9K-F')) and (imagetag and ( imagetag is version('F3', 'lt'))))
when: ((platform is search('N9K-F')) and (imagetag and (imagetag is version_compare('F3', 'lt'))))
- set_fact: udld_run="false"
when: titanium
@ -16,14 +16,9 @@
state: enabled
provider: "{{ connection }}"
- name: Reset udld
nxos_udld:
reset: True
provider: "{{ connection }}"
- name: Ensure udld agg mode is globally disabled and msg time is 20
- name: Configure udld
nxos_udld: &conf1
aggressive: disabled
aggressive: enabled
msg_time: 20
provider: "{{ connection }}"
register: result
@ -32,7 +27,7 @@
that:
- "result.changed == true"
- name: "Conf1 Idempotence"
- name: "Check Idempotence"
nxos_udld: *conf1
register: result
@ -40,22 +35,59 @@
that:
- "result.changed == false"
- name: Reset udld
nxos_udld:
reset: True
provider: "{{ connection }}"
- name: Ensure udld agg mode is globally enabled and msg time is 15
- name: Configure udld2
nxos_udld: &conf2
aggressive: enabled
msg_time: 15
aggressive: disabled
provider: "{{ connection }}"
register: result
- assert: *true
- name: "conf2 Idempotence"
- name: "Check Idempotence"
nxos_udld: *conf2
register: result
- assert: *false
- name: Configure udld3
nxos_udld: &conf3
msg_time: default
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_udld: *conf3
register: result
- assert: *false
- name: Configure udld again
nxos_udld: *conf1
register: result
- assert: *true
- name: Remove udld config
nxos_udld: &conf4
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_udld: *conf4
register: result
- assert: *false
when: udld_run
always:

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_udld/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_udld_interface/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_udld_interface/tests/common/sanity.yaml

@ -0,0 +1,117 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_user parameter test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- set_fact: idem="true"
- set_fact: idem="false"
when: ((platform is search('N7K')) and (imagetag and (imagetag is version_compare('D1', 'eq'))))
- block:
- name: Create user
nxos_user: &configure
name: netend
configured_password: Hello!23$
update_password: on_create
roles: network-operator
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- 'result.changed == true'
- block:
- name: conf idempotency
nxos_user: *configure
register: result
- assert: &false
that:
- 'result.changed == false'
when: idem
- name: Remove user
nxos_user: &remove
name: netend
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: remove idempotency
nxos_user: *remove
register: result
- assert: *false
- debug: msg="skipping sshkey test as the key needs to be created on the server first"
# - name: create a new user
# nxos_user: &conf1
# name: ansible
# sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
# state: present
# provider: "{{ connection }}"
# register: result
#
# - assert: *true
# - block:
# - name: user idempotency
# nxos_user: *conf1
# register: result
#
# - assert: *false
#
# when: idem
- name: Collection of users
nxos_user: &coll
users:
- name: test1
- name: test2
configured_password: Hello!23$
update_password: on_create
state: present
roles:
- network-admin
- network-operator
provider: "{{ connection }}"
register: result
- assert: *true
- block:
- name: users idempotency
nxos_user: *coll
register: result
- assert: *false
when: idem
- name: tearDown
nxos_user: &tear
name: ansible
purge: yes
provider: "{{ connection }}"
register: result
- assert: *true
- name: teardown idempotency
nxos_user: *tear
register: result
- assert: *false
always:
- name: tearDown
nxos_user: *tear
register: result
ignore_errors: yes
- debug: msg="END connection={{ ansible_connection }} nxos_user parameter test"

@ -7,6 +7,7 @@
lines:
- no vlan 100
provider: "{{ connection }}"
ignore_errors: yes
- name: setup - remove vlan from interfaces used in test(part1)
nxos_config:

@ -3,6 +3,9 @@
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- set_fact: testint1="{{ nxos_int1 }}"
- set_fact: testint2="{{ nxos_int2 }}"
- block:
- name: "Enable feature vn segment"
nxos_config:
@ -44,7 +47,7 @@
- assert: *true
when: platform is search('N9K')
- name: "web Idempotence"
- name: "web1 Idempotence"
nxos_vlan: *web1
register: result
when: platform is search('N9K')
@ -52,8 +55,30 @@
- assert: *false
when: platform is search('N9K')
- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
- name: change name and vni to default
nxos_vlan: &web2
vlan_id: 50
vlan_state: active
admin_state: up
name: default
mapped_vni: default
provider: "{{ connection }}"
register: result
when: platform is search('N9K')
- assert: *true
when: platform is search('N9K')
- name: "web2 Idempotence"
nxos_vlan: *web2
register: result
when: platform is search('N9K')
- assert: *false
when: platform is search('N9K')
- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
nxos_vlan: &web3
vlan_id: 50
vlan_state: suspend
admin_state: down
@ -65,14 +90,74 @@
- assert: *true
when: platform is search('N3K|N7K')
- name: "web Idempotence"
nxos_vlan: *web2
- name: "web3 Idempotence"
nxos_vlan: *web3
register: result
when: platform is search('N3K|N7K')
- assert: *false
when: platform is search('N3K|N7K')
- name: Change name to default
nxos_vlan: &web4
vlan_id: 50
vlan_state: active
admin_state: up
name: default
provider: "{{ connection }}"
register: result
when: platform is search('N3K|N7K')
- assert: *true
when: platform is search('N3K|N7K')
- name: "web4 Idempotence"
nxos_vlan: *web4
register: result
when: platform is search('N3K|N7K')
- assert: *false
when: platform is search('N3K|N7K')
# Uncomment this once the get_capabilities() work on nxapi as well
# - name: Change mode
# nxos_vlan: &mode1
# vlan_id: 50
# mode: fabricpath
# provider: "{{ connection }}"
# register: result
# when: platform is search('N5k|N7K')
#
# - assert: *true
# when: platform is search('N5k|N7K')
#
# - name: "mode1 Idempotence"
# nxos_vlan: *mode1
# register: result
# when: platform is search('N5k|N7K')
#
# - assert: *false
# when: platform is search('N5k|N7K')
#
# - name: Change mode again
# nxos_vlan: &mode2
# vlan_id: 50
# mode: ce
# provider: "{{ connection }}"
# register: result
# when: platform is search('N5k|N7K')
#
# - assert: *true
# when: platform is search('N5k|N7K')
#
# - name: "mode2 Idempotence"
# nxos_vlan: *mode2
# register: result
# when: platform is search('N5k|N7K')
#
# - assert: *false
# when: platform is search('N5k|N7K')
- name: Ensure VLAN is NOT on the device
nxos_vlan: &no_vlan
vlan_id: 50
@ -88,7 +173,44 @@
- assert: *false
- name: Add interfaces to vlan
nxos_vlan: &addint
vlan_id: 101
vlan_state: suspend
interfaces:
- "{{ testint1 }}"
- "{{ testint2 }}"
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Addint idempotence"
nxos_vlan: *addint
register: result
- assert: *false
- name: Remove interfaces from vlan
nxos_vlan: &remint
vlan_id: 101
interfaces: default
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Remint idempotence"
nxos_vlan: *remint
register: result
- assert: *false
always:
- name: Remove int from vlan
nxos_vlan: *remint
ignore_errors: yes
- name: remove vlans
nxos_vlan:
vlan_range: "2-10,20,50,55-60,100-150"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_vpc/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_vpc/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_vpc_interface/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_vpc_interface/tests/common/sanity.yaml

@ -3,21 +3,39 @@
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- block:
- name: 'Setup: Delete VRF before test'
nxos_config:
lines:
- no vrf context ntc
provider: "{{ connection }}"
ignore_errors: yes
- set_fact: intname1="{{ nxos_int1 }}"
- set_fact: intname2="{{ nxos_int2 }}"
- set_fact: rdnd="1:2"
when: (platform is not match("N35|N7K")) and ((imagetag != 'I2'))
- set_fact: rdd="default"
when: (platform is not match("N35|N7K")) and ((imagetag != 'I2'))
- set_fact: vnind="5000"
when: platform is not match("N35|N7K")
- set_fact: vnid="default"
when: platform is not match("N35|N7K")
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: Ensure ntc VRF exists on switch
nxos_vrf: &configure
vrf: ntc
admin_state: down
description: testing
#vni: 5000
#rd: auto
vni: "{{vnind|default(omit)}}"
rd: "{{rdnd|default(omit)}}"
interfaces:
- "{{ intname1 }}"
- "{{ intname2 }}"
provider: "{{ connection }}"
register: result
@ -33,13 +51,30 @@
that:
- "result.changed == false"
- pause:
seconds: 30
- name: Remove config
nxos_vrf: &remconf
vrf: ntc
admin_state: up
vni: "{{vnid|default(omit)}}"
rd: "{{rdd|default(omit)}}"
interfaces: default
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vrf: *remconf
register: result
- assert: *false
- name: Ensure ntc VRF does not exist on switch
nxos_vrf: &remove
vrf: ntc
admin_state: down
description: testing
#vni: 5000
#rd: auto
state: absent
provider: "{{ connection }}"
register: result
@ -55,11 +90,12 @@
- assert: *false
- name: 'Teardown: Delete VRF after test'
nxos_config:
lines:
- no vrf context ntc
always:
- name: "Disable feature BGP"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ connection }}"
ignore_errors: yes
- debug: msg="END connection={{ ansible_connection }} nxos_vrf sanity test"
- debug: msg="END connection={{ ansible_connection }} nxos_vrf sanity test"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_vrf_af/tests/common/sanity.yaml

@ -13,18 +13,20 @@
nxos_config:
commands: "feature nv overlay"
provider: "{{ connection }}"
ignore_errors: yes
- name: Configure nv overlay evpn
nxos_config:
commands: "nv overlay evpn"
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: Configure vrf af
nxos_vrf_af: &configure
- name: Configure vrf af ipv4
nxos_vrf_af: &configure4
vrf: ansible
afi: ipv4
route_target_both_auto_evpn: true
route_target_both_auto_evpn: True
provider: "{{ connection }}"
register: result
@ -33,18 +35,66 @@
- "result.changed == true"
- name: "Conf Idempotence"
nxos_vrf_af: *configure
nxos_vrf_af: *configure4
register: result
- assert: &false
that:
- "result.changed == false"
- name: Remove vrf af
nxos_vrf_af: &remove
- name: Configure vrf af ipv6
nxos_vrf_af: &configure6
vrf: ansible
afi: ipv6
route_target_both_auto_evpn: True
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vrf_af: *configure6
register: result
- assert: *false
- name: Remove router target4
nxos_vrf_af: &rrt4
vrf: ansible
afi: ipv4
route_target_both_auto_evpn: true
route_target_both_auto_evpn: False
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vrf_af: *rrt4
register: result
- assert: *false
- name: Remove router target6
nxos_vrf_af: &rrt6
vrf: ansible
afi: ipv6
route_target_both_auto_evpn: False
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vrf_af: *rrt6
register: result
- assert: *false
- name: Remove vrf af v6
nxos_vrf_af: &remove6
vrf: ansible
afi: ipv6
route_target_both_auto_evpn: True
state: absent
provider: "{{ connection }}"
register: result
@ -55,21 +105,37 @@
seconds: 30
- name: "Remove Idempotence"
nxos_vrf_af: *remove
nxos_vrf_af: *remove6
register: result
- assert: *false
always:
- name: Remove feature bgp
nxos_feature:
feature: bgp
state: disabled
- name: Remove vrf af v4
nxos_vrf_af: &remove4
vrf: ansible
afi: ipv4
route_target_both_auto_evpn: True
state: absent
provider: "{{ connection }}"
register: result
- name: Remove feature nv overlay
- assert: *true
- pause:
seconds: 30
- name: "Remove Idempotence"
nxos_vrf_af: *remove4
register: result
- assert: *false
when: not platform is search("N35")
always:
- name: Remove vrf
nxos_config:
commands: "no feature nv overlay"
commands: "no vrf context ansible"
provider: "{{ connection }}"
ignore_errors: yes
@ -79,4 +145,16 @@
provider: "{{ connection }}"
ignore_errors: yes
- name: Remove feature nv overlay
nxos_config:
commands: "no feature nv overlay"
provider: "{{ connection }}"
ignore_errors: yes
- name: Remove feature bgp
nxos_feature:
feature: bgp
state: disabled
provider: "{{ connection }}"
- debug: msg="END connection={{ ansible_connection }} nxos_vrf_af sanity test"

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_vrf_af/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml

@ -1,4 +0,0 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml
Loading…
Cancel
Save