Commit 8de70fa6 by Abhijit Menon-Sen

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
parent cf35bdbd
...@@ -186,7 +186,7 @@ class CLI(object): ...@@ -186,7 +186,7 @@ class CLI(object):
self.options.become_method = 'su' 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 ''' ''' check for conflicting options '''
op = self.options op = self.options
...@@ -211,6 +211,10 @@ class CLI(object): ...@@ -211,6 +211,10 @@ class CLI(object):
"and become arguments ('--become', '--become-user', and '--ask-become-pass')" "and become arguments ('--become', '--become-user', and '--ask-become-pass')"
" are exclusive of each other") " are exclusive of each other")
if fork_opts:
if op.forks < 1:
self.parser.error("The number of processes (--forks) must be >= 1")
@staticmethod @staticmethod
def expand_tilde(option, opt, value, parser): def expand_tilde(option, opt, value, parser):
setattr(parser.values, option.dest, os.path.expanduser(value)) setattr(parser.values, option.dest, os.path.expanduser(value))
......
...@@ -60,7 +60,7 @@ class AdHocCLI(CLI): ...@@ -60,7 +60,7 @@ class AdHocCLI(CLI):
raise AnsibleOptionsError("Missing target hosts") raise AnsibleOptionsError("Missing target hosts")
self.display.verbosity = self.options.verbosity 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 return True
......
...@@ -76,7 +76,7 @@ class PlaybookCLI(CLI): ...@@ -76,7 +76,7 @@ class PlaybookCLI(CLI):
raise AnsibleOptionsError("You must specify a playbook file to run") raise AnsibleOptionsError("You must specify a playbook file to run")
self.display.verbosity = self.options.verbosity 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): def run(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment