Actually, I just played with this a bit more and registered the output of the EC2 task that creates these instances. I’ve run through this a number of times so the 1 instance already exists, but the output of my Ansible run indicates that it thinks there are 2 instances. The following is the registered output:
ok: [localhost] => { "var": { "app_var": { "changed": false, "msg": "All items completed", "results": [ { "changed": false, "skipped": true }, { "changed": false, "instance_ids": null, "instances": [], "invocation": { "module_args": "", "module_name": "ec2" }, "item": { "az": "us-west-1a", "cidr": "10.1.2.0/24", "id": "subnet-ecea39b5", "resource_tags": { "Name": "example-subnet-app" } }, "tagged_instances": [ { "ami_launch_index": "0", "architecture": "x86_64", "dns_name": "", "ebs_optimized": false, "groups": { "sg-3684fe53": "example-sg-app", "sg-3c84fe59": "example-sg-access" }, "hypervisor": "xen", "id": "i-cb3fe479", "image_id": "ami-df6a8b9b", "instance_type": "c4.large", "kernel": null, "key_name": "example_key", "launch_time": "2015-09-28T22:39:11.000Z", "placement": "us-west-1a", "private_dns_name": "ip-10-1-2-63.us-west-1.compute.internal", "private_ip": "10.1.2.63", "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": "us-west-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", "state": "running", "state_code": 16, "tags": { "Environment": "prod", "Name": "example-ec2-app", "Subnet": "example-subnet-app", "Type": "app", "VPC": "example" }, "tenancy": "default", "virtualization_type": "hvm" } ] }, { "changed": false, "instance_ids": null, "instances": [], "invocation": { "module_args": "", "module_name": "ec2" }, "item": { "az": "us-west-1b", "cidr": "10.1.3.0/24", "id": "subnet-921486f7", "resource_tags": { "Name": "example-subnet-app" } }, "tagged_instances": [ { "ami_launch_index": "0", "architecture": "x86_64", "dns_name": "", "ebs_optimized": false, "groups": { "sg-3684fe53": "example-sg-app", "sg-3c84fe59": "example-sg-access" }, "hypervisor": "xen", "id": "i-cb3fe479", "image_id": "ami-df6a8b9b", "instance_type": "c4.large", "kernel": null, "key_name": "example_key", "launch_time": "2015-09-28T22:39:11.000Z", "placement": "us-west-1a", "private_dns_name": "ip-10-1-2-63.us-west-1.compute.internal", "private_ip": "10.1.2.63", "public_dns_name": "", "public_ip": null, "ramdisk": null, "region": "us-west-1", "root_device_name": "/dev/sda1", "root_device_type": "ebs", "state": "running", "state_code": 16, "tags": { "Environment": "prod", "Name": "example-ec2-app", "Subnet": "example-subnet-app", "Type": "app", "VPC": "example" }, "tenancy": "default", "virtualization_type": "hvm" } ] }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true }, { "changed": false, "skipped": true } ] } } }
It appears to me that Ansible thinks 2 instances exist, but I only see one in the AWS console.