ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

nxos_vlan returns "Command does not support JSON output" #3876

Closed RNanney closed 7 years ago

RNanney commented 8 years ago
ISSUE TYPE

nxos_vlan

ANSIBLE VERSION
vagrant@precise32:/vagrant$ ansible --version
ansible 2.1.0.0
  config file = /vagrant/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

ansible.cfg ask_pass = False gathering = explicit roles_path = /vagrant/roles/

OS / ENVIRONMENT

Running from vagrant precise32 Managing Cisco Nexus 3172 Chassis; System version: 6.0(2)U5(2)

SUMMARY

nxos_vlan module returns "Command does not support JSON output" however the vlans are added to the device

STEPS TO REPRODUCE

Example role

- name: Vlan configuration
  nxos_vlan:
    admin_state: "{{ item.admin_state | default(omit) }}"
    host: "{{ inventory_hostname }}"
    name: "{{ item.name | default(omit) }}"
    password: "{{ cisco.nexus.password }}"
    port: "{{ item.port | default(omit) }}"
    provider: "{{ provider | default(omit) }}"
    ssh_keyfile: "{{ ssh_keyfile | default(omit) }}"
    state: "{{ item.state | default(omit) }}"
    transport: "{{ transport | default('cli') }}"
    use_ssl: "{{ use_ssl | default(omit) }}"
    username: "{{ cisco.nexus.username }}"
    vlan_id: "{{ item.vlan_id | default(omit) }}"
    vlan_range: "{{ item.vlan_range | default(omit) }}"
    vlan_state: "{{ item.vlan_state | default(omit) }}"
  with_items: "{{ vlans }}"

Example group_vars:

vlans:
  - vlan_id: 500
    name: clbv2_vm_mgmt
    state: present
  - vlan_id: 600
    name: clbv2_vm_snet
    state: present
EXPECTED RESULTS

I expected the vlans to be added and the module to return 'changed'. Subsequent runs return 'ok'

ACTUAL RESULTS
vagrant@precise32:/vagrant$ ansible-playbook vlan_test.yml -i inventory/lab

PLAY [all] *********************************************************************

TASK [vlan : Include nxos vlan tasks] ******************************************
included: /vagrant/roles/vlan/tasks/nxos.yml for 10.127.49.31, 10.127.49.32

TASK [vlan : Vlan configuration] ***********************************************
failed: [10.127.49.32] (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_mgmt", "state": "present", "vlan_id": 500}, "msg": "Command does not support JSON output"}
failed: [10.127.49.31] (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_mgmt", "state": "present", "vlan_id": 500}, "msg": "Command does not support JSON output"}
failed: [10.127.49.32] (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_snet", "state": "present", "vlan_id": 600}, "msg": "Command does not support JSON output"}
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600})
    to retry, use: --limit @vlan_test.retry

PLAY RECAP *********************************************************************
10.127.49.31               : ok=1    changed=0    unreachable=0    failed=1
10.127.49.32               : ok=1    changed=0    unreachable=0    failed=1

vagrant@precise32:/vagrant$ ansible-playbook vlan_test.yml -i inventory/lab

PLAY [all] *********************************************************************

TASK [vlan : Include nxos vlan tasks] ******************************************
included: /vagrant/roles/vlan/tasks/nxos.yml for 10.127.49.31, 10.127.49.32

TASK [vlan : Vlan configuration] ***********************************************
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500})
ok: [10.127.49.31] => (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500})
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600})
ok: [10.127.49.31] => (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600})

PLAY RECAP *********************************************************************
10.127.49.31               : ok=2    changed=0    unreachable=0    failed=0
10.127.49.32               : ok=2    changed=0    unreachable=0    failed=0
privateip commented 8 years ago

/cc @jedelman8 @GGabriele

jedelman8 commented 8 years ago

Hi @RNanney This is interesting. Our testing has been predominantly on 7.0 code, but some minor nuances are popping up between versions of NX-OS. Let's dive into your platform + OS, because I just tested on 9396 and 7.0, and it's good. Initial tests were on 6.0 code too, but can't recall the release.

Can you provide the output of show vlan | json from the device before AND after you run the playbook? There seems to be something funky going on there.

Thanks.

RNanney commented 8 years ago

Hi @jedelman8, yeah this is strange but it seems to be working on our 9ks as well.

Before:

yc3-32-cin-nexus3172-2379242# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethernet1/23,Ethernet1/24,Eth
rnet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,Ethernet1/43,Ethernet1/44
Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/49,Ethernet1/51,Ethernet1/52,Ethernet1/53"}, {"vlanshowbr-vlanid": "40", "vlanshowbr-vlanid-utf": "40", "vlanshowbr-vlanname": "CBS-MGMT_10.21.224.0/22", "vlanshowbr-vlanstate": "active", "vlan
howbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "41", "vlanshowbr-vlanid-utf": "41", "vlanshowbr-vlanname": "CBS-DRAC_10.21.176.0/21", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "no
hutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "50", "vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlan
howplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "90", "vlanshowbr-vlanid-utf": "90", "vlanshowbr-vlanname": "CBS-FWtoF5_192.168.100.0/24", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx":
Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "100", "vlanshowbr-vlanid-utf": "100", "vlanshowbr-vlanname": "Acct1547246_CBS-NetDev_5.79.45.1", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/
1,Ethernet1/49"}, {"vlanshowbr-vlanid": "105", "vlanshowbr-vlanid-utf": "105", "vlanshowbr-vlanname": "VLAN0105", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vla
id": "106", "vlanshowbr-vlanid-utf": "106", "vlanshowbr-vlanname": "VLAN0106", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "305", "vlanshowbr-vlanid-utf
: "305", "vlanshowbr-vlanname": "VLAN0305", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "306", "vlanshowbr-vlanid-utf": "306", "vlanshowbr-vlanname": "V
AN0306", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "875", "vlanshowbr-vlanid-utf": "875", "vlanshowbr-vlanname": "VLAN0875", "vlanshowbr-vlanstate": "
ctive", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/4,Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "881", "vlanshowbr-vlanid-utf": "881", "vlanshowbr-vlanname": "VLAN0881", "vlanshowbr-vlanstate": "active", "vlanshowbr-sh
tstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "924", "vlanshowbr-vlanid-utf": "924", "vlanshowbr-vlanname": "VLAN0924", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowpl
st-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "953", "vlanshowbr-vlanid-utf": "953", "vlanshowbr-vlanname": "VLAN0953", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1
49"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vlanid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "40", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshow
nfo-vlanid": "41", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "50", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "90", "vlanshowinfo-media-type": "enet
, "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "100", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "105", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshow
nfo-vlanid": "106", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "305", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "306", "vlanshowinfo-media-type": "e
et", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "875", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "881", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlans
owinfo-vlanid": "924", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "953", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}
!
yc3-32-cin-nexus3172-2379243# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/4,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/13,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethe
net1/23,Ethernet1/24,Ethernet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,
thernet1/43,Ethernet1/44,Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/51,Ethernet1/52,Ethernet1/54"}, {"vlanshowbr-vlanid": "40", "vlanshowbr-vlanid-utf": "40", "vlanshowbr-vlanname": "CBS-MGMT_10.21.224.0/22", "vlanshowbr-vlanstate": "ac
ive", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "41", "vlanshowbr-vlanid-utf": "41", "vlanshowbr-vlanname": "CBS-DRAC_10.21.176.0/21", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "50",
vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "90", "vlanshowbr-vlanid-utf": "90", "vlanshowbr-vlanname": "CBS-FWtoF5_19
.168.100.0/24", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "100", "vlanshowbr-vlanid-utf": "100", "vlanshowbr-vlanname": "Acct1547246_CBS-NetDev_5.79.45.1", "vlanshowbr-vlanstate": "active", "vlanshowbr-
hutstate": "noshutdown"}, {"vlanshowbr-vlanid": "105", "vlanshowbr-vlanid-utf": "105", "vlanshowbr-vlanname": "VLAN0105", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "106", "vlanshowbr-vlanid-utf": "106",
"vlanshowbr-vlanname": "VLAN0106", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "305", "vlanshowbr-vlanid-utf": "305", "vlanshowbr-vlanname": "VLAN0305", "vlanshowbr-vlanstate": "active", "vlanshowbr-shuts
ate": "noshutdown"}, {"vlanshowbr-vlanid": "306", "vlanshowbr-vlanid-utf": "306", "vlanshowbr-vlanname": "VLAN0306", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vlanid": "1",
vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "40", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "41", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vla
mode": "ce-vlan"}, {"vlanshowinfo-vlanid": "50", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "90", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "100", "
lanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "105", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "106", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vl
nmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "305", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "306", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}

After:

yc3-32-cin-nexus3172-2379242# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethernet1/23,Ethernet1/24,Eth
rnet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,Ethernet1/43,Ethernet1/44
Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/49,Ethernet1/51,Ethernet1/52,Ethernet1/53"}, {"vlanshowbr-vlanid": "40", "vlanshowbr-vlanid-utf": "40", "vlanshowbr-vlanname": "CBS-MGMT_10.21.224.0/22", "vlanshowbr-vlanstate": "active", "vlan
howbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "41", "vlanshowbr-vlanid-utf": "41", "vlanshowbr-vlanname": "CBS-DRAC_10.21.176.0/21", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "no
hutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "50", "vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlan
howplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "90", "vlanshowbr-vlanid-utf": "90", "vlanshowbr-vlanname": "CBS-FWtoF5_192.168.100.0/24", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx":
Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "100", "vlanshowbr-vlanid-utf": "100", "vlanshowbr-vlanname": "Acct1547246_CBS-NetDev_5.79.45.1", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/
1,Ethernet1/49"}, {"vlanshowbr-vlanid": "105", "vlanshowbr-vlanid-utf": "105", "vlanshowbr-vlanname": "VLAN0105", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vla
id": "106", "vlanshowbr-vlanid-utf": "106", "vlanshowbr-vlanname": "VLAN0106", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "305", "vlanshowbr-vlanid-utf
: "305", "vlanshowbr-vlanname": "VLAN0305", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "306", "vlanshowbr-vlanid-utf": "306", "vlanshowbr-vlanname": "V
AN0306", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "500", "vlanshowbr-vlanid-utf": "500", "vlanshowbr-vlanname": "clbv2_vm_mgmt", "vlanshowbr-vlanstat
": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "600", "vlanshowbr-vlanid-utf": "600", "vlanshowbr-vlanname": "clbv2_vm_snet", "vlanshowbr-vlanstate": "active", "vlanshowbr-shut
tate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "875", "vlanshowbr-vlanid-utf": "875", "vlanshowbr-vlanname": "VLAN0875", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplis
-ifidx": "Ethernet1/4,Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlanid": "881", "vlanshowbr-vlanid-utf": "881", "vlanshowbr-vlanname": "VLAN0881", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31
Ethernet1/49"}, {"vlanshowbr-vlanid": "924", "vlanshowbr-vlanid-utf": "924", "vlanshowbr-vlanname": "VLAN0924", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}, {"vlanshowbr-vlani
": "953", "vlanshowbr-vlanid-utf": "953", "vlanshowbr-vlanname": "VLAN0953", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "Ethernet1/31,Ethernet1/49"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vl
nid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "40", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "41", "vlanshowinfo-media-type": "enet", "vlan
howinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "50", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "90", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlani
": "100", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "105", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "106", "vlanshowinfo-media-type": "enet", "vla
showinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "305", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "306", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vl
nid": "500", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "600", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "875", "vlanshowinfo-media-type": "enet", "
lanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "881", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "924", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo
vlanid": "953", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}
!
yc3-32-cin-nexus3172-2379243# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/4,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/13,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethe
net1/23,Ethernet1/24,Ethernet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,
thernet1/43,Ethernet1/44,Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/51,Ethernet1/52,Ethernet1/54"}, {"vlanshowbr-vlanid": "40", "vlanshowbr-vlanid-utf": "40", "vlanshowbr-vlanname": "CBS-MGMT_10.21.224.0/22", "vlanshowbr-vlanstate": "ac
ive", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "41", "vlanshowbr-vlanid-utf": "41", "vlanshowbr-vlanname": "CBS-DRAC_10.21.176.0/21", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "50",
vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "90", "vlanshowbr-vlanid-utf": "90", "vlanshowbr-vlanname": "CBS-FWtoF5_19
.168.100.0/24", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "100", "vlanshowbr-vlanid-utf": "100", "vlanshowbr-vlanname": "Acct1547246_CBS-NetDev_5.79.45.1", "vlanshowbr-vlanstate": "active", "vlanshowbr-
hutstate": "noshutdown"}, {"vlanshowbr-vlanid": "105", "vlanshowbr-vlanid-utf": "105", "vlanshowbr-vlanname": "VLAN0105", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "106", "vlanshowbr-vlanid-utf": "106",
"vlanshowbr-vlanname": "VLAN0106", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "305", "vlanshowbr-vlanid-utf": "305", "vlanshowbr-vlanname": "VLAN0305", "vlanshowbr-vlanstate": "active", "vlanshowbr-shuts
ate": "noshutdown"}, {"vlanshowbr-vlanid": "306", "vlanshowbr-vlanid-utf": "306", "vlanshowbr-vlanname": "VLAN0306", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "500", "vlanshowbr-vlanid-utf": "500", "vla
showbr-vlanname": "clbv2_vm_mgmt", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "600", "vlanshowbr-vlanid-utf": "600", "vlanshowbr-vlanname": "clbv2_vm_snet", "vlanshowbr-vlanstate": "active", "vlanshowbr-
hutstate": "noshutdown"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vlanid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "40", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "c
-vlan"}, {"vlanshowinfo-vlanid": "41", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "50", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "90", "vlanshowinf
-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "100", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "105", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "c
-vlan"}, {"vlanshowinfo-vlanid": "106", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "305", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "306", "vlanshow
nfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "500", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "600", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode":
"ce-vlan"}]}}

Interesting enough this time around the playbook output looks different.

vagrant@precise32:/vagrant$ ansible-playbook vlan_test.yml -i inventory/lab

PLAY [all] *********************************************************************

TASK [vlan : Include nxos vlan tasks] ******************************************
included: /vagrant/roles/vlan/tasks/nxos.yml for 10.127.49.31, 10.127.49.32

TASK [vlan : Vlan configuration] ***********************************************
failed: [10.127.49.32] (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_mgmt", "state": "present", "vlan_id": 500}, "msg": "Command does not support JSON output"}
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500})
failed: [10.127.49.32] (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_snet", "state": "present", "vlan_id": 600}, "msg": "Command does not support JSON output"}
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600})
    to retry, use: --limit @vlan_test.retry

PLAY RECAP *********************************************************************
10.127.49.31               : ok=2    changed=1    unreachable=0    failed=0
10.127.49.32               : ok=1    changed=0    unreachable=0    failed=1
jedelman8 commented 8 years ago

Odd. I see this.

First...

{"vlanshowbr-vlanid": "50", vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}

which is in the after of this device yc3-32-cin-nexus3172-2379243# sh vlan | json

Background...

The reason that failure message is displayed is because there is a Python ValueError in the nxos_vlan module and where it's located, it's because there is invalid JSON. So, I started to try and lint the JSON, and then visually saw what's above. Notice the key vlanshowbr-vlanid-utf doesn't have starting quotes. Please confirm you are seeing this too :) - getting late on my side.

If this is the case, the missing quotes is clearly invalid JSON. I wonder if there is a nxos bug when using | json that sometimes it forgets to add quotes. Can you do more testing on the CLI adding/removing VLANs, checking the output, checking the JSON object returned, etc.

last...

Would you mind confirming the module works for you when using NX-API? Would be interesting to see if there is invalid JSON in one and not the other...

From the other device (quotes are good):

{"vlanshowbr-vlanid": "50", "vlanshowbr-vlanid-utf": "50", "vlanshowbr-vlanname": "Acct#1547246_162.13.17.216/29", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanhowplist-ifidx": "Ethernet1/31,Ethernet1/49"},

RNanney commented 8 years ago

Thanks for looking in to this so late in your day. This is working when using transport=nxapi. Is it possible this has something to do with line wrapping. If you notice that key that is missing double quotes on device 2379243 falls on the edge of the output. I tried messing with the vlans and came up with something similar on the same device

yc3-32-cin-nexus3172-2379243# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/4,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/13,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethe
net1/23,Ethernet1/24,Ethernet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,
thernet1/43,Ethernet1/44,Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/51,Ethernet1/52,Ethernet1/54"}, {"vlanshowbr-vlanid": "500", "vlanshowbr-vlanid-utf": "500", "vlanshowbr-vlanname": "clbv2_vm_mgmt", "vlanshowbr-vlanstate": "active", "
lanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "503", "vlanshowbr-vlanid-utf": "503", "vlanshowbr-vlanname": "test_add_503", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "505", "vlanshowbr-vlan
d-utf": "505", "vlanshowbr-vlanname": "test_add_505", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "507", "vlanshowbr-vlanid-utf": "507", "vlanshowbr-vlanname": "test_add_507", "vlanshowbr-vlanstate": "act
ve", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "600", "vlanshowbr-vlanid-utf": "600", "vlanshowbr-vlanname": "clbv2_vm_snet", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{
vlanshowinfo-vlanid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "500", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "503", "vlanshowinfo-media-ty
e": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "505", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "507", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"},
"vlanshowinfo-vlanid": "600", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}

Notice the missing quote on the "vlanshowinfo-vlanid" key:

{"ROW_mtuinfo": [{
vlanshowinfo-vlanid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}

Were you able to decode the json from the 2379242 device? I also found missing double quotes at the character positions 1785, (which may be coincidence but that is also the same character position that the quote is missing in the output from device 2379243 above), 2554, 4340. The output from 2379243 only has 2398 characters.

yc3-32-cin-nexus3172-2379242# sh run int mgmt0

!Command: show running-config interface mgmt0
!Time: Wed Jun  8 04:10:52 2016

version 6.0(2)U5(2)

interface mgmt0
  vrf member management
  ip address 10.127.49.31/26

After I manually added in the double quotes I was able to decode the json from 2379242. If it's necessary tomorrow I can add some vlans back to 2379243 to increase the characters in that output and check the positions of missing double quotes.

jedelman8 commented 8 years ago

I do agree, there is a small coincidence with where it's wrapping the line, but if you want try changing your terminal width and see what happens :)

Regardless, I don't think it's an issue with the module. Will let Cisco know so they can provide feedback too although I do know they will probably recommend a different version of NXOS. Are you locked into this version?

RNanney commented 8 years ago

Ok, I've been experimenting with this more and while the character position from last night appears to be a coincidence I'm leaning more towards the line wrapping issue with the output. You can see below that there should be a comma before {"vlanshowbr-vlanid": "110"

yc3-32-cin-nexus3172-2379243# sh vlan | json
{"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown", "vlanshowplist-ifidx": "port-channel999,Ethernet1/1,E
hernet1/2,Ethernet1/4,Ethernet1/5,Ethernet1/6,Ethernet1/7,Ethernet1/8,Ethernet1/9,Ethernet1/10,Ethernet1/11,Ethernet1/12,Ethernet1/13,Ethernet1/14,Ethernet1/15,Ethernet1/16,Ethernet1/17,Ethernet1/18,Ethernet1/19,Ethernet1/20,Ethernet1/21,Ethernet1/22,Ethe
net1/23,Ethernet1/24,Ethernet1/25,Ethernet1/26,Ethernet1/27,Ethernet1/28,Ethernet1/29,Ethernet1/30,Ethernet1/31,Ethernet1/32,Ethernet1/33,Ethernet1/34,Ethernet1/35,Ethernet1/36,Ethernet1/37,Ethernet1/38,Ethernet1/39,Ethernet1/40,Ethernet1/41,Ethernet1/42,
thernet1/43,Ethernet1/44,Ethernet1/45,Ethernet1/46,Ethernet1/47,Ethernet1/48,Ethernet1/51,Ethernet1/52,Ethernet1/54"}, {"vlanshowbr-vlanid": "100", "vlanshowbr-vlanid-utf": "100", "vlanshowbr-vlanname": "BNRwrKXghNXfwwAZhnIZIyLsvcJITuKD", "vlanshowbr-vlan
tate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "101", "vlanshowbr-vlanid-utf": "101", "vlanshowbr-vlanname": "hPmCNjFuofcFlMOwykCyteaEQbRrYShI", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlan
howbr-vlanid": "102", "vlanshowbr-vlanid-utf": "102", "vlanshowbr-vlanname": "UjSsVWHwlquJjZLqjWzFvFLvkithuXHI", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "103", "vlanshowbr-vlanid-utf": "103", "vlansho
br-vlanname": "VvwWbwPQNEYiieOTaTDYUbcmoVYGMvvl", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "104", "vlanshowbr-vlanid-utf": "104", "vlanshowbr-vlanname": "roCjwDXDViwcaokpgScJZewjMBqMOYuO", "vlanshowbr-
lanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "105", "vlanshowbr-vlanid-utf": "105", "vlanshowbr-vlanname": "hssoqUdmANzWRzJItbvWZoqMSLppfIjW", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"
lanshowbr-vlanid": "106", "vlanshowbr-vlanid-utf": "106", "vlanshowbr-vlanname": "KioaZvZslIsldZqmLeYHQaouYSVUBvdB", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "107", "vlanshowbr-vlanid-utf": "107", "vla
showbr-vlanname": "DGAgUfHDGLgUiWWwALylCwNfWvvOmKVC", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "108", "vlanshowbr-vlanid-utf": "108", "vlanshowbr-vlanname": "QsKgPerOyURvDaHYgZGMWdCgkHZkVAxu", "vlansho
br-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "109", "vlanshowbr-vlanid-utf": "109", "vlanshowbr-vlanname": "BIjHuAqeVSwVWEjoGMbqYyoEFdHjoumM", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}
 {"vlanshowbr-vlanid": "110", "vlanshowbr-vlanid-utf": "110", "vlanshowbr-vlanname": "sUpSbgeeGizwDHuTlZFPKqsHCevSDnTj", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "111", "vlanshowbr-vlanid-utf": "111",
vlanshowbr-vlanname": "YfTKhtllaJuVWszIYgmKgyCJIBDmPxUa", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "112", "vlanshowbr-vlanid-utf": "112", "vlanshowbr-vlanname": "CbjiVUOxFIwoVyebTcrpoQKkFqFceYBJ", "vla
showbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "113", "vlanshowbr-vlanid-utf": "113", "vlanshowbr-vlanname": "ZIVuscmkThcrMkkOJlQepVyfcOAYvHqi", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdo
n"}, {"vlanshowbr-vlanid": "114", "vlanshowbr-vlanid-utf": "114", "vlanshowbr-vlanname": "kDQNfMypVUkAUzgSurIpwXpeiXufFGJN", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "500", "vlanshowbr-vlanid-utf": "50
", "vlanshowbr-vlanname": "clbv2_vm_mgmt", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "503", "vlanshowbr-vlanid-utf": "503", "vlanshowbr-vlanname": "test_add_503", "vlanshowbr-vlanstate": "active", "vlan
howbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "505", "vlanshowbr-vlanid-utf": "505", "vlanshowbr-vlanname": "test_add_505", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "507", "vlanshowbr-vlanid-u
f": "507", "vlanshowbr-vlanname": "test_add_507", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "600", "vlanshowbr-vlanid-utf": "600", "vlanshowbr-vlanname": "clbv2_vm_snet", "vlanshowbr-vlanstate": "active
, "vlanshowbr-shutstate": "noshutdown"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vlanid": "1", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "100", "vlanshowinfo-media-type": "enet", "vlanshowin
o-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "101", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "102", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid":
103", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "104", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "105", "vlanshowinfo-media-type": "enet", "vlansho
info-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "106", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "107", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid
: "108", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "109", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "110", "vlanshowinfo-media-type": "enet", "vlan
howinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "111", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "112", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vla
id": "113", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "114", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "500", "vlanshowinfo-media-type": "enet", "v
anshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "503", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "505", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-
lanid": "507", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "600", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}

I also witnessed this happening on the .31 host as well.

vagrant@precise32:/vagrant$ ansible-playbook vlan_test.yml -i inventory/lab

PLAY [all] *********************************************************************

TASK [vlan : Include nxos vlan tasks] ******************************************
included: /vagrant/roles/vlan/tasks/nxos.yml for 10.127.49.31, 10.127.49.32

TASK [vlan : Vlan configuration] ***********************************************
failed: [10.127.49.31] (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_mgmt", "state": "present", "vlan_id": 500}, "msg": "Command does not support JSON output"}
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'clbv2_vm_mgmt', u'vlan_id': 500})
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'test_add_503', u'vlan_id': 503})
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'test_add_503', u'vlan_id': 503})
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'test_add_505', u'vlan_id': 505})
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'test_add_507', u'vlan_id': 507})
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'test_add_505', u'vlan_id': 505})
ok: [10.127.49.32] => (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600})
changed: [10.127.49.31] => (item={u'state': u'present', u'name': u'test_add_507', u'vlan_id': 507})
failed: [10.127.49.31] (item={u'state': u'present', u'name': u'clbv2_vm_snet', u'vlan_id': 600}) => {"command": "show vlan | json", "failed": true, "item": {"name": "clbv2_vm_snet", "state": "present", "vlan_id": 600}, "msg": "Command does not support JSON output"}
    to retry, use: --limit @vlan_test.retry

PLAY RECAP *********************************************************************
10.127.49.31               : ok=1    changed=0    unreachable=0    failed=1
10.127.49.32               : ok=2    changed=0    unreachable=0    failed=0

I agree with you that the issue is more with the way the json is returned by the device, but is there a way that the module could accommodate this? We are running variants of 6.0 in production. I logged in to one switch at random and it doesn't even support json/nxapi :-/

I did change the terminal width from 270 to 511, but that hasn't affected the output.

Also, the .32 host is running 6.0(2)U4(3) and .31 has 6.0(2)U5(2).

Thanks again for your help.

jedelman8 commented 8 years ago

Summary: we've seen missing quotes and commas and there is invalid JSON being returned.

The workarounds that I'm thinking of would be either to fix the bad JSON object somehow or if there is an error raised, I suppose, we can re-connect to the device and get ASCII text back, and then parse show vlan without the | json. Personally, I don't like either and could set wrong expectations going forward, but the second approach is doable.

@privateip - what do you think?

sivel commented 8 years ago

Just a thought here, but since these typically run locally, we would have access to pyyaml. The YAML parser can parse JSON, and is more lenient, as not having quotes is valid YAML.

jedelman8 commented 8 years ago

Sounds interesting, but one of the issues was a missing a comma too

privateip commented 8 years ago

@sivel these modules work with delegate_to so you cannot be assured of pyyaml

privateip commented 8 years ago

@jedelman8 @RNanney is the missing " consistent or intermittent? i don't believe terminal width is the issue here, i have a funny feeling its how nxos generates the json output but thats just my gut telling me that

RNanney commented 8 years ago

@privateip I'm not sure how to answer that. You can see in my last playbook run that the first vlan add on the .31 host failed (but the vlan was actually added) and the next add on the same host came back as changed. I'm assuming this is because of the additional characters caused the lines to break at different positions. Then you can see the last add for the .31 host fails again.

jedelman8 commented 8 years ago

It's still changing because we query the device after the change to get the list of VLANs again. That is where it's failing. Still, not sure what we do here?

On Wed, Jun 8, 2016 at 11:54 AM, RNanney notifications@github.com wrote:

@privateip https://github.com/privateip I'm not sure how to answer that. You can see in my last playbook run that the first vlan add on the .31 host failed (but the vlan was actually added) and the next add on the same host came back as changed. I'm assuming this is because of the additional characters caused the lines to break at different positions. Then you can see the last add for the .31 host fails again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ansible/ansible-modules-core/issues/3876#issuecomment-224635586, or mute the thread https://github.com/notifications/unsubscribe/AGCgqkujLwzMDsPGmUY-GSS135LAOR0uks5qJuWogaJpZM4IvLrU .

heathdbrown commented 8 years ago

Just an fyi, we opened a bug report with Cisco on the issue in:

We will also try upgrading the code version to something higher in the 6.0.2.U6 code train.

ansibot commented 8 years ago

@privateip, @GGabriele, ping. This issue is still waiting on your response. click here for bot help

gundalow commented 8 years ago

@heathdbrown What response did you get from Cisco?

ansibot commented 8 years ago

@jedelman8, @GGabriele, @privateip, @gundalow, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@jedelman8, @GGabriele, @privateip, @gundalow, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@jedelman8, @GGabriele, @privateip, @gundalow, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@jedelman8, @GGabriele, @privateip, @gundalow, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@jedelman8, @GGabriele, @privateip, @gundalow, @qalthos, ping. This issue is still waiting on your response. click here for bot help

heathdbrown commented 7 years ago

@gundalow we did not get a response back and I am following back up to see if the issue got missed somewhere.

gundalow commented 7 years ago

@heathdbrown Thanks for the update

ansibot commented 7 years ago

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

ansibot commented 7 years ago

This issue was migrated to https://github.com/ansible/ansible/issues/29784