1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #10026 from bcoca/v2_empty_inventory_warns

adds to v2 the ability to run with empty inventory (implicit localhost)
This commit is contained in:
Brian Coca 2015-01-16 18:41:33 -05:00
commit ed891c76f6

View file

@ -15,6 +15,7 @@ from ansible.playbook.task import Task
from ansible.utils.cli import base_parser from ansible.utils.cli import base_parser
from ansible.utils.vars import combine_vars from ansible.utils.vars import combine_vars
from ansible.vars import VariableManager from ansible.vars import VariableManager
from ansible.utils import warning
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
@ -138,7 +139,7 @@ def main(args):
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=options.inventory) inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=options.inventory)
inventory.subset(options.subset) inventory.subset(options.subset)
if len(inventory.list_hosts()) == 0: if len(inventory.list_hosts()) == 0:
raise AnsibleError("provided hosts list is empty") warning("provided hosts list is empty, only localhost is available")
# create the playbook executor, which manages running the plays # create the playbook executor, which manages running the plays
# via a task queue manager # via a task queue manager