# How to rename VLANs with e.g. arista.eos.eos\_vlan, cisco.nxos.nxos\_vlans, etc.?

**URL:** <https://forum.ansible.com/t/how-to-rename-vlans-with-e-g-arista-eos-eos-vlan-cisco-nxos-nxos-vlans-etc/4070>\
**Category:** Get Help\
**Tags:** collections, network\
**Created:** [February 26, 2024, 7:18pm UTC](https://forum.ansible.com/t/how-to-rename-vlans-with-e-g-arista-eos-eos-vlan-cisco-nxos-nxos-vlans-etc/4070 "2024-02-26T19:18:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![athompson\_merlin](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@athompson\_merlin](https://forum.ansible.com/u/athompson_merlin)\
**Post date:** [February 26, 2024, 7:18pm UTC](https://forum.ansible.com/t/how-to-rename-vlans-with-e-g-arista-eos-eos-vlan-cisco-nxos-nxos-vlans-etc/4070/1 "2024-02-26T19:18:04Z")

</div>

I’ve figured out how to rename VLANs in aoscx, but I’m at a loss for how to do this in Arista EOS or Cisco IOS/IOSX/NXOS or most other platforms.

I have VLANs in the field that I want to rename, _without_ altering anything else about the VLAN.  
Right now, I’m pulling in a giant VLANS hash (dict?) with { vlan\_id , name } in it, and passing it to the repsective platform’s \_vlans module’s config: bit, in “merged” mode.  
Merged mode does not appear to update VLAN names on any of the platforms, although it will create the VLAN with the correct name if it’s missing.

With aoscx\_vlan, there’s no config object, I have to iterate anyway with `state: update`, and that seems to work.

I do NOT want to use `state: replaced` because that alters other VLAN properties, such as whether it’s enabled or not.

Anyone have a suggestion?

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 17, 2024, 8:19am UTC](https://forum.ansible.com/t/how-to-rename-vlans-with-e-g-arista-eos-eos-vlan-cisco-nxos-nxos-vlans-etc/4070/2 "2024-09-17T08:19:54Z")

</div>

Hi. I think the only other option is to use something like the cisco.ios.ios\_config module.

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [November 6, 2024, 8:13am UTC](https://forum.ansible.com/t/how-to-rename-vlans-with-e-g-arista-eos-eos-vlan-cisco-nxos-nxos-vlans-etc/4070/3 "2024-11-06T08:13:14Z")

</div>

Example from role:

```yaml
$ cat tasks/main.yml
---
- name: Ensure vlans.
  cisco.ios.ios_config:
    src: vlans.j2
    save_when: modified

$ cat templates/vlans.j2
{% for vlan_item in vlan_config %}
vlan {{ vlan_item['vlan_id'] }}
 name {{ vlan_item['name'] }}
{% endfor %}

$ cat defaults/main.yml
---
vlan_config:
  - name: Example1
    vlan_id: 10
  - name: Example2
    vlan_id: 20

```

This will create missing vlans or update the name if the vlan already exists. All other vlan parameters will remain untouched.
