From 5a39672efadfffb93c49a0acd1a1e67bdba0c306 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 24 Apr 2014 11:56:25 -0600 Subject: [PATCH 1/3] documentation fix availability_zones should be required for ec2_asg --- library/cloud/ec2_asg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/cloud/ec2_asg b/library/cloud/ec2_asg index 6528d95118..971a2a8c72 100644 --- a/library/cloud/ec2_asg +++ b/library/cloud/ec2_asg @@ -40,7 +40,7 @@ options: availability_zones: description: - List of availability zone names in which to create the group. - required: false + required: true launch_config_name: description: - Name of the Launch configuration to use for the group. See the ec2_lc module for managing these. From 4596521147a7b5d98ded9b45106050c51dc3fc57 Mon Sep 17 00:00:00 2001 From: Ben Holloway Date: Thu, 24 Apr 2014 17:56:26 -0600 Subject: [PATCH 2/3] attempt to set availability_zones to all if neither availability_zones or vpc_identifier are set --- library/cloud/ec2_asg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/library/cloud/ec2_asg b/library/cloud/ec2_asg index 971a2a8c72..f0305e717a 100644 --- a/library/cloud/ec2_asg +++ b/library/cloud/ec2_asg @@ -39,8 +39,8 @@ options: required: false availability_zones: description: - - List of availability zone names in which to create the group. - required: true + - List of availability zone names in which to create the group. Required if vpc_zone_identifier is not set. + required: false launch_config_name: description: - Name of the Launch configuration to use for the group. See the ec2_lc module for managing these. @@ -102,7 +102,7 @@ def enforce_required_arguments(module): they cannot be mandatory arguments for the module, so we enforce them here ''' missing_args = [] - for arg in ('min_size', 'max_size', 'launch_config_name', 'availability_zones'): + for arg in ('min_size', 'max_size', 'launch_config_name'): if module.params[arg] is None: missing_args.append(arg) if missing_args: @@ -122,9 +122,17 @@ def create_autoscaling_group(connection, module): vpc_zone_identifier = module.params.get('vpc_zone_identifier') launch_configs = connection.get_all_launch_configurations(names=[launch_config_name]) - + as_groups = connection.get_all_groups(names=[group_name]) + if not vpc_zone_identifier and not availability_zones: + region, ec2_url, aws_connect_params = get_aws_connection_info(module) + try: + ec2_connection = connect_to_aws(boto.ec2, region, **aws_connect_params) + except boto.exception.NoAuthHandlerFound, e: + module.fail_json(msg=str(e)) + module.params['availability_zones'] = [zone.name for zone in ec2_connection.get_all_zones()] + if not as_groups: ag = AutoScalingGroup( group_name=group_name, From e45d33954bff66bf4e6e030908aaed9cc772dbf8 Mon Sep 17 00:00:00 2001 From: Ben Holloway Date: Thu, 24 Apr 2014 17:58:39 -0600 Subject: [PATCH 3/3] documentation fix --- library/cloud/ec2_asg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/cloud/ec2_asg b/library/cloud/ec2_asg index f0305e717a..856f5d59ad 100644 --- a/library/cloud/ec2_asg +++ b/library/cloud/ec2_asg @@ -39,7 +39,7 @@ options: required: false availability_zones: description: - - List of availability zone names in which to create the group. Required if vpc_zone_identifier is not set. + - List of availability zone names in which to create the group. Defaults to all the availability zones in the region if vpc_zone_identifier is not set. required: false launch_config_name: description: