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 #3227 from bcoca/modules_wantlist

implementing with_items list globbing made easier for modules
This commit is contained in:
Michael DeHaan 2013-06-16 19:29:02 -07:00
commit d9f91be34a
4 changed files with 9 additions and 2 deletions

View file

@ -163,6 +163,7 @@ class Runner(object):
self.is_playbook = is_playbook self.is_playbook = is_playbook
self.environment = environment self.environment = environment
self.complex_args = complex_args self.complex_args = complex_args
self.module_with_list = False
self.callbacks.runner = self self.callbacks.runner = self
@ -405,8 +406,8 @@ class Runner(object):
if type(items) != list: if type(items) != list:
raise errors.AnsibleError("lookup plugins have to return a list: %r" % items) raise errors.AnsibleError("lookup plugins have to return a list: %r" % items)
if len(items) and utils.is_list_of_strings(items) and self.module_name in [ 'apt', 'yum', 'pkgng' ]: if len(items) and utils.is_list_of_strings(items) and self.module_with_list:
# hack for apt, yum, and pkgng so that with_items maps back into a single module call # with_items maps back into a single module call, making modules that support this more efficient
inject['item'] = ",".join(items) inject['item'] = ",".join(items)
items = None items = None
@ -711,6 +712,9 @@ class Runner(object):
if 'WANT_JSON' in module_data: if 'WANT_JSON' in module_data:
module_style = 'non_native_want_json' module_style = 'non_native_want_json'
if 'WITH_ITEMS_USES_LIST' in module_data:
self.module_with_list = True
complex_args_json = utils.jsonify(complex_args) complex_args_json = utils.jsonify(complex_args)
# We force conversion of module_args to str because module_common calls shlex.split, # We force conversion of module_args to str because module_common calls shlex.split,
# a standard library function that incorrectly handles Unicode input before Python 2.7.3. # a standard library function that incorrectly handles Unicode input before Python 2.7.3.

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST
# (c) 2012, Flowroute LLC # (c) 2012, Flowroute LLC
# Written by Matthew Williams <matthew@flowroute.com> # Written by Matthew Williams <matthew@flowroute.com>

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST
# (c) 2013, bleader # (c) 2013, bleader
# Written by bleader <bleader@ratonland.org> # Written by bleader <bleader@ratonland.org>

View file

@ -1,5 +1,6 @@
#!/usr/bin/python -tt #!/usr/bin/python -tt
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST
# (c) 2012, Red Hat, Inc # (c) 2012, Red Hat, Inc
# Written by Seth Vidal <skvidal at fedoraproject.org> # Written by Seth Vidal <skvidal at fedoraproject.org>