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
This commit is contained in:
James E. Blair 2016-07-25 08:02:33 -07:00
parent c709b6adb7
commit 176431ec14
1 changed files with 2 additions and 1 deletions

View File

@ -1250,7 +1250,8 @@ class NodeWorker(object):
config.write('[defaults]\n') config.write('[defaults]\n')
config.write('hostfile = %s\n' % jobdir.inventory) config.write('hostfile = %s\n' % jobdir.inventory)
config.write('keep_remote_files = True\n') 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('private_key_file = %s\n' % self.private_key_file)
config.write('retry_files_enabled = False\n') config.write('retry_files_enabled = False\n')
config.write('log_path = %s\n' % jobdir.ansible_log) config.write('log_path = %s\n' % jobdir.ansible_log)