Repository: ansible/ansible

Issue:
(P1) nxos_vxlan_vtep_vni does not delete config when assoc_vrf is present
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
nxos_vxlan_vtep_vni

##### ANSIBLE VERSION
```
ansible 2.4.0 (devel 54cd641df4) last updated 2017/07/19 18:06:44 (GMT -400)
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/p2/Projects/nxos_ansible/p1_ansible/lib/ansible
  executable location = /root/p2/Projects/nxos_ansible/p1_ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
Ansible Server : Ubuntu 14.04
Device: NX-OSv9K running 7.0(3)I2(5)

##### SUMMARY
When a vxlan_vtep_vni configuration with associate-vrf is removed from device, it does not remove the configuration from the device. However, the playbook does not throw any errors too and it just silently passes the test.  

If we run the same test with {{ nxapi }}, there is an error:
```
fatal: [n9k.example.com]: FAILED! => {"changed": false, "clierror": "ERROR: VNI delete failed: Mismatched vni:6000 vrf association\n", "code": "400", "failed": true, "msg": "CLI execution error", "output": [{"body": {}, "code": "200", "msg": "Success"}, {"clierror": "ERROR: VNI delete failed: Mismatched vni:6000 vrf association\n", "code": "400", "msg": "CLI execution error"}], "url": "http://n9k.example.com:80/ins"}
```
The devices where this problem occurs are running versions:
n9k with 7.0(3)I2(5)
n9k with 7.0(3)I4(6)
n3k with 7.0(3)I6(1)

##### STEPS TO REPRODUCE
playbook:

<!--- Paste example playbooks or commands between quotes below -->
```
  - name: "Enable feature nv overlay"
    nxos_config: 
      commands:
        - feature nv overlay
      provider: "{{ cli }}"
      match: none

  - name: configure vxlan_vtep
    nxos_vxlan_vtep:
      interface: nve1
      host_reachability: True
      provider: "{{ cli }}"

  - name: configure vxlan_vtep_vni assoc-vrf
    nxos_vxlan_vtep_vni: &conf1
      interface: nve1
      vni: 6000
      assoc_vrf: True
      provider: "{{ cli }}"
    register: result

  - assert: &true
      that:
        - "result.changed == true"

  - name: "Conf 1 Idempotence"
    nxos_vxlan_vtep_vni: *conf1
    register: result

  - assert: &false
      that:
        - "result.changed == false"

  - name: remove vxlan_vtep_vni
    nxos_vxlan_vtep_vni:
      interface: nve1
      vni: 6000
      assoc_vrf: True
      state: absent
      provider: "{{ cli }}"
```

##### EXPECTED RESULTS
On the console, after running the above playbook, it should be:
```
camden-nx-2(config)# sh running-config int nve1

!Command: show running-config interface nve1
!Time: Tue Aug  8 21:13:21 2017

version 7.0(3)I2(5)

interface nve1
  host-reachability protocol bgp
```

##### ACTUAL RESULTS
```
camden-nx-2(config)# sh running-config int nve1

!Command: show running-config interface nve1
!Time: Tue Aug  8 21:13:21 2017

version 7.0(3)I2(5)

interface nve1
  host-reachability protocol bgp
  member vni 6000 associate-vrf ------> STILL PRESENT
```



Discussion:
cc @GGabriele @jedelman8 @mikewiebe @privateip @rahushen @rcarrillocruz @trishnaguha
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py
--- a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py
+++ b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py
@@ -107,7 +107,7 @@
 from ansible.module_utils.netcfg import CustomNetworkConfig
 
 BOOL_PARAMS = [
-    'assoc-vrf',
+    'assoc_vrf',
     'suppress_arp',
 ]
 PARAM_TO_COMMAND_KEYMAP = {
@@ -164,8 +164,7 @@ def get_existing(module, args):
         temp_config = netcfg.get_section(parents)
 
         if 'member vni {0} associate-vrf'.format(module.params['vni']) in temp_config:
-            parents.append('member vni {0} associate-vrf'.format(
-                module.params['vni']))
+            parents.append('member vni {0} associate-vrf'.format(module.params['vni']))
             config = netcfg.get_section(parents)
         elif "member vni {0}".format(module.params['vni']) in temp_config:
             parents.append('member vni {0}'.format(module.params['vni']))


Test patch: