# target: "local" # simplifying generalization of instnace-id, gateway-id or local
#
-name:Manage Private ELB Subnets
ec2_subnet:
profile:"{{profile}}"
state:"{{state}}"
region:"{{aws_region}}"
name:"{{item.name}}"
vpc_id:"{{vpc_id}}"
cidr_block:"{{item.cidr}}"
az:"{{item.az}}"
route_table_id:"{{item.route_table_id}}"
tags:"{{item.tags}}"
register:created_elb_private_subnets
with_items:elb_private_subnets
when:private_elb_subnet_1 is defined and private_elb_subnet_2 is defined
tags:
-elb
-name:Check that internal ELBs have subnets
fail:msg="If you set an elb scheme to 'internal' you must also define private_elb_subnet_1 and private_elb_subnet_2"
when:private_elb_subnet_1 is not defined and private_elb_subnet_2 is not defined and elbs is defined and 'internal' in elbs|map(attribute='scheme')|list
-name:Compare requested instances vs. current instances
when:not auto_scaling_service and (potential_existing_instances.instances|length > create_instances | int)
fail:msg="This playbook will not shrink the number of instances. {{create_instances }} requested. There are currently {{ potential_existing_instances.instances|length }} instances that match this tag."
#This task will create the number of instances requested (create_instances parameter).
# By default, it will create instances equaling the number of subnets specified.
#Modulo logic explained: The subnet specified will be the instance number modulo the number of subnets,