combine - merge two identical vars when list_merge=append or list_merge=prepend#79312
combine - merge two identical vars when list_merge=append or list_merge=prepend#79312R37ribution wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
tests and changelog? https://docs.ansible.com/ansible/latest/community/contributions.html
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
d8d1573 to
70bf94b
Compare
@bcoca I believe I have resolved your concerns. Can you have another look? Thanks, Aaron |
| # (this `if` can be remove without impact on the function | ||
| # except performance) | ||
| if x == {} or x == y: | ||
| if x == {} or (x == y and list_merge != 'append' and list_merge != 'prepend'): |
There was a problem hiding this comment.
list_merge not in ('append', 'prepend')
There was a problem hiding this comment.
can you also add a test to prevent regressions?
There was a problem hiding this comment.
I thought you might ask about not in - I'll get it added.
There was a problem hiding this comment.
Hey @bcoca, I made the code change. As far as the test goes, I'll need to dig into that as I'm not familiar with the creation of tests yet in this repo.
There was a problem hiding this comment.
can you also add a test to prevent regressions?
@bcoca Do you have any guides on how to create regression tests?
| # (this `if` can be remove without impact on the function | ||
| # except performance) | ||
| if x == {} or x == y: | ||
| if x == {} or (x == y and list_merge != 'append' and list_merge != 'prepend'): |
There was a problem hiding this comment.
can you also add a test to prevent regressions?
|
note: not for this PR, but perpend_unique/append_unique might be worth adding to keep the case in which the preexisting behavior is desired. |
6401f65 to
f7d8137
Compare
f7d8137 to
016f134
Compare
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
@webknjaz I have rebased with ... |
@bcoca I have ran the following tests according to the guide...
|
|
FTR the VyOS failure is unrelated. |
|
This needs to be rebased to unblock the CI. |
…when-vars-are-equal.yml - add changelog fragment for PR ansible#79312
016f134 to
c1219c9
Compare
This comment was marked as abuse.
This comment was marked as abuse.
done! |
|
The last piece to getting this completed AFAIK is getting the regression test in place that @bcoca requested. If someone has a guide or even an example of a similar regression test, I can get that implemented in this PR. |
diff --git a/test/integration/targets/filter_core/tasks/main.yml b/test/integration/targe
ts/filter_core/tasks/main.yml
index 4f538cf12ca..b2d6f25714e 100644
--- a/test/integration/targets/filter_core/tasks/main.yml
+++ b/test/integration/targets/filter_core/tasks/main.yml
@@ -209,6 +209,16 @@
- "'aHR0cHM6Ly93d3cucHl0aG9uLm9yZy9leGFtcGxlLTE=' | b64decode(urlsafe=True) == 'http
s://www.python.org/example-1'"
- set_fact:
+ foo_data:
+ profile_list:
+ - "test"
+ bar_data:
+ profile_list:
+ - "test"
+ result_data:
+ profile_list:
+ - "test"
+ - "test"
x:
x: x
key: x
@@ -271,6 +281,8 @@
- name: Verify combine filter
assert:
that:
+ - "foo_data | combine(bar_data, list_merge='append') == result_data"
+ - "foo_data | combine(bar_data, list_merge='prepend') == result_data"
- "([x] | combine) == x" |
| @@ -0,0 +1,2 @@ | |||
| bugfixes: | |||
| - combine - ``combine()`` filter did not merge two identical vars when using options ``list_merge='append'`` or ``list_merge='prepend'``. fix for ``def merge_hash`` function, defined in ``lib/ansible/utils/vars.py`` which is used by ``combine()``, to now append / prepend when merging vars which are equal (https://github.com/ansible/ansible/issues/79293). | |||
There was a problem hiding this comment.
| - combine - ``combine()`` filter did not merge two identical vars when using options ``list_merge='append'`` or ``list_merge='prepend'``. fix for ``def merge_hash`` function, defined in ``lib/ansible/utils/vars.py`` which is used by ``combine()``, to now append / prepend when merging vars which are equal (https://github.com/ansible/ansible/issues/79293). | |
| - filters - merge two identical vars when using ``combine`` options ``list_merge='append'`` or ``list_merge='prepend'`` (https://github.com/ansible/ansible/issues/79293). |
|
@R37ribution This PR is waiting for your response. Please respond or the PR will be closed. |
|
@R37ribution You have not responded to information requests in this PR so we will assume it no longer affects you. If you are still interested in this, please create a new PR with the requested information. |
|
Can someone help with reopening this? I'll get the tests that @Akasurde provided examples of integrated into the PR next week. I would rather not open a new PR and loose the history in this one. |
SUMMARY
Resolves #79293
ISSUE TYPE
COMPONENT NAME
resolves
combine()filter plugin not appending / prepending properly when the two vars to be combined are equalADDITIONAL INFORMATION
test.yaml playbook used to reproduce issue
Before change:
After change: