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

Allow /bin/ansible to use --limit

This commit is contained in:
Michael DeHaan 2012-08-11 14:05:24 -04:00
parent 9041adddaa
commit 3587ffdef3
2 changed files with 9 additions and 3 deletions

View file

@ -45,7 +45,7 @@ class Cli(object):
def parse(self):
''' create an options parser for bin/ansible '''
parser = utils.base_parser(constants=C, runas_opts=True, async_opts=True,
parser = utils.base_parser(constants=C, runas_opts=True, subset_opts=True, async_opts=True,
output_opts=True, connect_opts=True, usage='%prog <host-pattern> [options]')
parser.add_option('-a', '--args', dest='module_args',
help="module arguments", default=C.DEFAULT_MODULE_ARGS)
@ -96,7 +96,7 @@ class Cli(object):
pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo,
sudo_pass=sudopass,sudo_user=options.sudo_user,
transport=options.connection
transport=options.connection, subset=options.subset
)
if options.seconds:

View file

@ -123,7 +123,8 @@ class Runner(object):
sudo_user=C.DEFAULT_SUDO_USER, # ex: 'root'
module_vars=None, # a playbooks internals thing
is_playbook=False, # running from playbook or not?
inventory=None # reference to Inventory object
inventory=None, # reference to Inventory object
subset=None # subset pattern
):
# storage & defaults
@ -133,6 +134,7 @@ class Runner(object):
self.generated_jid = str(random.randint(0, 999999999999))
self.transport = transport
self.inventory = utils.default(inventory, lambda: ansible.inventory.Inventory(host_list))
self.module_vars = utils.default(module_vars, lambda: {})
self.sudo_user = sudo_user
self.connector = connection.Connection(self)
@ -153,6 +155,10 @@ class Runner(object):
self.is_playbook = is_playbook
# misc housekeeping
if subset and self.inventory._subset is None:
# don't override subset when passed from playbook
self.inventory.subset(subset)
if self.transport == 'ssh' and remote_pass:
raise errors.AnsibleError("SSH transport does not support passwords, only keys or agents")
if self.transport == 'local':