Merge "Ensure ansible.log accesses are locked"

This commit is contained in:
Zuul 2021-03-09 14:23:58 +00:00 committed by Gerrit Code Review
commit 0ab9a1ad80
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import json
import logging
import multiprocessing
import os
from pathlib import Path
import shutil
import six
from six.moves import configparser
@ -116,6 +117,11 @@ def write_default_ansible_cfg(work_dir,
datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
os.rename(log_path, new_path)
# Create the log file, and set some rights on it in order to prevent
# unwanted accesse
Path(log_path).touch()
os.chmod(log_path, 0o640)
config.set('defaults', 'forks', str(min(
multiprocessing.cpu_count() * 4, 100)))
config.set('defaults', 'timeout', '30')