'Squash items down to a comma-separated list for certain modules which support it
(typically package management modules).'

def _squash_items(self, items, loop_var, variables):

    name = None
    try:
        templar = Templar(loader=self._loader, shared_loader_obj=self._shared_loader_obj, variables=variables)
        task_action = self._task.action
        if templar._contains_vars(task_action):
            task_action = templar.template(task_action, fail_on_undefined=False)
        if ((len(items) > 0) and (task_action in self.SQUASH_ACTIONS)):
            if all((isinstance(o, string_types) for o in items)):
                final_items = []
                for allowed in ['name', 'pkg', 'package']:
                    name = self._task.args.pop(allowed, None)
                    if (name is not None):
                        break
                template_no_item = template_with_item = None
                if name:
                    if templar._contains_vars(name):
                        variables[loop_var] = '\x00$'
                        template_no_item = templar.template(name, variables, cache=False)
                        variables[loop_var] = '\x00@'
                        template_with_item = templar.template(name, variables, cache=False)
                        del variables[loop_var]
                    if (template_no_item != template_with_item):
                        for item in items:
                            variables[loop_var] = item
                            if self._task.evaluate_conditional(templar, variables):
                                new_item = templar.template(name, cache=False)
                                final_items.append(new_item)
                        self._task.args['name'] = final_items
                        return [final_items]
                    else:
                        self._task.args['name'] = name
    except:
        if (name is not None):
            self._task.args['name'] = name
    return items
