Skip to content
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

Don't swallow exceptions when processing included files #54791

Merged
merged 3 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/include-no-swallow-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- include_role - Don't swallow errors when processing included files/roles (https://github.com/ansible/ansible/issues/54786)
15 changes: 6 additions & 9 deletions lib/ansible/plugins/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,15 +893,12 @@ def _do_handler_run(self, handler, handler_name, iterator, play_context, notifie
# collect the results from the handler run
host_results = self._wait_on_handler_results(iterator, handler, notified_hosts)

try:
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)
except AnsibleError:
return False
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)

result = True
if len(included_files) > 0:
Expand Down
15 changes: 6 additions & 9 deletions lib/ansible/plugins/strategy/free.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,12 @@ def run(self, iterator, play_context):

self.update_active_connections(results)

try:
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)
except AnsibleError as e:
return self._tqm.RUN_ERROR
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)

if len(included_files) > 0:
all_blocks = dict((host, []) for host in hosts_left)
Expand Down
16 changes: 6 additions & 10 deletions lib/ansible/plugins/strategy/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,12 @@ def run(self, iterator, play_context):

self.update_active_connections(results)

try:
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)
except AnsibleError as e:
# this is a fatal error, so we abort here regardless of block state
return self._tqm.RUN_ERROR
included_files = IncludedFile.process_include_results(
host_results,
iterator=iterator,
loader=self._loader,
variable_manager=self._variable_manager
)

include_failure = False
if len(included_files) > 0:
Expand Down