From 53c2f4c1bb367a6f6b6e060b06367fbfc021fb53 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 3 Sep 2013 10:59:50 -0500 Subject: [PATCH] Fix race condition on creating the temp directory for ControlPersist Fixes #3943 --- lib/ansible/runner/connection_plugins/ssh.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 5ba0747676..589cecbbdd 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -43,9 +43,12 @@ class Connection(object): self.user = user self.password = password self.private_key_file = private_key_file - self.cp_dir = utils.prepare_writeable_dir('$HOME/.ansible/cp',mode=0700) self.HASHED_KEY_MAGIC = "|1|" + fcntl.lockf(self.runner.process_lockfile, fcntl.LOCK_EX) + self.cp_dir = utils.prepare_writeable_dir('$HOME/.ansible/cp',mode=0700) + fcntl.lockf(self.runner.process_lockfile, fcntl.LOCK_UN) + def connect(self): ''' connect to the remote host '''