Hi,

Below is the playbook, which work fine and create an ec2 instance inside 
the Public subnet inside my VPC and register the result inside the "ec2" 
variable, but the problem is sometime the "Associate new EIP to the NAT 
Instance" work and sometime fail, the reason is that, if the "Public 
subnet" result is at index 0, then it work and it come at index 1 then it 
fail, like this:

This work perfectly:

TASK: [NAT | Create the NAT Instance] ***********************
changed: [localhost -> 127.0.0.1] => (item={u'resource_tags': {u'Name': 
u'tendo_public_subnet'}, u'cidr': u'172.25.10.0/24', u'az': 
u'ap-southeast-2a', u'id': u'subnet-61549316'})
skipping: [localhost -> 127.0.0.1] => (item={u'resource_tags': {u'Name': 
u'tendo_private_subnet'}, u'cidr': u'172.25.20.0/24', u'az': 
u'ap-southeast-2b', u'id': u'subnet-68cb120d'})

but this fail:

TASK: [NAT | Create the NAT Instance] ***********************
skipping: [localhost -> 127.0.0.1] => (item={u'resource_tags': {u'Name': 
u'tendo_private_subnet'}, u'cidr': u'172.25.20.0/24', u'az': 
u'ap-southeast-2b', u'id': u'subnet-68cb120d'})
changed: [localhost -> 127.0.0.1] => (item={u'resource_tags': {u'Name': 
u'tendo_public_subnet'}, u'cidr': u'172.25.10.0/24', u'az': 
u'ap-southeast-2a', u'id': u'subnet-61549316'})

Can we make something that the public subnet result always come at 0 or 1 
but not flip all the time?

Thanks

===================

---

 - name: NAT | Create the NAT Instance

   local_action:

     module: ec2

     region: "{{ vpc_region }}"

     group: "{{ group_name }}"

     keypair: "{{ key_name }}"

     instance_type: "{{ nat_instance_type }}"

     image: "{{ imgae_id }}"

     vpc_subnet_id: "{{ item.id }}"

     private_ip: "{{ nat_private_ip }}"

     source_dest_check: False

     wait: True

     wait_timeout: 500

     instance_tags:

       Name: "NAT_Instance"

     exact_count: 1

     count_tag:

       Name: "NAT_Instance"

   with_items: vpc.subnets

   when: item['cidr'] == public_cidr

   register: ec2

 - name: NAT | Associate new EIP to the NAT Instance

   local_action:

     module: ec2_eip

     region: "{{ vpc_region }}"

     instance_id: "{{ item.id }}"

   with_items: ec2.results.0.instances

   register: eip

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c734bee1-d856-4225-859f-0a88c6d97b57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to