Skip to content

Commit

Permalink
Increase the number of Ansible forks (hitachienergy#2861)
Browse files Browse the repository at this point in the history
* Add --ansible-forks option

* Update changelog

* Add temporary workaround
  • Loading branch information
to-bar authored Jan 12, 2022
1 parent 650185a commit 2c18ce4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cli/engine/ApplyEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cli/engine/InitEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cli/engine/UpgradeEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion cli/engine/ansible/AnsibleConfigFileCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions cli/epicli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions docs/changelogs/CHANGELOG-1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2c18ce4

Please sign in to comment.