Adjust Ansible forks caculations

Using a multiple of 10 can be excessive on resource usage. It has now
been lowered to 4. The default maximum will also no longer exceed 100.

Change-Id: I57345d5b100efce143fa940b56c81f5e6bc6c390
Signed-off-by: Luke Short <ekultails@gmail.com>
(cherry picked from commit 9e9948e7ed)
This commit is contained in:
Luke Short 2020-09-10 15:58:11 -04:00
parent 422beab6be
commit d5a54beb34
2 changed files with 3 additions and 2 deletions

View File

@ -104,7 +104,8 @@ def write_default_ansible_cfg(work_dir,
datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
os.rename(log_path, new_path)
config.set('defaults', 'forks', str(multiprocessing.cpu_count() * 10))
config.set('defaults', 'forks', str(min(
multiprocessing.cpu_count() * 4, 100)))
config.set('defaults', 'timeout', '30')
config.set('defaults', 'gather_timeout', '30')

View File

@ -348,4 +348,4 @@ class CopyConfigFileTest(base.TestCase):
ansible_cfg = configparser.ConfigParser()
ansible_cfg.read(resulting_ansible_config)
self.assertEqual('40', ansible_cfg.get('defaults', 'forks'))
self.assertEqual('16', ansible_cfg.get('defaults', 'forks'))