diff --git a/lib/ansible/modules/network/nxos/nxos_system.py b/lib/ansible/modules/network/nxos/nxos_system.py index 0059be17ccb..da51e2bd422 100644 --- a/lib/ansible/modules/network/nxos/nxos_system.py +++ b/lib/ansible/modules/network/nxos/nxos_system.py @@ -238,12 +238,14 @@ def parse_domain_search(config, vrf_config): return objects -def parse_name_servers(config, vrf_config): +def parse_name_servers(config, vrf_config, vrfs): objects = list() match = re.search('^ip name-server (.+)$', config, re.M) if match: for addr in match.group(1).split(' '): + if addr == 'use-vrf' or addr in vrfs: + continue objects.append({'server': addr, 'vrf': None}) for vrf, cfg in iteritems(vrf_config): @@ -275,7 +277,7 @@ def map_config_to_obj(module): 'domain_lookup': 'no ip domain-lookup' not in config, 'domain_name': parse_domain_name(config, vrf_config), 'domain_search': parse_domain_search(config, vrf_config), - 'name_servers': parse_name_servers(config, vrf_config), + 'name_servers': parse_name_servers(config, vrf_config, vrfs), 'system_mtu': parse_system_mtu(config) } diff --git a/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml b/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml index 735bbd26f3a..f8114e83ca2 100644 --- a/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml +++ b/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml @@ -22,7 +22,6 @@ - assert: that: - result.changed == true - - result.commands|length == 3 - "'ip name-server 1.1.1.1' in result.commands" - "'ip name-server 2.2.2.2' in result.commands" - "'ip name-server 3.3.3.3' in result.commands" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml index 39620572d20..70879484eb9 100644 --- a/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml +++ b/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml @@ -28,7 +28,6 @@ - assert: that: - result.changed == true - - result.commands|length == 3 - "'ip name-server 1.1.1.1' in result.commands" - "'ip name-server 2.2.2.2' in result.commands" - "'ip name-server 3.3.3.3' in result.commands"