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
changes/80/346880/1
James E. Blair 6 years ago
parent c709b6adb7
commit 176431ec14
  1. 3
      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)

Loading…
Cancel
Save