@ -25,7 +25,7 @@ import subprocess
import sys
import sys
import time
import time
from ansible . compat . six import iteritems
from ansible . compat . six import iteritems , string_types
from ansible import constants as C
from ansible import constants as C
from ansible . errors import AnsibleError , AnsibleParserError , AnsibleUndefinedVariable , AnsibleConnectionFailure
from ansible . errors import AnsibleError , AnsibleParserError , AnsibleUndefinedVariable , AnsibleConnectionFailure
@ -230,6 +230,7 @@ class TaskExecutor:
( typically package management modules ) .
( typically package management modules ) .
'''
'''
if len ( items ) > 0 and self . _task . action in self . SQUASH_ACTIONS :
if len ( items ) > 0 and self . _task . action in self . SQUASH_ACTIONS :
if all ( isinstance ( o , string_types ) for o in items ) :
final_items = [ ]
final_items = [ ]
name = self . _task . args . pop ( ' name ' , None ) or self . _task . args . pop ( ' pkg ' , None )
name = self . _task . args . pop ( ' name ' , None ) or self . _task . args . pop ( ' pkg ' , None )
for item in items :
for item in items :
@ -241,10 +242,16 @@ class TaskExecutor:
final_items . append ( new_item )
final_items . append ( new_item )
else :
else :
final_items . append ( item )
final_items . append ( item )
joined_items = " , " . join ( final_items )
self . _task . args [ ' name ' ] = final_items
self . _task . args [ ' name ' ] = joined_items
return [ final_items ]
return [ joined_items ]
# Right now we only optimize single entries. In the future we
else :
# could optimize more types:
# * lists can be squashed together
# * dicts could squash entries that match in all cases except the
# name or pkg field.
# Note: we really should be checking that the name or pkg field
# contains a template that expands with our with_items values.
# If it doesn't then we may break things
return items
return items
def _execute ( self , variables = None ) :
def _execute ( self , variables = None ) :