@ -340,8 +340,8 @@ class Ec2Inventory(object):
else :
self . all_elasticache_nodes = False
# boto configuration profile (prefer CLI argument )
self . boto_profile = self . args . boto_profile
# boto configuration profile (prefer CLI argument then environment variables then config file )
self . boto_profile = self . args . boto_profile or os . environ . get ( ' AWS_PROFILE ' )
if config . has_option ( ' ec2 ' , ' boto_profile ' ) and not self . boto_profile :
self . boto_profile = config . get ( ' ec2 ' , ' boto_profile ' )
@ -376,14 +376,11 @@ class Ec2Inventory(object):
os . makedirs ( cache_dir )
cache_name = ' ansible-ec2 '
aws_profile = lambda : ( self . boto_profile or
os . environ . get ( ' AWS_PROFILE ' ) or
os . environ . get ( ' AWS_ACCESS_KEY_ID ' ) or
self . credentials . get ( ' aws_access_key_id ' , None ) )
if aws_profile ( ) :
cache_name = ' %s - %s ' % ( cache_name , aws_profile ( ) )
self . cache_path_cache = cache_dir + " / %s .cache " % cache_name
self . cache_path_index = cache_dir + " / %s .index " % cache_name
cache_id = self . boto_profile or os . environ . get ( ' AWS_ACCESS_KEY_ID ' , self . credentials . get ( ' aws_access_key_id ' ) )
if cache_id :
cache_name = ' %s - %s ' % ( cache_name , cache_id )
self . cache_path_cache = os . path . join ( cache_dir , " %s .cache " % cache_name )
self . cache_path_index = os . path . join ( cache_dir , " %s .index " % cache_name )
self . cache_max_age = config . getint ( ' ec2 ' , ' cache_max_age ' )
if config . has_option ( ' ec2 ' , ' expand_csv_tags ' ) :