From 8de70fa657ce9be45bb5ec6dbd6ca326d0a94625 Mon Sep 17 00:00:00 2001 From: Abhijit Menon-Sen Date: Sun, 2 Aug 2015 14:10:42 +0530 Subject: [PATCH] Disallow --forks 0 Without at least one worker process, things break: Traceback (most recent call last): File "/home/ams/extern/ansible/ansible/lib/ansible/executor/process/result.py", line 103, in run result = self._read_worker_result() File "/home/ams/extern/ansible/ansible/lib/ansible/executor/process/result.py", line 69, in _read_worker_result (worker_prc, main_q, rslt_q) = self._workers[self._cur_worker] IndexError: list index out of range --- lib/ansible/cli/__init__.py | 6 +++++- lib/ansible/cli/adhoc.py | 2 +- lib/ansible/cli/playbook.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index fd2d2dcfea..a9599da1a4 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -186,7 +186,7 @@ class CLI(object): self.options.become_method = 'su' - def validate_conflicts(self, vault_opts=False, runas_opts=False): + def validate_conflicts(self, vault_opts=False, runas_opts=False, fork_opts=False): ''' check for conflicting options ''' op = self.options @@ -211,6 +211,10 @@ class CLI(object): "and become arguments ('--become', '--become-user', and '--ask-become-pass')" " are exclusive of each other") + if fork_opts: + if op.forks < 1: + self.parser.error("The number of processes (--forks) must be >= 1") + @staticmethod def expand_tilde(option, opt, value, parser): setattr(parser.values, option.dest, os.path.expanduser(value)) diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index 71c76374c3..a92869fafe 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -60,7 +60,7 @@ class AdHocCLI(CLI): raise AnsibleOptionsError("Missing target hosts") self.display.verbosity = self.options.verbosity - self.validate_conflicts(runas_opts=True, vault_opts=True) + self.validate_conflicts(runas_opts=True, vault_opts=True, fork_opts=True) return True diff --git a/lib/ansible/cli/playbook.py b/lib/ansible/cli/playbook.py index 08bbb64f97..474c0b6b9a 100644 --- a/lib/ansible/cli/playbook.py +++ b/lib/ansible/cli/playbook.py @@ -76,7 +76,7 @@ class PlaybookCLI(CLI): raise AnsibleOptionsError("You must specify a playbook file to run") self.display.verbosity = self.options.verbosity - self.validate_conflicts(runas_opts=True, vault_opts=True) + self.validate_conflicts(runas_opts=True, vault_opts=True, fork_opts=True) def run(self):