# Duplicate dict key

**URL:** <https://forum.ansible.com/t/duplicate-dict-key/20300>\
**Category:** Ansible Project\
**Created:** [January 20, 2016, 11:43pm UTC](https://forum.ansible.com/t/duplicate-dict-key/20300 "2016-01-20T23:43:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Fortier](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@Josef\_Fortier](https://forum.ansible.com/u/Josef_Fortier)\
**Post date:** [January 20, 2016, 11:43pm UTC](https://forum.ansible.com/t/duplicate-dict-key/20300/1 "2016-01-20T23:43:50Z")

</div>

Updating to 2.0 throws a new error (certainly not an unreasonable error) in a play I’ve used for a while:  
found a duplicate dict key

I know I’m likely abusing behavior, but I’m hoping someone might offer an alternate approach 🙂

At a high level, I’m looking to

1. take output from a command
2. run regex tests against it against a set of dictionary keys
3. on match, execute a command with a dict value

But some of the dict keys duplicate others

More specifically, I’m running SuSE and want to restart services on a zypper update when they show up as being “stale” (zypper -ps)  
The major issue here, service names vary from version to version, and do not match precisely with the status output (zypper -ps)

I could possibly reverse the key value pairings, but there’s still likely to be duplication.

I’d not be surprised if this wasn’t working correctly before 2.0, but just silently discarding the duplication.

Thanks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 20, 2016, 11:48pm UTC](https://forum.ansible.com/t/duplicate-dict-key/20300/2 "2016-01-20T23:48:55Z")

</div>

that is exactly what was happening before 2.0, only the last value for  
the key was used, the rest were discarded.
