Remove ansible files at startup before copy

When starting executor a second time, a traceback was happening because
the destination for the ansible files already existed. shutil.copytree
requires that the destination path does not exist. Since what we seem to
want is a fresh copy of the ansible files at start up, and no left over
cruft, removing the tree seems correct.

Change-Id: I92418f0e6233558f8aaee796a679d638f7c4c4c7
This commit is contained in:
Jesse Keating 2017-06-06 16:01:47 -07:00
parent b0fb9b0c86
commit 9e62265c44
1 changed files with 3 additions and 2 deletions

View File

@ -387,12 +387,13 @@ class ExecutorServer(object):
self.command_socket = commandsocket.CommandSocket(path)
ansible_dir = os.path.join(state_dir, 'ansible')
self.ansible_dir = ansible_dir
if os.path.exists(ansible_dir):
shutil.rmtree(ansible_dir)
zuul_dir = os.path.join(ansible_dir, 'zuul')
plugin_dir = os.path.join(zuul_dir, 'ansible')
if not os.path.exists(plugin_dir):
os.makedirs(plugin_dir)
os.makedirs(plugin_dir, mode=0o0755)
self.library_dir = os.path.join(plugin_dir, 'library')
self.action_dir = os.path.join(plugin_dir, 'action')