Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

nxos_vlan

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: NX-OSv9K running 7.0(3)I2(5)

SUMMARY

If we configure mapped vni for vlan and try to remove the vlan afterwards, it fails saying

fatal: [n9k.example.com]: FAILED! => {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}

STEPS TO REPRODUCE

playbook:

- block:
- name: "Enable feature vn segment"
nxos_config:
commands:
- feature vn-segment-vlan-based
provider: "{{ cli }}"
match: none

- name: Ensure a range of VLANs are present on the switch
nxos_vlan: &conf_vlan
vlan_range: "2-10,20,50,55-60,100-150"
provider: "{{ cli }}"
register: result

- assert: &true
that:
- "result.changed == true"

- name: "Vlan Idempotence"
nxos_vlan: *conf_vlan
register: result

- assert: &false
that:
- "result.changed == false"

- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
nxos_vlan: &web1
vlan_id: 50
vlan_state: suspend
admin_state: down
name: WEB
mapped_vni: 5555
provider: "{{ cli }}"
register: result

- assert: *true

- name: "web Idempotence"
nxos_vlan: *web1
register: result

- assert: *false

- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
nxos_vlan: &web2
vlan_id: 50
vlan_state: suspend
admin_state: down
name: WEB
provider: "{{ cli }}"
register: result

- assert: *true

- name: "web Idempotence"
nxos_vlan: *web2
register: result

- assert: *false

- name: Ensure VLAN is NOT on the device
nxos_vlan: &no_vlan
vlan_id: 50
state: absent
provider: "{{ cli }}"
register: result

- assert: *true

- name: "no vlan Idempotence"
nxos_vlan: *no_vlan
register: result

- assert: *false

always:
- name: remove vlans
nxos_vlan:
vlan_range: "2-10,20,50,55-60,100-150"
state: absent
provider: "{{ cli }}"
ignore_errors: yes

- name: "Disable feature vn segement"
nxos_feature:
feature: vn-segment-vlan-based
state: disabled
provider: "{{ cli }}"
ignore_errors: yes=

EXPECTED RESULTS

PLAY RECAP ********************************************************************************************************************************************
n9k.example.com : ok=53 changed=13 unreachable=0 failed=0

ACTUAL RESULTS

TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! => {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

nxos_vlan

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: NX-OSv9K running 7.0(3)I2(5)

SUMMARY

If we configure mapped vni for vlan and try to remove the vlan afterwards, it fails saying

fatal: [n9k.example.com]: FAILED! => {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}

STEPS TO REPRODUCE

playbook:

- block:
- name: "Enable feature vn segment"
nxos_config:
commands:
- feature vn-segment-vlan-based
provider: "{{ cli }}"
match: none

- name: Ensure a range of VLANs are present on the switch
nxos_vlan: &conf_vlan
vlan_range: "2-10,20,50,55-60,100-150"
provider: "{{ cli }}"
register: result

- assert: &true
that:
- "result.changed == true"

- name: "Vlan Idempotence"
nxos_vlan: *conf_vlan
register: result

- assert: &false
that:
- "result.changed == false"

- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
nxos_vlan: &web1
vlan_id: 50
vlan_state: suspend
admin_state: down
name: WEB
mapped_vni: 5555
provider: "{{ cli }}"
register: result

- assert: *true

- name: "web Idempotence"
nxos_vlan: *web1
register: result

- assert: *false

- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
nxos_vlan: &web2
vlan_id: 50
vlan_state: suspend
admin_state: down
name: WEB
provider: "{{ cli }}"
register: result

- assert: *true

- name: "web Idempotence"
nxos_vlan: *web2
register: result

- assert: *false

- name: Ensure VLAN is NOT on the device
nxos_vlan: &no_vlan
vlan_id: 50
state: absent
provider: "{{ cli }}"
register: result

- assert: *true

- name: "no vlan Idempotence"
nxos_vlan: *no_vlan
register: result

- assert: *false

always:
- name: remove vlans
nxos_vlan:
vlan_range: "2-10,20,50,55-60,100-150"
state: absent
provider: "{{ cli }}"
ignore_errors: yes

- name: "Disable feature vn segement"
nxos_feature:
feature: vn-segment-vlan-based
state: disabled
provider: "{{ cli }}"
ignore_errors: yes=

EXPECTED RESULTS

PLAY RECAP ********************************************************************************************************************************************
n9k.example.com : ok=53 changed=13 unreachable=0 failed=0

ACTUAL RESULTS

TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! => {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}