Repository: ansible/ansible

Issue:
nxos_config is not idempotent
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
nxos_config

##### 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: Nexus9000 C9396PX running 7.0(3)I7(1)

##### SUMMARY
nxos_config is NOT idempotent any longer. Looks like 
https://github.com/ansible/ansible/pull/26565 is the culprit but not entirely sure.

Any configuration with any match criteria (line, strict or exact) is not idempotent now.

##### STEPS TO REPRODUCE
playbook:

```
- hosts: nxos
  connection: local
  gather_facts: no

  tasks:
  - name: setup
  nxos_config:
    lines: no ip access-list test
    provider: "{{ cli }}"
    match: none

  - name: configure sub level command
    nxos_config:
      lines: 10 permit ip any any log
      parents: ip access-list test
      provider: "{{ cli }}"
    register: result

  - assert:
      that:
        - "result.changed == true"
        - "'ip access-list test' in result.updates"
        - "'10 permit ip any any log' in result.updates"

  - name: configure sub level command idempotent check
    nxos_config:
      lines: 10 permit ip any any log
      parents: ip access-list test
      provider: "{{ cli }}"
    register: result

  - assert:
      that:
        - "result.changed == false"
  - name: teardown
    nxos_config:
      lines: no ip access-list test
      provider: "{{ cli }}"
      match: none
```

##### EXPECTED RESULTS
```
PLAY RECAP ********************************************************************************************************************************************
n9k.example.com          : ok=31   changed=2    unreachable=0    failed=0
```

##### ACTUAL RESULTS
```
TASK [nxos_config : configure sub level command idempotent check] *************************************************************************************
changed: [n9k.example.com]                                                                                                                           

TASK [nxos_config : assert] ***************************************************************************************************************************
fatal: [n9k.example.com]: FAILED! => {                                                                                                               
    "assertion": "result.changed == false",                                                                                                            
    "changed": false,                                                                                                                                  
    "evaluated_to": false,                                                                                                                             
    "failed": true                                                                                                                                     
}
```



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_config.py b/lib/ansible/modules/network/nxos/nxos_config.py
--- a/lib/ansible/modules/network/nxos/nxos_config.py
+++ b/lib/ansible/modules/network/nxos/nxos_config.py
@@ -283,7 +283,7 @@ def get_running_config(module, config=None):
         else:
             flags = ['all']
             contents = get_config(module, flags=flags)
-    return NetworkConfig(indent=3, contents=contents)
+    return NetworkConfig(indent=2, contents=contents)
 
 
 def get_candidate(module):


Test patch: