Merge pull request #11832 from amenonsen/zeroforks

Disallow --forks 0
This commit is contained in:
James Cammarata 2015-08-02 22:39:21 -04:00
commit 7b9aee7077
3 changed files with 7 additions and 3 deletions

View file

@ -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))

View file

@ -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

View file

@ -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):