# stale tags/groups after changing tag values (dynamic inventory)

**URL:** <https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837>\
**Category:** AWX Project\
**Tags:** aws, awx\
**Created:** [March 23, 2021, 4:19pm UTC](https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837 "2021-03-23T16:19:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 23, 2021, 4:19pm UTC](https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837/1 "2021-03-23T16:19:20Z")

</div>

Hi Folks,

Dynamic inventory initially works great and creates host groups based on the AWS tags assigned to the ec2 hosts in y AWS account. However, if I then make a change to the tag value in AWS e.g. change from DEV to PROD and then re-run source sync in AWX, i find that it pulls in the new tag/group but does not remove the original tag/group assigned to the very same host.

This means i have stale tags associated with my hosts. I now have a group called DEV and PROD associated to the same host which is not in sync with my AWS tagging.

Is this there a workaround for this? otherwise this makes dynamic inventory not quite great.

Thanks,

---

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 24, 2021, 2:05pm UTC](https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837/2 "2021-03-24T14:05:37Z")

</div>

Deleting all groups/hosts and then re-syncing is not an option because we pass variables at the inventory group level. This would mean we need to re-insert the variable for all groups each time we make changes/add new tags to our AWS inventory.

---

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 24, 2021, 3:55pm UTC](https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837/3 "2021-03-24T15:55:43Z")

</div>

you can see the yml file being used for dynamic inventories below.

 ![dynamic_inventory.PNG](https://us1.discourse-cdn.com/ansible/original/2X/d/de83d88c138e85130770f6f218effc9d82025e1c.png)

> <https://github.com/bigred247/dynamicinventory/blob/master/inventories/aws/all_running_hosts.aws_ec2.yml>

---

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 25, 2021, 10:11am UTC](https://forum.ansible.com/t/stale-tags-groups-after-changing-tag-values-dynamic-inventory/34837/4 "2021-03-25T10:11:14Z")

</div>

Managed to resolve this issue by checking the “overwrite” button in the \> inventories \> sources (tab). See screenshot below:

 ![dynamic_overwrite_inventory.PNG](https://us1.discourse-cdn.com/ansible/original/2X/8/87be6a6d7838b18f785e393f545e8122cac91ff3.png)
