From 82c806979be7dba21c1c00d26085e442e5a0b278 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 2 Aug 2013 15:39:38 -0500 Subject: [PATCH] Only use LOG_LOCK in log_flock if a runner is not specified Fixes issue #3466 - When ansible can't authenticate against a host, and your answer is no, ansible crash. --- lib/ansible/callbacks.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 3422336f85..d4bf2adf09 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -84,22 +84,31 @@ def log_lockfile(): LOG_LOCK = open(log_lockfile(), 'w') def log_flock(runner): - fcntl.lockf(LOG_LOCK, fcntl.LOCK_EX) if runner is not None: try: fcntl.lockf(runner.output_lockfile, fcntl.LOCK_EX) except OSError: # already got closed? pass + else: + try: + fcntl.lockf(LOG_LOCK, fcntl.LOCK_EX) + except OSError: + pass + def log_unflock(runner): - fcntl.lockf(LOG_LOCK, fcntl.LOCK_UN) if runner is not None: try: fcntl.lockf(runner.output_lockfile, fcntl.LOCK_UN) except OSError: # already got closed? pass + else: + try: + fcntl.lockf(LOG_LOCK, fcntl.LOCK_UN) + except OSError: + pass def set_play(callback, play): ''' used to notify callback plugins of context '''