diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py index e1032177725..32410036197 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py @@ -305,8 +305,8 @@ PARAM_TO_COMMAND_KEYMAP = { 'neighbor': 'neighbor', 'additional_paths_receive': 'capability additional-paths receive', 'additional_paths_send': 'capability additional-paths send', - 'advertise_map_exist': 'advertise-map', - 'advertise_map_non_exist': 'advertise-map', + 'advertise_map_exist': 'advertise-map exist', + 'advertise_map_non_exist': 'advertise-map non-exist', 'allowas_in': 'allowas-in', 'allowas_in_max': 'allowas-in', 'as_override': 'as-override', @@ -599,7 +599,7 @@ def state_present(module, existing, proposed, candidate): command += ' disable' commands.append(command) elif key.startswith('advertise-map'): - direction = key.split()[0] + direction = key.split()[1] commands.append('advertise-map {1} {0} {2}'.format(direction, *value)) elif key in ['filter-list', 'prefix-list', 'route-map']: commands.append('{0} {1} {2}'.format(key, *value)) diff --git a/test/units/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/test/units/modules/network/nxos/test_nxos_bgp_neighbor_af.py index 49959a45272..ded3319be54 100644 --- a/test/units/modules/network/nxos/test_nxos_bgp_neighbor_af.py +++ b/test/units/modules/network/nxos/test_nxos_bgp_neighbor_af.py @@ -64,3 +64,19 @@ class TestNxosBgpNeighborAfModule(TestNxosModule): changed=True, sort=False, commands=['router bgp 65535', 'neighbor 3.3.3.5', 'no address-family ipv4 unicast'] ) + + def test_nxos_bgp_neighbor_af_advertise_map(self): + set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', + advertise_map_exist=['my_advertise_map', 'my_exist_map'])) + self.execute_module( + changed=True, sort=False, + commands=['router bgp 65535', 'neighbor 3.3.3.5', 'advertise-map my_advertise_map exist my_exist_map'] + ) + + def test_nxos_bgp_neighbor_af_advertise_map_non_exist(self): + set_module_args(dict(asn=65535, neighbor='3.3.3.5', afi='ipv4', safi='unicast', + advertise_map_non_exist=['my_advertise_map', 'my_exist_map'])) + self.execute_module( + changed=True, sort=False, + commands=['router bgp 65535', 'neighbor 3.3.3.5', 'advertise-map my_advertise_map non-exist my_exist_map'] + )