diff --git a/app/models/manageiq/providers/ansible_runner_workflow.rb b/app/models/manageiq/providers/ansible_runner_workflow.rb index 521610fe4cf..4fbd150b006 100644 --- a/app/models/manageiq/providers/ansible_runner_workflow.rb +++ b/app/models/manageiq/providers/ansible_runner_workflow.rb @@ -50,6 +50,8 @@ def execute route_signal(:poll_runner) end + rescue => err + route_signal(:abort, "Failed to run ansible #{execution_type}: #{err}", "error") end def poll_runner diff --git a/lib/ansible/runner.rb b/lib/ansible/runner.rb index 73a5ddad931..284f9c97ab5 100644 --- a/lib/ansible/runner.rb +++ b/lib/ansible/runner.rb @@ -371,7 +371,15 @@ def wait_for(path, timeout: 10.seconds) path_created.set if added.include?(path) || modified.include?(path) end - thread = Thread.new { listener.start } + thread = Thread.new do + listener.start + rescue ArgumentError => err + # If the main thread raises an exception immediately it is possible + # for the ensure block to call `listener.stop` before this thread + # begins its execution resulting in an ArgumentError due to the state + # being `:stopped` + raise unless err.message.include?("cannot start from state :stopped") + end begin res = yield