Repository: ansible/ansible

Issue:
eos_vlan.py fails when running via transport eapi
<!---
Verify first that your issue/request is not already reported on GitHub.
THIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.
Also test if the latest release, and devel branch are affected too.
ALWAYS add information AFTER (OUTSIDE) these html comments.
Otherwise it may end up being automatically closed by our bot. -->

##### SUMMARY
eos_vlan fails when run with transport method eapi.  The reason is that ```show vlan conf`` is not a full command and by default eapi doesn't expand commands

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path-->

eos_vlan

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
dt@tactools:~$ ansible --version
ansible 2.5.1
  config file = None
  configured module search path = [u'/home/dt/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr 10 2015, 08:09:05) [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)]
```

##### CONFIGURATION
<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).-->

##### OS / ENVIRONMENT
<!--- Mention, BELOW THIS COMMENT, 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.-->

##### 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
- hosts: all
  connection: local
  gather_facts: false

  tasks:
    - name: Create vlan
      eos_vlan:
        vlan_id: 4000
        name: vlan-4000
        state: present
        provider: "{{ provider }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
The playbook should add the desired vlan
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->



<!--- Paste verbatim command output between quotes below -->
```

fatal: [mn100]: FAILED! => {
    "changed": false,
    "code": 1002,
    "invocation": {
        "module_args": {
            "aggregate": null,
            "associated_interfaces": null,
            "auth_pass": null,
            "authorize": true,
            "delay": 10,
            "host": "mn100",
            "interfaces": null,
            "name": "vlan-4000",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "provider": {
                "auth_pass": null,
                "authorize": true,
                "host": "mn100",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": 443,
                "ssh_keyfile": null,
                "timeout": 10,
                "transport": "eapi",
                "use_proxy": true,
                "use_ssl": true,
                "username": "admin",
                "validate_certs": true
            },
            "purge": false,
            "ssh_keyfile": null,
            "state": "present",
            "timeout": 10,
            "transport": "eapi",
            "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "url_username": "admin",
            "use_ssl": true,
            "username": "admin",
            "validate_certs": true,
            "vlan_id": 4000
        }
    },
    "msg": "CLI command 2 of 2 'show vlan conf ' failed: invalid command"

```



Discussion:
Files identified in the description:
* [lib/ansible/modules/network/eos/eos_vlan.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/eos/eos_vlan.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @privateip @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/eos/eos_vlan.py b/lib/ansible/modules/network/eos/eos_vlan.py
--- a/lib/ansible/modules/network/eos/eos_vlan.py
+++ b/lib/ansible/modules/network/eos/eos_vlan.py
@@ -213,7 +213,7 @@ def map_obj_to_commands(updates, module):
 
 def map_config_to_obj(module):
     objs = []
-    vlans = run_commands(module, ['show vlan conf | json'])
+    vlans = run_commands(module, ['show vlan configured-ports | json'])
 
     for vlan in vlans[0]['vlans']:
         obj = {}


Test patch: