From eab9ca9a00173797a5ab042db9c29dab97837994 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Tue, 17 Oct 2017 14:34:29 -0400 Subject: [PATCH] ec2_vpc_endpoint: make policy_path usable (#31801) The current code flow precludes the use of the policy_path module parameter that's documented. It's actually called policy_file in the code. What's worse is that the policy_file branch actually tries to open the file named by the policy parameter, even though policy and policy_file are marked as mutually-exclusive. This change fixes the logic bug in policy_file and updates the documentation to reference policy_file. The old parameter policy_path is provided as an alias --- lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py index ed50dd4c8b4..28d76249cd3 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py @@ -39,7 +39,7 @@ options: - Option when creating an endpoint. If not provided AWS will utilise a default policy which provides full access to the service. required: false - policy_path: + policy_file: description: - The path to the properly json formatted policy file, see U(https://github.com/ansible/ansible/issues/7005#issuecomment-42894813) @@ -47,6 +47,7 @@ options: - Option when creating an endpoint. If not provided AWS will utilise a default policy which provides full access to the service. required: false + aliases: [ "policy_path" ] state: description: - present to ensure resource is created. @@ -262,7 +263,7 @@ def create_vpc_endpoint(client, module): elif module.params.get('policy_file'): try: - with open(module.params.get('policy'), 'r') as json_data: + with open(module.params.get('policy_file'), 'r') as json_data: policy = json.load(json_data) except Exception as e: module.fail_json(msg=str(e), exception=traceback.format_exc(), @@ -330,7 +331,7 @@ def main(): vpc_id=dict(), service=dict(), policy=dict(type='json'), - policy_file=dict(type='path'), + policy_file=dict(type='path', aliases=['policy_path']), state=dict(default='present', choices=['present', 'absent']), wait=dict(type='bool', default=False), wait_timeout=dict(type='int', default=320, required=False),