Configure ansible forks based on cores

At present we use a fixed value of 36. It seems the emperical
formula is 4 forks per core ans would be automatically limited
by ansible to the number of hosts.

Change-Id: I9a9e600935e3b8443341a1dc28421a19d9978bfe
This commit is contained in:
Rabi Mishra 2020-05-11 15:04:33 +05:30
parent 6268bdea73
commit ce948ae049
1 changed files with 2 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import logging
from six.moves.configparser import ConfigParser
import json
import multiprocessing
import netaddr
import os
import os.path
@ -477,7 +478,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
'-T'
).format(os.devnull)
env['ANSIBLE_DISPLAY_FAILED_STDERR'] = True
env['ANSIBLE_FORKS'] = 36
env['ANSIBLE_FORKS'] = multiprocessing.cpu_count() * 4
env['ANSIBLE_TIMEOUT'] = ansible_timeout
env['ANSIBLE_GATHER_TIMEOUT'] = 45
env['ANSIBLE_SSH_RETRIES'] = 3