diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index fd2d2dcfeab..a9599da1a47 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 71c76374c3a..a92869fafe7 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 08bbb64f973..474c0b6b9ad 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):