From e67cdd448eea1f2a58e3326f1d7cdaf5b8561626 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 31 May 2017 14:59:55 -0400 Subject: [PATCH] [cloud] EC2 dynamic inventory default filename is documented as ec2.ini - fixes #24396 (#24515) * the default filename is ec2.ini (to override that use the env var EC2_INI_PATH) * allow fallback to ec2.ini --- contrib/inventory/ec2.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py index 9614c5fe91..0f4bf2a8fd 100755 --- a/contrib/inventory/ec2.py +++ b/contrib/inventory/ec2.py @@ -226,6 +226,7 @@ class Ec2Inventory(object): defaults = { 'ec2': { + 'ini_fallback': os.path.join(os.path.dirname(__file__), 'ec2.ini'), 'ini_path': os.path.join(os.path.dirname(__file__), '%s.ini' % scriptbasename) } } @@ -236,6 +237,10 @@ class Ec2Inventory(object): config = configparser.SafeConfigParser() ec2_ini_path = os.environ.get('EC2_INI_PATH', defaults['ec2']['ini_path']) ec2_ini_path = os.path.expanduser(os.path.expandvars(ec2_ini_path)) + + if not os.path.isfile(ec2_ini_path): + ec2_ini_path = os.path.expanduser(defaults['ec2']['ini_fallback']) + config.read(ec2_ini_path) # is eucalyptus?