Repository: ansible/ansible

Issue:
nxos_vpc confirmation prompt documentation needed
<!---
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
<!--- Name of the module/plugin/task/feature -->
nxos_vpc

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.4.0 (nxos_vpc ade593da52) last updated 2017/08/01 18:48:09 (GMT +550)
  config file = /home/tguha/RHWork/ansible/hacking/example/ansible.cfg
  configured module search path = [u'/home/tguha/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/tguha/RHWork/ansible/lib/ansible
  executable location = /home/tguha/RHWork/ansible/bin/ansible
  python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->
NX-OS 7.3
##### SUMMARY
<!--- Explain the problem briefly -->
nxos_vpc fails on confirmation prompt on a particular param `peer_gw` (peer-gateway). 
After testing this manually it is confirmed that peer-gateway does ask for confirmation on both nxapi and cli transport.
same with peer-gateway `false`.

##### 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 -->
```
    - name: Configure vpc port channel
      nxos_vpc:
        domain: 100
        role_priority: 32667
        system_priority: 2000
        peer_gw: true
        pkl_src: 10.1.100.2
        pkl_dest: 192.168.100.4
        auto_recovery: true
        provider: "{{ nxapi }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
nxos_vpc should work
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
Fails on confirmation prompt
<!--- Paste verbatim command output between quotes below -->
```
    "msg": "CLI execution error", 
    "output": [
        {
            "body": {}, 
            "code": "200", 
            "msg": "Success"
        }, 
        {
            "body": {}, 
            "code": "200", 
            "msg": "Success"
        }, 
        {
            "body": "Warning: \n Enables restoring of vPCs in a peer-detached state after reload, will wait for 240 seconds to determine if peer is un-reachable\n", 
            "code": "200", 
            "msg": "Success"
        }, 
        {
            "clierror": "\nThis peer-gateway config may cause traffic loss. Do you want to continue (y/n)? [[n] \n\n\n", 
            "code": "400", 
            "msg": "CLI execution error"
        }
    ], 
```


Discussion:
cc @GGabriele @jedelman8 @mikewiebe @privateip @rahushen @rcarrillocruz
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Since `peer-gateway` asks for confirmation, a way to handle this would be passing `terminal dont-ask` as command. `dont-ask` takes the default answer.
```
    - name: Disable prompt
      nxos_command:
        commands: terminal dont-ask

    - name: Configure vpc port channel
      nxos_vpc:
        domain: 100
        role_priority: 32667
        system_priority: 2000
        peer_gw: true
        pkl_src: 10.1.100.2
        pkl_dest: 192.168.100.4
        auto_recovery: true
```
this way `nxos_vpc` won't fail. 

Resolving patch:
diff --git a/lib/ansible/modules/network/nxos/nxos_vpc.py b/lib/ansible/modules/network/nxos/nxos_vpc.py
--- a/lib/ansible/modules/network/nxos/nxos_vpc.py
+++ b/lib/ansible/modules/network/nxos/nxos_vpc.py
@@ -95,8 +95,8 @@
 '''
 
 EXAMPLES = '''
-# configure a simple asn
-- nxos_vpc:
+- name: configure a simple asn
+  nxos_vpc:
     domain: 100
     role_priority: 1000
     system_priority: 2000
@@ -104,6 +104,24 @@
     pkl_src: 10.1.100.20
     peer_gw: true
     auto_recovery: true
+
+# peer-gateway might ask for confirmation to apply changes
+# Device should be configured with terminal dont-ask that makes
+# the device take default answer on confirmation prompt
+
+- name: Make device take default answer
+  nxos_command:
+    commands: terminal dont-ask
+
+- name: configure
+  nxos_vpc:
+    domain: 100
+    role_priority: 32667
+    system_priority: 2000
+    peer_gw: true
+    pkl_src: 10.1.100.2
+    pkl_dest: 192.168.100.4
+    auto_recovery: true
 '''
 
 RETURN = '''


Test patch: