From 176431ec1488fbde93c953972f639b8a31d173c8 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 25 Jul 2016 08:02:33 -0700 Subject: [PATCH] Ansible launcher: set remote_tmp When we use 'delegate_to' to run commands locally, the 'remote' side of the Ansible connection is the local host. When running these tasks it will write to the 'remote_tmp' directory, which is actually the local ~/.ansible/tmp directory. We also set 'keep_remote_files' to true in order to avoid a race condition with 'async' on the actual remote hosts, but in this case, these two options in combination end up meaning 'keep some files in the local ~/.ansible/tmp directory indefinitely' which is not good for our long-running launchers. Instead, set 'remote_tmp' to a subdirectory of the jobdir so that when used in the local context, it will be cleaned up at the end of the run. In the remote context, it will end up in a similarly randomly named directory under /tmp on the worker. Ansible will create that directory. This has the side benefit of removing the Ansible running the job further from potential uses of Ansible within the job (which may continue to use ~/.ansible by default). Change-Id: I70475d5844cbd66bf670566f992fdec263d271a5 --- zuul/launcher/ansiblelaunchserver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zuul/launcher/ansiblelaunchserver.py b/zuul/launcher/ansiblelaunchserver.py index f38c4af3ab..2380e56621 100644 --- a/zuul/launcher/ansiblelaunchserver.py +++ b/zuul/launcher/ansiblelaunchserver.py @@ -1250,7 +1250,8 @@ class NodeWorker(object): config.write('[defaults]\n') config.write('hostfile = %s\n' % jobdir.inventory) config.write('keep_remote_files = True\n') - config.write('local_tmp = %s/.ansible/tmp\n' % jobdir.root) + config.write('local_tmp = %s/.ansible/local_tmp\n' % jobdir.root) + config.write('remote_tmp = %s/.ansible/remote_tmp\n' % jobdir.root) config.write('private_key_file = %s\n' % self.private_key_file) config.write('retry_files_enabled = False\n') config.write('log_path = %s\n' % jobdir.ansible_log)