-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent role execution. #15409
Comments
Assuming I read the playbooks right, I think the problem, at least for 2.0.1.0, seems to be that variables from previous runs of the role are allowed to bleed into later runs. I have some playbooks that have only be run using 1.9.x that do multiple includes of the same role, and conditionals within the roles are being executed with previous values of the variables used in the condition. I can't speak to what's going on in 2.1; @pcastellazzi was rather vague as to what the actual correct behavior was, only that it's inconsistent between versions. I would expect that the correct behavior is that any role variables are reset to defaults when the role is executed again, and any variable set for previous role execution that do not have defaults should be deleted. In other words, subsequent runs of a role should occur in a clean, isolated environment without pollution from previous runs. I should be able to reason about how a role will run based solely on the input variables, without any knowledge of the environment that exists around the role. |
Sorry i was not clear enough. Variable bleeding is an issue, yes, but that's not what i meant with inconsistent. i.e.: With ansible 1.9.6 test1.yml run role1 4 times, the same as test3.yml, but test2.yml run it 3 times, even with It's my understanding that each unique role should be executed once, and a unique role include its parameters. A call to When you run this with ansible 2.x role1 is run 3 times on every case, which is again wrong because, for test2.yml it should run 4 times due to
|
There is one more inconsistency noticed Following scenario roles:
With this role 1 gets executed twice, without setting allow_duplicates:yes But for the following scenario roles:
Second instance to role1 only gets executed if allow_duplicates: yes is set. I have tried this on ansible 2.1, 2.2 and devel 2.3 they all have same behaviour. |
When the same role is listed consecutively in a play, the previous role completion detection failed to mark it as complete as it only checked to see if the role changed. This patch addresses that by also keeping track of which task in the role we are on, so that even if the same role is encountered during later passes the task number will be less than or equal to the last noted task position. Related to #15409
When the same role is listed consecutively in a play, the previous role completion detection failed to mark it as complete as it only checked to see if the role changed. This patch addresses that by also keeping track of which task in the role we are on, so that even if the same role is encountered during later passes the task number will be less than or equal to the last noted task position. Related to #15409
When the same role is listed consecutively in a play, the previous role completion detection failed to mark it as complete as it only checked to see if the role changed. This patch addresses that by also keeping track of which task in the role we are on, so that even if the same role is encountered during later passes the task number will be less than or equal to the last noted task position. Related to #15409
When the same role is listed consecutively in a play, the previous role completion detection failed to mark it as complete as it only checked to see if the role changed. This patch addresses that by also keeping track of which task in the role we are on, so that even if the same role is encountered during later passes the task number will be less than or equal to the last noted task position. Related to #15409 (cherry picked from commit fed079e)
When the same role is listed consecutively in a play, the previous role completion detection failed to mark it as complete as it only checked to see if the role changed. This patch addresses that by also keeping track of which task in the role we are on, so that even if the same role is encountered during later passes the task number will be less than or equal to the last noted task position. Related to #15409
Closing This TicketHi! We believe the above commit should resolve this problem for you. This will also be included in the next release. Do note however, that roles instantiated with different parameters are not considered duplicates, so for most of the examples in the original run you will see multiple invocations of the role. If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:
Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved. Thank you! |
ISSUE TYPE
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
SUMMARY
While migrating some playbooks to Ansible 2.0 i found some inconsistencies between different ansible versions, and most importantly in the same version depending of the syntax chosen.
Attached you while find a complete example with variations over the same theme, running the same role multiple times.
STEPS TO REPRODUCE
example.zip
EXPECTED RESULTS
All three playbooks should return the same result.
ACTUAL RESULTS
Each ansible version tested return different results for playbooks that should be equivalent.
The text was updated successfully, but these errors were encountered: