Repository: ansible/ansible

Issue:
(P2)nxos_bgp - event_history properties and suppress_fib_pending are not idempotent
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
- nxos_bgp

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.4.0 (devel e8072ee616) last updated 2017/06/21 14:40:23 (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/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
- Ansible Server : Ubuntu 14.04
- Device: Nexus9000 C9508  running 7.0(3)I6(1)

##### SUMMARY
The properties event_history_cli, event_history_detail, event_history_events, event_history_periodic, suppress_fib_pending are not idempotent. The same playbook applied twice shows the result as 'changed'.

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
cli:
  host: "{{ inventory_hostname }}"
  username: "{{ nxos_cli_user | default('admin') }}"
  password: "{{ nxos_cli_pass | default('admin') }}"

nxapi:
  host: "{{ inventory_hostname }}"
  username: "{{ nxos_nxapi_user | default('admin') }}"
  password: "{{ nxos_nxapi_pass | default('admin') }}"
  transport: nxapi
  user_ssl: no

---
- name: NXOS Sample Playbook
  hosts: nxos
  connection: local
  gather_facts: no

  tasks:

  - name: Ensure BGP Is Enabled
    nxos_feature:
      feature: bgp
      state: enabled
      provider: "{{ cli }}"

  - name: "Configure BGP non defaults"
    nxos_bgp: &configure_non_default
      asn: 65535
      router_id: 1.1.1.1
      bestpath_always_compare_med: true
      bestpath_aspath_multipath_relax: true
      bestpath_compare_routerid: true
      bestpath_cost_community_ignore: true
      bestpath_med_confed: true
      bestpath_med_missing_as_worst: true
      bestpath_med_non_deterministic: true
      cluster_id: 10.0.0.1
      confederation_id: 99
      disable_policy_batching: true
      enforce_first_as: false
      fast_external_fallover: false
      flush_routes: true
      graceful_restart_helper: true
      graceful_restart_timers_restart: 130
      graceful_restart_timers_stalepath_time: 310
      isolate: false
      log_neighbor_changes: true
      maxas_limit: 50
      neighbor_down_fib_accelerate: true
      reconnect_interval: 55
      router_id: 192.168.0.66
      shutdown: true
      timer_bestpath_limit: 255
      timer_bgp_hold: 110
      timer_bgp_keepalive: 45
      event_history_cli: size_medium
      event_history_detail: size_large
      event_history_events: size_medium
      event_history_periodic: size_small
      suppress_fib_pending: true
      state: present
      provider: "{{ cli }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
When the above playbook is run a second time the result should be

PLAY RECAP ************************************************************************************************************************************************
nxxxx-x-xxx.example.com          : ok=2    changed=0    unreachable=0    failed=0 

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
PLAY RECAP ************************************************************************************************************************************************
nxxxx-x-xxx.example.com          : ok=2    changed=1    unreachable=0    failed=0
```

(P2)nxos_bgp - event_history properties and suppress_fib_pending are not idempotent
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
- nxos_bgp

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.4.0 (devel e8072ee616) last updated 2017/06/21 14:40:23 (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/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
- Ansible Server : Ubuntu 14.04
- Device: Nexus9000 C9508  running 7.0(3)I6(1)

##### SUMMARY
The properties event_history_cli, event_history_detail, event_history_events, event_history_periodic, suppress_fib_pending are not idempotent. The same playbook applied twice shows the result as 'changed'.

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
cli:
  host: "{{ inventory_hostname }}"
  username: "{{ nxos_cli_user | default('admin') }}"
  password: "{{ nxos_cli_pass | default('admin') }}"

nxapi:
  host: "{{ inventory_hostname }}"
  username: "{{ nxos_nxapi_user | default('admin') }}"
  password: "{{ nxos_nxapi_pass | default('admin') }}"
  transport: nxapi
  user_ssl: no

---
- name: NXOS Sample Playbook
  hosts: nxos
  connection: local
  gather_facts: no

  tasks:

  - name: Ensure BGP Is Enabled
    nxos_feature:
      feature: bgp
      state: enabled
      provider: "{{ cli }}"

  - name: "Configure BGP non defaults"
    nxos_bgp: &configure_non_default
      asn: 65535
      router_id: 1.1.1.1
      bestpath_always_compare_med: true
      bestpath_aspath_multipath_relax: true
      bestpath_compare_routerid: true
      bestpath_cost_community_ignore: true
      bestpath_med_confed: true
      bestpath_med_missing_as_worst: true
      bestpath_med_non_deterministic: true
      cluster_id: 10.0.0.1
      confederation_id: 99
      disable_policy_batching: true
      enforce_first_as: false
      fast_external_fallover: false
      flush_routes: true
      graceful_restart_helper: true
      graceful_restart_timers_restart: 130
      graceful_restart_timers_stalepath_time: 310
      isolate: false
      log_neighbor_changes: true
      maxas_limit: 50
      neighbor_down_fib_accelerate: true
      reconnect_interval: 55
      router_id: 192.168.0.66
      shutdown: true
      timer_bestpath_limit: 255
      timer_bgp_hold: 110
      timer_bgp_keepalive: 45
      event_history_cli: size_medium
      event_history_detail: size_large
      event_history_events: size_medium
      event_history_periodic: size_small
      suppress_fib_pending: true
      state: present
      provider: "{{ cli }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
When the above playbook is run a second time the result should be

PLAY RECAP ************************************************************************************************************************************************
nxxxx-x-xxx.example.com          : ok=2    changed=0    unreachable=0    failed=0 

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
PLAY RECAP ************************************************************************************************************************************************
nxxxx-x-xxx.example.com          : ok=2    changed=1    unreachable=0    failed=0
```



Discussion:
cc @jedelman8 @GGabriele @privateip @rcarrillocruz @mikewiebe @trishnaguha
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
#27329 fixes `event-history`, but I'm not seeing any idempotence issues with `suppress_fib_pending`. Can you get me some detailed output of this happening?
cc @jedelman8 @GGabriele @privateip @rcarrillocruz @mikewiebe @trishnaguha
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
#27329 fixes `event-history`, but I'm not seeing any idempotence issues with `suppress_fib_pending`. Can you get me some detailed output of this happening?

Resolving patch:
diff --git a/lib/ansible/modules/network/nxos/nxos_bgp.py b/lib/ansible/modules/network/nxos/nxos_bgp.py
--- a/lib/ansible/modules/network/nxos/nxos_bgp.py
+++ b/lib/ansible/modules/network/nxos/nxos_bgp.py
@@ -460,7 +460,7 @@ def get_value(arg, config):
 
 def get_existing(module, args, warnings):
     existing = {}
-    netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
+    netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=['bgp all']))
 
     asn_re = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+).*', re.S)
     asn_match = asn_re.match(str(netcfg))


Test patch: