<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">nxos_vlan</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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]"><pre class="notranslate"><code class="notranslate">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]
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ansible Server : Ubuntu 14.04<br>
Device: NX-OSv9K running 7.0(3)I2(5)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">If we configure mapped vni for vlan and try to remove the vlan afterwards, it fails saying</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [n9k.example.com]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# &quot;}
"><pre class="notranslate"><code class="notranslate">fatal: [n9k.example.com]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}

</code></pre></div>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">playbook:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- block:
  - name: &quot;Enable feature vn segment&quot;
    nxos_config: 
      commands:
        - feature vn-segment-vlan-based
      provider: &quot;{{ cli }}&quot;
      match: none

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

  - assert: &amp;true
      that:
        - &quot;result.changed == true&quot;

  - name: &quot;Vlan Idempotence&quot;
    nxos_vlan: *conf_vlan
    register: result

  - assert: &amp;false
      that:
        - &quot;result.changed == false&quot;

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

  - assert: *true

  - name: &quot;web Idempotence&quot;
    nxos_vlan: *web1
    register: result

  - assert: *false

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

  - assert: *true

  - name: &quot;web Idempotence&quot;
    nxos_vlan: *web2
    register: result

  - assert: *false

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

  - assert: *true

  - name: &quot;no vlan Idempotence&quot;
    nxos_vlan: *no_vlan
    register: result

  - assert: *false

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

    - name: &quot;Disable feature vn segement&quot;
      nxos_feature: 
        feature: vn-segment-vlan-based
        state: disabled
        provider: &quot;{{ cli }}&quot;
      ignore_errors: yes="><pre class="notranslate"><code class="notranslate">- 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: &amp;conf_vlan
      vlan_range: "2-10,20,50,55-60,100-150"
      provider: "{{ cli }}"
    register: result

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

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

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

  - name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
    nxos_vlan: &amp;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: &amp;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: &amp;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=
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY RECAP ********************************************************************************************************************************************
n9k.example.com      : ok=53   changed=13   unreachable=0    failed=0
"><pre class="notranslate"><code class="notranslate">PLAY RECAP ********************************************************************************************************************************************
n9k.example.com      : ok=53   changed=13   unreachable=0    failed=0

</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# &quot;} "><pre class="notranslate"><code class="notranslate">TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "} 
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">nxos_vlan</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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]"><pre class="notranslate"><code class="notranslate">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]
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ansible Server : Ubuntu 14.04<br>
Device: NX-OSv9K running 7.0(3)I2(5)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">If we configure mapped vni for vlan and try to remove the vlan afterwards, it fails saying</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [n9k.example.com]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# &quot;}
"><pre class="notranslate"><code class="notranslate">fatal: [n9k.example.com]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "}

</code></pre></div>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">playbook:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- block:
  - name: &quot;Enable feature vn segment&quot;
    nxos_config: 
      commands:
        - feature vn-segment-vlan-based
      provider: &quot;{{ cli }}&quot;
      match: none

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

  - assert: &amp;true
      that:
        - &quot;result.changed == true&quot;

  - name: &quot;Vlan Idempotence&quot;
    nxos_vlan: *conf_vlan
    register: result

  - assert: &amp;false
      that:
        - &quot;result.changed == false&quot;

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

  - assert: *true

  - name: &quot;web Idempotence&quot;
    nxos_vlan: *web1
    register: result

  - assert: *false

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

  - assert: *true

  - name: &quot;web Idempotence&quot;
    nxos_vlan: *web2
    register: result

  - assert: *false

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

  - assert: *true

  - name: &quot;no vlan Idempotence&quot;
    nxos_vlan: *no_vlan
    register: result

  - assert: *false

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

    - name: &quot;Disable feature vn segement&quot;
      nxos_feature: 
        feature: vn-segment-vlan-based
        state: disabled
        provider: &quot;{{ cli }}&quot;
      ignore_errors: yes="><pre class="notranslate"><code class="notranslate">- 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: &amp;conf_vlan
      vlan_range: "2-10,20,50,55-60,100-150"
      provider: "{{ cli }}"
    register: result

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

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

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

  - name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
    nxos_vlan: &amp;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: &amp;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: &amp;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=
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY RECAP ********************************************************************************************************************************************
n9k.example.com      : ok=53   changed=13   unreachable=0    failed=0
"><pre class="notranslate"><code class="notranslate">PLAY RECAP ********************************************************************************************************************************************
n9k.example.com      : ok=53   changed=13   unreachable=0    failed=0

</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# &quot;} "><pre class="notranslate"><code class="notranslate">TASK [nxos_vlan : Ensure VLAN is NOT on the device] ***************************************************************************************************
fatal: [n9k.example.com]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "no vn-segment\r\r\n                                   ^\r\n% Invalid command at '^' marker.\r\n\rn9k.example.com(config)# "} 
</code></pre></div>