The problem will most likely be with your count_tag. If you use a tag to
include the subnet in the count, you can have exact_count=1 and multiple
subnets, and it will create a box in each subnet. If you want to create
different numbers of boxes in each subnet, you just expand your subnet vars
to include how many, like below.
exact_count: "{{item.how_many}}"
count_tag:
deploy_env: "{{deploy_env}}"
service: "{{service}}"
az: "{{item.az}}"
region: "{{region}}"
with_items: subnets
Then subnets would look like:
subnets:
- { az: a, subnet: subnet-1a2b3c4d, how_many: 2}
- { az: b, subnet: subnet-2b3c4d5e, how_many: 1}
On Thursday, October 8, 2015 at 11:23:50 AM UTC-7, Guy Knights wrote:
>
> I have a playbook that fires up some ec2 instances in multiple subnets
> using exact_count and count_tag to control how many instances are created.
> I'm using when to loop over the subnets I want to use - in this particular
> case, there are 2 subnets in different availability zones, and I want to
> create one instance in each AZ.
>
> The problem is that if I set exact_count to 1, ansible creates the first
> instance and then doesn't create the second instance in the second subnet
> as exact_count is already reached. If I change exact_count to 2, it will
> create 2 instances but they're in the same subnet. Basically, the loop is
> irrelevant.
>
> Is there any way around this issue?
>
> Thanks,
> Guy
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/dbe9fdb4-b22b-4caa-ad8e-0bd598c757c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.