From ed832c89f4d85d06d6b24efefc279379c248f4c3 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 9 Aug 2016 10:36:45 -0500 Subject: [PATCH] If rc is null, assume that a timeout happened. Fixes #2484 (#2485) --- lib/ansible/modules/extras/commands/expect.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/commands/expect.py b/lib/ansible/modules/extras/commands/expect.py index 4592179456b..4b5e5e8d623 100644 --- a/lib/ansible/modules/extras/commands/expect.py +++ b/lib/ansible/modules/extras/commands/expect.py @@ -214,7 +214,7 @@ def main(): if out is None: out = '' - module.exit_json( + ret = dict( cmd=args, stdout=out.rstrip('\r\n'), rc=rc, @@ -224,6 +224,12 @@ def main(): changed=True, ) + if rc: + module.exit_json(**ret) + else: + ret['msg'] = 'command exceeded timeout' + module.fail_json(**ret) + # import module snippets from ansible.module_utils.basic import *