From 17a409f20d9a0be957d7e50817d075bf35be56a4 Mon Sep 17 00:00:00 2001 From: sisso Date: Thu, 16 Apr 2015 14:36:26 -0300 Subject: [PATCH] fixed bug where scaling policy return a random policy if many autoscale group have policies with same name. --- lib/ansible/modules/cloud/amazon/ec2_scaling_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_scaling_policy.py b/lib/ansible/modules/cloud/amazon/ec2_scaling_policy.py index 28eda56f07..28054bfc27 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_scaling_policy.py +++ b/lib/ansible/modules/cloud/amazon/ec2_scaling_policy.py @@ -88,7 +88,7 @@ def create_scaling_policy(connection, module): try: connection.create_scaling_policy(sp) - policy = connection.get_all_policies(policy_names=[sp_name])[0] + policy = connection.get_all_policies(as_group=asg_name,policy_names=[sp_name])[0] module.exit_json(changed=True, name=policy.name, arn=policy.policy_arn, as_name=policy.as_name, scaling_adjustment=policy.scaling_adjustment, cooldown=policy.cooldown, adjustment_type=policy.adjustment_type, min_adjustment_step=policy.min_adjustment_step) except BotoServerError, e: module.fail_json(msg=str(e)) @@ -115,7 +115,7 @@ def create_scaling_policy(connection, module): try: if changed: connection.create_scaling_policy(policy) - policy = connection.get_all_policies(policy_names=[sp_name])[0] + policy = connection.get_all_policies(as_group=asg_name,policy_names=[sp_name])[0] module.exit_json(changed=changed, name=policy.name, arn=policy.policy_arn, as_name=policy.as_name, scaling_adjustment=policy.scaling_adjustment, cooldown=policy.cooldown, adjustment_type=policy.adjustment_type, min_adjustment_step=policy.min_adjustment_step) except BotoServerError, e: module.fail_json(msg=str(e))