From 741b941f332d037a32bb70427865eeddc888ee0d Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 21 Feb 2018 13:50:14 -0500 Subject: [PATCH] [cloud] If inventory file isn't able to be parsed by aws_ec2, raise an AnsibleParserError (#36387) (#36459) * If inventory file isn't able to be parsed by aws_ec2, return an empty dict instead of None * Raise an AnsibleParserError instead * remove extra lines * aws_ec2 inventory plugin - fix path matching logic --- lib/ansible/plugins/inventory/aws_ec2.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/inventory/aws_ec2.py b/lib/ansible/plugins/inventory/aws_ec2.py index 7d22757d676..6254abdc227 100644 --- a/lib/ansible/plugins/inventory/aws_ec2.py +++ b/lib/ansible/plugins/inventory/aws_ec2.py @@ -451,10 +451,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): :return the contents of the config file ''' if super(InventoryModule, self).verify_file(path): - if path.endswith('.aws_ec2.yml' or '.aws_ec2.yaml'): + if path.endswith('.aws_ec2.yml') or path.endswith('.aws_ec2.yaml'): return self._read_config_data(path) - else: - raise AnsibleParserError("Not a ec2 inventory plugin configuration file") + raise AnsibleParserError("Not a ec2 inventory plugin configuration file") def _get_query_options(self, config_data): '''