From 2c18ce4c016dbfa0eee50fe9b496a3e524c40d49 Mon Sep 17 00:00:00 2001 From: to-bar <46519524+to-bar@users.noreply.github.com> Date: Wed, 12 Jan 2022 23:51:31 +0100 Subject: [PATCH] Increase the number of Ansible forks (#2861) * Add --ansible-forks option * Update changelog * Add temporary workaround --- cli/engine/ApplyEngine.py | 3 ++- cli/engine/InitEngine.py | 1 + cli/engine/UpgradeEngine.py | 3 ++- cli/engine/ansible/AnsibleConfigFileCreator.py | 3 ++- cli/epicli.py | 4 ++++ docs/changelogs/CHANGELOG-1.3.md | 1 + 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cli/engine/ApplyEngine.py b/cli/engine/ApplyEngine.py index 23d7d968ce..1860127534 100644 --- a/cli/engine/ApplyEngine.py +++ b/cli/engine/ApplyEngine.py @@ -26,7 +26,8 @@ def __init__(self, input_data): self.file = input_data.file self.skip_infrastructure = getattr(input_data, 'no_infra', False) self.skip_config = getattr(input_data, 'skip_config', False) - self.ansible_options = {'profile_tasks': getattr(input_data, 'profile_ansible_tasks', False)} + self.ansible_options = {'forks': getattr(input_data, 'ansible_forks'), + 'profile_tasks': getattr(input_data, 'profile_ansible_tasks', False)} self.logger = Log(__name__) self.cluster_model = None diff --git a/cli/engine/InitEngine.py b/cli/engine/InitEngine.py index 8182ae5e1e..3f021f78a9 100644 --- a/cli/engine/InitEngine.py +++ b/cli/engine/InitEngine.py @@ -60,6 +60,7 @@ def init(self): def get_config_docs(self, input_docs): cluster_config_path = save_manifest(input_docs, self.name, self.name + '.yml') args = type('obj', (object,), {'file': cluster_config_path})() + args.ansible_forks = 10 # TODO: remove these workarounds args.ping_retries = 5 # generate the config documents diff --git a/cli/engine/UpgradeEngine.py b/cli/engine/UpgradeEngine.py index fdff4b977f..0fc7bad0df 100644 --- a/cli/engine/UpgradeEngine.py +++ b/cli/engine/UpgradeEngine.py @@ -15,7 +15,8 @@ class UpgradeEngine(Step): def __init__(self, input_data): super().__init__(__name__) self.build_dir = input_data.build_directory - self.ansible_options = {'profile_tasks': getattr(input_data, 'profile_ansible_tasks', False)} + self.ansible_options = {'forks': getattr(input_data, 'ansible_forks'), + 'profile_tasks': getattr(input_data, 'profile_ansible_tasks', False)} self.file = getattr(input_data, 'file', "") self.backup_build_dir = '' self.ansible_command = AnsibleCommand() diff --git a/cli/engine/ansible/AnsibleConfigFileCreator.py b/cli/engine/ansible/AnsibleConfigFileCreator.py index 9b9801729e..9cc01dd3ce 100644 --- a/cli/engine/ansible/AnsibleConfigFileCreator.py +++ b/cli/engine/ansible/AnsibleConfigFileCreator.py @@ -44,11 +44,12 @@ def update_setting(self, section, key, value, append=False): self.ansible_config_file_settings[section][key] = value def process_ansible_options(self): + self.add_setting('defaults', 'allow_world_readable_tmpfiles', 'true') # workaround for delegate_to with become_user if self.ansible_options['profile_tasks']: self.add_setting('defaults', 'callback_whitelist', ['profile_tasks']) + self.add_setting('defaults', 'forks', self.ansible_options['forks']) # Ubuntu 18 upgraded to 20 has Python 2 and 3 so 'auto_legacy' doesn't work for PostgreSQL Ansible modules self.add_setting('defaults', 'interpreter_python', 'auto') - self.add_setting('defaults', 'allow_world_readable_tmpfiles', 'true') # workaround for delegate_to with become_user def create(self): self.logger.info('Creating ansible.cfg') diff --git a/cli/epicli.py b/cli/epicli.py index ea3674ed16..42192131f6 100644 --- a/cli/epicli.py +++ b/cli/epicli.py @@ -207,6 +207,8 @@ def apply_parser(subparsers): help='Enable Ansible profile_tasks plugin for timing tasks. (developer/debug option)') optional.add_argument('--ping-retries', dest='ping_retries', type=int, required=False, action='store', default=5, help='Number of pings after which Ansible will fail.') + optional.add_argument('--ansible-forks', dest='ansible_forks', type=int, required=False, action='store', default=10, + help='Sets the number of forks in ansible.cfg.') sub_parser._action_groups.append(optional) def run_apply(args): @@ -297,6 +299,8 @@ def splitarg(arg): help='Provides comma separated list of components for upgrade selected from the following: [' + ', '.join(map(str, component_list)) + ']') optional.add_argument('--ping-retries', dest='ping_retries', type=int, required=False, action='store', default=5, help='Number of pings after which Ansible will fail.') + optional.add_argument('--ansible-forks', dest='ansible_forks', type=int, required=False, action='store', default=10, + help='Sets the number of forks in ansible.cfg.') sub_parser._action_groups.append(optional) def run_upgrade(args): diff --git a/docs/changelogs/CHANGELOG-1.3.md b/docs/changelogs/CHANGELOG-1.3.md index e80d096d3b..a07e81f997 100644 --- a/docs/changelogs/CHANGELOG-1.3.md +++ b/docs/changelogs/CHANGELOG-1.3.md @@ -25,6 +25,7 @@ - [#633](https://github.com/epiphany-platform/epiphany/issues/633) - DOC: How to use TLS/SSL certificate with HA Proxy - [#2702](https://github.com/epiphany-platform/epiphany/issues/2702) - Use state flag file in K8s upgrades - [#2840](https://github.com/epiphany-platform/epiphany/issues/2840) - Create deprecation notes documentation +- [#2860](https://github.com/epiphany-platform/epiphany/issues/2860) - Increase the number of forks in Ansible from default (5) to configure more hosts in parallel ### Fixed