Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Sequenced include_tasks can silently crash the current play without error #49969
Certain sequences of include_tasks can crash the current play. This crashing comes without error and ansible happily stops running the current play then starts the next play.
OS / ENVIRONMENT
This was first observed on host running Ubuntu Bionic but reproduced in this simpler case on openSUSE tumbleweed.
STEPS TO REPRODUCE
The basic reproduction is to have a playbook run two plays. In the first play run two roles. In the first role include_tasks some tasks so that you have a task file that runs on hostsX and another task file that runs on hostsY. In the task file for hostsY include_tasks the tasks for hostsX. At this point the entire play stops running successfully. The second role in this play is not run and the second play is started. No indication of failure is given.
I've put all of this together at https://github.com/cboylan/ansible_include_tasks_crash as it isn't the smallest reproduction case.
At the very least I would expect the first role to fail, ansible to report failure and stop running the playbook. I think my biggest concern is that ansible silently fails here and will continue running subsequent plays, skipping and additional work in the first play that may be necessary for the next.
Ideally I would expect the second include_tasks to run those additional tasks as well. There are other ways to structure things if this was a clear failure/error though so I don't think this is absolutely required.
The underlying error that is causing this behavior is:
This is encountered, and then the include is effectively skipped.
The reason this happens, is that the
We need to duplicate the logic in
Fixing the include tasks piece is great. Thank you for that.
Is there another bug here where the unhandled exception doesn't result in the playbook run failing and stopping immediately? It seem that it is undesireable to fail to record the error and could be dangerous to keep running subsequent plays?
I am trying to handle both issues in my forthcoming PR.
At current, it still won't fail immediately on the templating error of the parent, but will provide a warning letting the user know the subsequent include may fail to find the file, and then it continues on.
Which, as the warning will state, may result in a failure to find the file.