From 19a26f32ae41001a8bf014f7c974e02cfe929468 Mon Sep 17 00:00:00 2001 From: Rabi Mishra Date: Mon, 11 May 2020 15:04:33 +0530 Subject: [PATCH] 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 (cherry picked from commit ce948ae04947596afe2e1acefaca0a7813f1268f) --- tripleoclient/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 3d44d15ba..9b9300c71 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -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