mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
added missing ansibleoptionserror import and moved args check in playbook to after parser exists to allow for creating usage info
This commit is contained in:
parent
d1b4371287
commit
47be5b4166
2 changed files with 5 additions and 4 deletions
|
@ -31,7 +31,7 @@ import subprocess
|
||||||
|
|
||||||
from ansible import __version__
|
from ansible import __version__
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||||
from ansible.utils.unicode import to_bytes
|
from ansible.utils.unicode import to_bytes
|
||||||
|
|
||||||
class SortedOptParser(optparse.OptionParser):
|
class SortedOptParser(optparse.OptionParser):
|
||||||
|
|
|
@ -24,7 +24,7 @@ import sys
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.cli import CLI
|
from ansible.cli import CLI
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||||
from ansible.executor.playbook_executor import PlaybookExecutor
|
from ansible.executor.playbook_executor import PlaybookExecutor
|
||||||
from ansible.inventory import Inventory
|
from ansible.inventory import Inventory
|
||||||
from ansible.parsing import DataLoader
|
from ansible.parsing import DataLoader
|
||||||
|
@ -69,11 +69,12 @@ class PlaybookCLI(CLI):
|
||||||
|
|
||||||
self.options, self.args = parser.parse_args()
|
self.options, self.args = parser.parse_args()
|
||||||
|
|
||||||
if len(self.args) == 0:
|
|
||||||
raise AnsibleOptionsError("You must specify a playbook file to run")
|
|
||||||
|
|
||||||
self.parser = parser
|
self.parser = parser
|
||||||
|
|
||||||
|
if len(self.args) == 0:
|
||||||
|
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()
|
self.validate_conflicts()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue