ansible: ensure we can delete ansible files

If the source files mode are non writtable, then copytree/rmtree
fails with a PermissionError. This change ensures the files
are writtable before removing them.

Change-Id: I2b07ddc5ee203e7e4077b58224469fed916dabf6
This commit is contained in:
Tristan Cacqueray
2021-02-16 22:08:37 +00:00
parent bc4d0dd614
commit b6be000681
+5
View File
@@ -321,6 +321,11 @@ class AnsibleManager:
def copyAnsibleFiles(self):
if os.path.exists(self.zuul_ansible_dir):
# Ensure we can delete the files by setting writtable mode
for dirpath, dirnames, filenames in os.walk(self.zuul_ansible_dir):
os.chmod(dirpath, 0o755)
for filename in filenames:
os.chmod(os.path.join(dirpath, filename), 0o600)
shutil.rmtree(self.zuul_ansible_dir)
library_path = os.path.dirname(os.path.abspath(zuul.ansible.__file__))