Added filter plugin lists_mergeby. Fix #249 (#604)

This commit is contained in:
Vladimir Botka 2020-12-04 15:32:42 +01:00 committed by GitHub
commit 0f88c71f59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,23 @@
---
minor_changes:
- |
A new filter ``lists_mergeby`` to merge two lists of dictionaries by an attribute.
For example:
.. code-block:: yaml
[{'n': 'n1', 'p1': 'A', 'p2': 'F'},
{'n': 'n2', 'p2': 'B'}] | community.general.lists_mergeby(
[{'n': 'n1', 'p1': 'C'},
{'n': 'n2', 'p2': 'D'},
{'n': 'n3', 'p3': 'E'}], 'n') | list
evaluates to
.. code-block:: yaml
[{'n': 'n1', 'p1': 'C', 'p2': 'F'},
{'n': 'n2', 'p2': 'D'},
{'n': 'n3', 'p3': 'E'}]
(https://github.com/ansible-collections/community.general/pull/604).