Fix AWS EC2 external inventory script config read
EC2 inventory scripts reads configuration from an INI file. The `instance_filters` option controls which EC2 instances are retrieved for inventory. Filling this option and running the inventory script with Python 3 crashes with the following error: ```python Traceback (most recent call last): File "./contrib/inventory/ec2.py", line 1328, in <module> Ec2Inventory() File "./contrib/inventory/ec2.py", line 163, in __init__ self.read_settings() File "./contrib/inventory/ec2.py", line 393, in read_settings for instance_filter in config.get('ec2', 'instance_filters', '').split(','): TypeError: get() takes 3 positional arguments but 4 were given ``` The problem is the last parameter of config.get() call, because `fallback` keyword argument is not specified. The fix handles epmpty `instance_filers` in case of Python 2&3
This commit is contained in:
parent
c44110bc81
commit
5975296770
1 changed files with 4 additions and 1 deletions
|
@ -388,7 +388,10 @@ class Ec2Inventory(object):
|
|||
# Instance filters (see boto and EC2 API docs). Ignore invalid filters.
|
||||
self.ec2_instance_filters = defaultdict(list)
|
||||
if config.has_option('ec2', 'instance_filters'):
|
||||
for instance_filter in config.get('ec2', 'instance_filters', '').split(','):
|
||||
|
||||
filters = [tag for tag in config.get('ec2', 'instance_filters').split(',') if tag]
|
||||
|
||||
for instance_filter in filters:
|
||||
instance_filter = instance_filter.strip()
|
||||
if not instance_filter or '=' not in instance_filter:
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue