diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_af.py b/lib/ansible/modules/network/nxos/nxos_vrf_af.py index 4c6b033d8a..7207135a0d 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_af.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_af.py @@ -90,13 +90,11 @@ def main(): argument_spec = dict( vrf=dict(required=True), afi=dict(required=True, choices=['ipv4', 'ipv6']), - route_target_both_auto_evpn=dict(required=False, type='bool'), + state=dict(choices=['present', 'absent'], default='present'), - m_facts=dict(default=False, type='bool'), + m_facts=dict(default=False, type='bool', removed_in_version="2.4"), safi=dict(choices=['unicast', 'multicast'], removed_in_version="2.4"), - - state=dict(choices=['present', 'absent'], default='present') ) argument_spec.update(nxos_argument_spec) @@ -120,23 +118,27 @@ def main(): current = None commands = list() - - if not current and module.params['state'] == 'present': - commands.append('address-family %s unicast' % module.params['afi']) - if module.params['route_target_both_auto_evpn']: - commands.append('route-target both auto evpn') - - elif current and module.params['state'] == 'absent': + if current and module.params['state'] == 'absent': commands.append('no address-family %s unicast' % module.params['afi']) - elif current: - if module.params['route_target_both_auto_evpn']: - commands.append('address-family %s unicast' % module.params['afi']) - if 'route-target both auto evpn' in current: + elif module.params['state'] == 'present': + + 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') - else: + 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']) + if module.params['route_target_both_auto_evpn']: + commands.append('route-target both auto evpn') + if commands: commands.insert(0, 'vrf context %s' % module.params['vrf']) if not module.check_mode: