Fixing v2 code for test_yum and added capability to squash items

This commit is contained in:
James Cammarata
2015-01-20 01:16:19 -06:00
parent 5addbe7956
commit eae9a406ad
4 changed files with 25 additions and 10 deletions

View File

@@ -112,14 +112,12 @@ class TaskExecutor:
results = []
# FIXME: squash items into a flat list here for those modules
# which support it (yum, apt, etc.) but make it smarter
# than it is today?
# make copies of the job vars and task so we can add the item to
# the variables and re-validate the task with the item variable
task_vars = self._job_vars.copy()
items = self._squash_items(items, task_vars)
for item in items:
# make copies of the job vars and task so we can add the item to
# the variables and re-validate the task with the item variable
task_vars = self._job_vars.copy()
task_vars['item'] = item
try:
@@ -143,6 +141,22 @@ class TaskExecutor:
return results
def _squash_items(self, items, variables):
'''
Squash items down to a comma-separated list for certain modules which support it
(typically package management modules).
'''
if len(items) > 0 and self._task.action in ('apt', 'yum', 'pkgng', 'zypper'):
final_items = []
for item in items:
variables['item'] = item
if self._task.evaluate_conditional(variables):
final_items.append(item)
return [",".join(final_items)]
else:
return items
def _execute(self, variables=None):
'''
The primary workhorse of the executor system, this runs the task