Solvedansible delegate_to not propagated to include_role
✔️Accepted Answer
I would say this is a huge issue. If Ansible would have raised an error for combination of delegate_to
and include_role
, that would be sad, but normal. But Ansible after upgrade from 2.4 to 2.5 silently ignores delegate_to
and makes changes on a wrong server. It's like surgeon whom amputates a leg for a wrong patient. If the patient complains afterwards, surgeon answers, 'this is expected behavior'.
There is literally nothing in changelog for such a huge change. Moreover, even in the documentation for delegation and include_role
there is not a single word about this.
Other Answers:
As I understand this, the delegate_to
attribute for dynamic includes (include_*
) is simply swallowed and ignored. That's pretty annoying to debug, and probably should lead to a warning to help developers.
Very unprofessional behavior to make silent such kind of changes. And even not logical because i guess someone puting attributes there expects that they get applied for this include.
Import_role does not support with loops.
For loops and include_role and delegate combined, there is a workaround: https://medium.com/opsops/ansible-2-5-delegate-to-and-include-role-20cd7e67008e
(use loop+include, then delegate+import)
My role now is broken for this issue.
Is there any workaround?
[EDIT]
I found, I have to use import_role and then it works as before
ISSUE TYPE
COMPONENT NAME
delegate_to
include_role
ANSIBLE VERSION
Ansible devel f849dc9
CONFIGURATION
default
OS / ENVIRONMENT
CentOS7
SUMMARY
This issue is maybe related to #18315
CentOS7 ansible-2.4.2.0-1.el7.noarch does not have this problem
EXPECTED RESULTS
Actually I'm not sure if the result below is really expected.
ACTUAL RESULTS
Is there a standard way to prepare and submit such cases so they get included in Ansible's CI in order to avoid regressions?