Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing with_items list globbing made easier for modules #3227

Merged
merged 1 commit into from
Jun 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def __init__(self,
self.is_playbook = is_playbook
self.environment = environment
self.complex_args = complex_args
self.module_with_list = False

self.callbacks.runner = self

Expand Down Expand Up @@ -405,8 +406,8 @@ def _executor_internal(self, host):
if type(items) != list:
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' ]:
# hack for apt, yum, and pkgng so that with_items maps back into a single module call
if len(items) and utils.is_list_of_strings(items) and self.module_with_list:
# with_items maps back into a single module call, making modules that support this more efficient
inject['item'] = ",".join(items)
items = None

Expand Down Expand Up @@ -711,6 +712,9 @@ def _copy_module(self, conn, tmp, module_name, module_args, inject, complex_args
if 'WANT_JSON' in module_data:
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)
# 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.
Expand Down
1 change: 1 addition & 0 deletions library/packaging/apt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST

# (c) 2012, Flowroute LLC
# Written by Matthew Williams <matthew@flowroute.com>
Expand Down
1 change: 1 addition & 0 deletions library/packaging/pkgng
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST

# (c) 2013, bleader
# Written by bleader <bleader@ratonland.org>
Expand Down
1 change: 1 addition & 0 deletions library/packaging/yum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
# WITH_ITEMS_USES_LIST

# (c) 2012, Red Hat, Inc
# Written by Seth Vidal <skvidal at fedoraproject.org>
Expand Down