I'm not quite positive what you are doing. You omitted the task that creates the instances. However it looks like you are targeting 3 hosts:
aaa-frs-ans-test1 aaa-frs-ans-test2 aaa-frs-ans-test3 And you are creating 1 instance for each host. add_host only runs on the first host in the group, so you see it only run for aaa-frs-ans-test1. It is called a host loop bypass plugin, meaning that it doesn't execute for each host you target in your play. You are trying to loop ec2.instances, but there is only 1 host in that result, since you created a host on each instance, since vars are scoped to hosts. Instead of targeting those 3 hosts, maybe you should instead target just localhost, and build your ec2 instances using a with_items to create 3 hosts. But again, still not really sure what you are doing, and if you have reasons for what you have done so far. On Tue, May 24, 2016 at 1:29 PM, Eric S <[email protected]> wrote: > sorry for the long output: > PLAY [ec2_instances] > *********************************************************** > > TASK [setup] > ******************************************************************* > Tuesday 24 May 2016 13:24:42 -0500 (0:00:00.019) 0:00:00.019 > *********** > ok: [aaa-frs-ans-test2] > ok: [aaa-frs-ans-test3] > ok: [aaa-frs-ans-test1] > > TASK [Launch Instance] > ********************************************************* > Tuesday 24 May 2016 13:24:46 -0500 (0:00:04.019) 0:00:04.038 > *********** > changed: [aaa-frs-ans-test3] => {"changed": true, "instance_ids": > ["i-683925ef"], "instances": [{"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-712c60da"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-683925ef", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-142-189.ec2.internal", "private_ip": "10.196.142.189", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test2"}, "tenancy": "default", "virtualization_type": "hvm"}], > "tagged_instances": []} > changed: [aaa-frs-ans-test2] => {"changed": true, "instance_ids": > ["i-b53a2632"], "instances": [{"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-1a2c60b1"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-b53a2632", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-141-57.ec2.internal", "private_ip": "10.196.141.57", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test2"}, "tenancy": "default", "virtualization_type": "hvm"}], > "tagged_instances": []} > changed: [aaa-frs-ans-test1] => {"changed": true, "instance_ids": > ["i-4f3a26c8"], "instances": [{"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-722c60d9"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-4f3a26c8", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-145-104.ec2.internal", "private_ip": "10.196.145.104", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test1"}, "tenancy": "default", "virtualization_type": "hvm"}], > "tagged_instances": []} > > TASK [Add hosts group temporary inventory group] > ******************************* > Tuesday 24 May 2016 13:25:29 -0500 (0:00:43.674) 0:00:47.713 > *********** > changed: [aaa-frs-ans-test1] => (item={u'kernel': None, > u'root_device_type': u'ebs', u'private_dns_name': > u'ip-10-196-145-104.ec2.internal', u'public_ip': None, u'private_ip': > u'10.196.145.104', u'id': u'i-4f3a26c8', u'ebs_optimized': False, u'state': > u'running', u'virtualization_type': u'hvm', u'architecture': u'x86_64', > u'ramdisk': None, u'block_device_mapping': {u'/dev/sda1': {u'status': > u'attached', u'delete_on_termination': True, u'volume_id': > u'vol-722c60d9'}}, u'key_name': u'FSR_DEV_QA_KEYPAIR', u'image_id': > u'ami-3683605b', u'tenancy': u'default', u'groups': {u'sg-7c538d04': > u'fsr-allow-all'}, u'public_dns_name': u'', u'state_code': 16, u'tags': > {u'Name': u'aaa-fsr-ans-test1', u'Env': u'Dev'}, u'placement': > u'us-east-1a', u'ami_launch_index': u'0', u'dns_name': u'', u'region': > u'us-east-1', u'launch_time': u'2016-05-24T18:24:48.000Z', > u'instance_type': u't2.micro', u'root_device_name': u'/dev/sda1', > u'hypervisor': u'xen'}) => {"add_host": {"groups": ["dynamic"], > "host_name": "10.196.145.104", "host_vars": {}}, "changed": true, "item": > {"ami_launch_index": "0", "architecture": "x86_64", "block_device_mapping": > {"/dev/sda1": {"delete_on_termination": true, "status": "attached", > "volume_id": "vol-722c60d9"}}, "dns_name": "", "ebs_optimized": false, > "groups": {"sg-7c538d04": "fsr-allow-all"}, "hypervisor": "xen", "id": > "i-4f3a26c8", "image_id": "ami-3683605b", "instance_type": "t2.micro", > "kernel": null, "key_name": "FSR_DEV_QA_KEYPAIR", "launch_time": > "2016-05-24T18:24:48.000Z", "placement": "us-east-1a", "private_dns_name": > "ip-10-196-145-104.ec2.internal", "private_ip": "10.196.145.104", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test1"}, "tenancy": "default", "virtualization_type": "hvm"}} > > TASK [Wait for SSH] > ************************************************************ > Tuesday 24 May 2016 13:25:29 -0500 (0:00:00.046) 0:00:47.759 > *********** > ok: [aaa-frs-ans-test1] => (item={u'kernel': None, u'root_device_type': > u'ebs', u'private_dns_name': u'ip-10-196-145-104.ec2.internal', > u'public_ip': None, u'private_ip': u'10.196.145.104', u'id': u'i-4f3a26c8', > u'ebs_optimized': False, u'state': u'running', u'virtualization_type': > u'hvm', u'architecture': u'x86_64', u'ramdisk': None, > u'block_device_mapping': {u'/dev/sda1': {u'status': u'attached', > u'delete_on_termination': True, u'volume_id': u'vol-722c60d9'}}, > u'key_name': u'FSR_DEV_QA_KEYPAIR', u'image_id': u'ami-3683605b', > u'tenancy': u'default', u'groups': {u'sg-7c538d04': u'fsr-allow-all'}, > u'public_dns_name': u'', u'state_code': 16, u'tags': {u'Name': > u'aaa-fsr-ans-test1', u'Env': u'Dev'}, u'placement': u'us-east-1a', > u'ami_launch_index': u'0', u'dns_name': u'', u'region': u'us-east-1', > u'launch_time': u'2016-05-24T18:24:48.000Z', u'instance_type': u't2.micro', > u'root_device_name': u'/dev/sda1', u'hypervisor': u'xen'}) => {"changed": > false, "elapsed": 72, "item": {"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-722c60d9"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-4f3a26c8", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-145-104.ec2.internal", "private_ip": "10.196.145.104", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test1"}, "tenancy": "default", "virtualization_type": "hvm"}, > "path": null, "port": 22, "search_regex": null, "state": "started"} > ok: [aaa-frs-ans-test2] => (item={u'kernel': None, u'root_device_type': > u'ebs', u'private_dns_name': u'ip-10-196-141-57.ec2.internal', > u'public_ip': None, u'private_ip': u'10.196.141.57', u'id': u'i-b53a2632', > u'ebs_optimized': False, u'state': u'running', u'virtualization_type': > u'hvm', u'architecture': u'x86_64', u'ramdisk': None, > u'block_device_mapping': {u'/dev/sda1': {u'status': u'attached', > u'delete_on_termination': True, u'volume_id': u'vol-1a2c60b1'}}, > u'key_name': u'FSR_DEV_QA_KEYPAIR', u'image_id': u'ami-3683605b', > u'tenancy': u'default', u'groups': {u'sg-7c538d04': u'fsr-allow-all'}, > u'public_dns_name': u'', u'state_code': 16, u'tags': {u'Name': > u'aaa-fsr-ans-test2', u'Env': u'Dev'}, u'placement': u'us-east-1a', > u'ami_launch_index': u'0', u'dns_name': u'', u'region': u'us-east-1', > u'launch_time': u'2016-05-24T18:24:48.000Z', u'instance_type': u't2.micro', > u'root_device_name': u'/dev/sda1', u'hypervisor': u'xen'}) => {"changed": > false, "elapsed": 72, "item": {"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-1a2c60b1"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-b53a2632", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-141-57.ec2.internal", "private_ip": "10.196.141.57", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test2"}, "tenancy": "default", "virtualization_type": "hvm"}, > "path": null, "port": 22, "search_regex": null, "state": "started"} > ok: [aaa-frs-ans-test3] => (item={u'kernel': None, u'root_device_type': > u'ebs', u'private_dns_name': u'ip-10-196-142-189.ec2.internal', > u'public_ip': None, u'private_ip': u'10.196.142.189', u'id': u'i-683925ef', > u'ebs_optimized': False, u'state': u'running', u'virtualization_type': > u'hvm', u'architecture': u'x86_64', u'ramdisk': None, > u'block_device_mapping': {u'/dev/sda1': {u'status': u'attached', > u'delete_on_termination': True, u'volume_id': u'vol-712c60da'}}, > u'key_name': u'FSR_DEV_QA_KEYPAIR', u'image_id': u'ami-3683605b', > u'tenancy': u'default', u'groups': {u'sg-7c538d04': u'fsr-allow-all'}, > u'public_dns_name': u'', u'state_code': 16, u'tags': {u'Name': > u'aaa-fsr-ans-test2', u'Env': u'Dev'}, u'placement': u'us-east-1a', > u'ami_launch_index': u'0', u'dns_name': u'', u'region': u'us-east-1', > u'launch_time': u'2016-05-24T18:24:48.000Z', u'instance_type': u't2.micro', > u'root_device_name': u'/dev/sda1', u'hypervisor': u'xen'}) => {"changed": > false, "elapsed": 72, "item": {"ami_launch_index": "0", "architecture": > "x86_64", "block_device_mapping": {"/dev/sda1": {"delete_on_termination": > true, "status": "attached", "volume_id": "vol-712c60da"}}, "dns_name": "", > "ebs_optimized": false, "groups": {"sg-7c538d04": "fsr-allow-all"}, > "hypervisor": "xen", "id": "i-683925ef", "image_id": "ami-3683605b", > "instance_type": "t2.micro", "kernel": null, "key_name": > "FSR_DEV_QA_KEYPAIR", "launch_time": "2016-05-24T18:24:48.000Z", > "placement": "us-east-1a", "private_dns_name": > "ip-10-196-142-189.ec2.internal", "private_ip": "10.196.142.189", > "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": > "us-east-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", > "state": "running", "state_code": 16, "tags": {"Env": "Dev", "Name": > "aaa-fsr-ans-test2"}, "tenancy": "default", "virtualization_type": "hvm"}, > "path": null, "port": 22, "search_regex": null, "state": "started"} > > TASK [Wait a little longer for centos] > ***************************************** > Tuesday 24 May 2016 13:26:42 -0500 (0:01:12.287) 0:02:00.047 > *********** > Pausing for 20 seconds > (ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort) > ok: [aaa-frs-ans-test1] => {"changed": false, "delta": 19, "rc": 0, > "start": "2016-05-24 13:26:42.068693", "stderr": "", "stdout": "Paused for > 20.0 seconds", "stop": "2016-05-24 13:27:02.068025", "user_input": ""} > > PLAY [dynamic] > ***************************************************************** > > TASK [setup] > ******************************************************************* > Tuesday 24 May 2016 13:27:02 -0500 (0:00:20.040) 0:02:20.087 > *********** > ok: [10.196.145.104] > > TASK [ansible-hostname-master : gather facts] > ********************************** > Tuesday 24 May 2016 13:27:06 -0500 (0:00:04.062) 0:02:24.150 > *********** > ok: [10.196.145.104] => {"ansible_facts": {"ansible_ec2_ami_id": > "ami-3683605b", "ansible_ec2_ami_launch_index": "0", > "ansible_ec2_ami_manifest_path": "(unknown)", > "ansible_ec2_block_device_mapping_ami": "/dev/sda1", > "ansible_ec2_block_device_mapping_root": "/dev/sda1", > "ansible_ec2_hostname": "ip-10-196-145-104.aws.foreseeresults.com", > "ansible_ec2_instance_action": "none", "ansible_ec2_instance_id": > "i-4f3a26c8", "ansible_ec2_instance_type": "t2.micro", > "ansible_ec2_local_hostname": "ip-10-196-145-104.aws.foreseeresults.com", > "ansible_ec2_local_ipv4": "10.196.145.104", "ansible_ec2_mac": > "0a:16:b5:46:d4:a1", "ansible_ec2_metrics_vhostmd": "<?xml version=\"1.0\" > encoding=\"UTF-8\"?>", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_device_number": "0", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_interface_id": > "eni-5d46c71e", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_local_hostname": " > ip-10-196-145-104.aws.foreseeresults.com", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_local_ipv4s": > "10.196.145.104", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_mac": > "0a:16:b5:46:d4:a1", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_owner_id": > "325603188418", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_security_group_ids": > "sg-7c538d04", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_security_groups": > "fsr-allow-all", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_subnet_id": > "subnet-4aa02e3c", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_subnet_ipv4_cidr_block": > "10.196.128.0/19", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_vpc_id": > "vpc-debf9bba", > "ansible_ec2_network_interfaces_macs_0a_16_b5_46_d4_a1_vpc_ipv4_cidr_block": > "10.196.0.0/16", "ansible_ec2_placement_availability_zone": "us-east-1a", > "ansible_ec2_placement_region": "us-east-1", "ansible_ec2_product_codes": > "aw0evgkw8e5c1q413zgy5pjce", "ansible_ec2_profile": "default-hvm", > "ansible_ec2_public_key": "ssh-rsa > AAAAB3NzaC1yc2EAAAADAQABAAABAQDGUJO+rS5fIh3bGcKrQzt66hywpxcVQMhz7rb4WyeMtii2gZ3PHb2mnxrTaLE5Q7g6tL8aBfluzASeP0dijWtSDM7YGD1TR6sYEHysxcHRd7dJLhoEsJzwwa8HgRnus66FKnCNtV9XahG/BdAqqDpcWtkmJfkegmzgJ4rjP46EKGW4CZ3JF1/sjVgHAxsU7tv6WWoaCv9+zqKTwWGlBbDHRQxrTmHzWsQlmrpBdr2OnUPSsGMmOcdFX89T4+0T8BQt8nJusFeVV2Nj0jGRFs6fy/a9+wOKLYYLer80Z5RP3NhKVxIEZWfZDN93McBaKRKaQJoj1VnZi0O8yW6P+0rR > FSR_DEV_QA_KEYPAIR\n", "ansible_ec2_reservation_id": "r-f0f66425", > "ansible_ec2_security_groups": "fsr-allow-all", > "ansible_ec2_services_domain": "amazonaws.com", > "ansible_ec2_services_partition": "aws", "ansible_ec2_user_data": null}, > "changed": false} > > TASK [ansible-hostname-master : get resource tags] > ***************************** > Tuesday 24 May 2016 13:27:07 -0500 (0:00:01.044) 0:02:25.194 > *********** > ok: [10.196.145.104 -> localhost] => {"changed": false, "tags": {"Env": > "Dev", "Name": "aaa-fsr-ans-test1"}} > > TASK [ansible-hostname-master : Keep temporary old hostname in /etc/hosts] > ***** > Tuesday 24 May 2016 13:27:07 -0500 (0:00:00.423) 0:02:25.617 > *********** > ok: [10.196.145.104] => {"backup": "", "changed": false, "msg": ""} > > TASK [ansible-hostname-master : Set hostname] > ********************************** > Tuesday 24 May 2016 13:27:08 -0500 (0:00:00.826) 0:02:26.444 > *********** > changed: [10.196.145.104] => {"ansible_facts": {"ansible_domain": "", > "ansible_fqdn": "aaa-fsr-ans-test1", "ansible_hostname": > "aaa-fsr-ans-test1", "ansible_nodename": "aaa-fsr-ans-test1"}, "changed": > true, "name": "aaa-fsr-ans-test1"} > > TASK [ansible-hostname-master : Update /etc/hosts] > ***************************** > Tuesday 24 May 2016 13:27:10 -0500 (0:00:02.190) 0:02:28.634 > *********** > changed: [10.196.145.104] => {"backup": "", "changed": true, "msg": "line > added"} > > TASK [ansible-hostname-master : add the preserve_hostname true to > /etc/cloud/cloud.cfg] *** > Tuesday 24 May 2016 13:27:11 -0500 (0:00:00.837) 0:02:29.471 > *********** > changed: [10.196.145.104] => {"backup": "", "changed": true, "msg": "line > added"} > > PLAY RECAP > ********************************************************************* > 10.196.145.104 : ok=7 changed=3 unreachable=0 failed=0 > aaa-frs-ans-test1 : ok=5 changed=2 unreachable=0 failed=0 > aaa-frs-ans-test2 : ok=3 changed=1 unreachable=0 failed=0 > aaa-frs-ans-test3 : ok=3 changed=1 unreachable=0 failed=0 > > Tuesday 24 May 2016 13:27:12 -0500 (0:00:00.774) 0:02:30.246 > *********** > > =============================================================================== > TASK: Wait for SSH ----------------------------------------------------- > 72.29s > TASK: Launch Instance -------------------------------------------------- > 43.67s > TASK: Wait a little longer for centos ---------------------------------- > 20.04s > TASK: setup ------------------------------------------------------------- > 4.06s > TASK: setup ------------------------------------------------------------- > 4.02s > TASK: ansible-hostname-master : Set hostname ---------------------------- > 2.19s > TASK: ansible-hostname-master : gather facts ---------------------------- > 1.04s > TASK: ansible-hostname-master : Update /etc/hosts ----------------------- > 0.84s > TASK: ansible-hostname-master : Keep temporary old hostname in /etc/hosts > --- 0.83s > TASK: ansible-hostname-master : add the preserve_hostname true to > /etc/cloud/cloud.cfg --- 0.77s > TASK: ansible-hostname-master : get resource tags ----------------------- > 0.42s > TASK: Add hosts group temporary inventory group ------------------------- > 0.05s > > -- > 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/0c3f7db4-ca10-4028-8203-e4a35fef8e6b%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/0c3f7db4-ca10-4028-8203-e4a35fef8e6b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- 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/CAD8N0v-oUzpWBeNeoUzq4vPRmq46krV7rhWDTEzJH4O%2BGFpvng%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
