Skip to content

Instantly share code, notes, and snippets.

@larsks
Created January 10, 2019 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/335aaa191f394c907624d8d479987618 to your computer and use it in GitHub Desktop.
Save larsks/335aaa191f394c907624d8d479987618 to your computer and use it in GitHub Desktop.
ec2:
results: [
{
"_ansible_ignore_errors": null,
"_ansible_item_label": {
"hn": "ddmtstsy01dxh1.dev.oclc.org",
"it": "t2.micro",
"sg": "[redacted]",
"sn": "[redacted]"
},
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"failed": false,
"instance_ids": [
"i-09d1504161dddf22d"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"block_device_mapping": {
"/dev/sda1": {
"delete_on_termination": true,
"status": "attached",
"volume_id": "vol-03c3b7d2bbc1c2433"
}
},
"dns_name": "",
"ebs_optimized": false,
"groups": {
"[redacted]": "[redacted]"
},
"hypervisor": "xen",
"id": "i-09d1504161dddf22d",
"image_id": "[redacted]",
"instance_type": "t2.micro",
"kernel": null,
"key_name": "AHS-Deploy",
"launch_time": "2019-01-10T19:11:06.000Z",
"placement": "us-east-2a",
"private_dns_name": "ip-10-3-16-248.us-east-2.compute.internal",
"private_ip": "10.3.16.248",
"public_dns_name": "",
"public_ip": null,
"ramdisk": null,
"region": "us-east-2",
"root_device_name": "/dev/sda1",
"root_device_type": "ebs",
"state": "running",
"state_code": 16,
"tags": {
"Name": "ddmtstsy01dxh1.dev.oclc.org"
},
"tenancy": "default",
"virtualization_type": "hvm"
}
],
"invocation": {
"module_args": {
"assign_public_ip": null,
"count": 1,
"count_tag": null,
"ebs_optimized": false,
"ec2_url": null,
"exact_count": null,
"group": null,
"group_id": [
"[redacted]"
],
"id": null,
"image": "[redacted]",
"instance_ids": null,
"instance_initiated_shutdown_behavior": null,
"instance_profile_name": null,
"instance_tags": {
"Name": "ddmtstsy01dxh1.dev.oclc.org"
},
"instance_type": "t2.micro",
"kernel": null,
"key_name": "[redacted]",
"monitoring": false,
"network_interfaces": null,
"placement_group": null,
"private_ip": null,
"profile": null,
"ramdisk": null,
"region": "us-east-2",
"security_token": null,
"source_dest_check": true,
"spot_launch_group": null,
"spot_price": null,
"spot_type": "one-time",
"spot_wait_timeout": "600",
"state": "present",
"tenancy": "default",
"termination_protection": null,
"user_data": "fqdn:ddmtstsy01dxh1.dev.oclc.org",
"validate_certs": true,
"volumes": null,
"vpc_subnet_id": "[redacted]",
"wait": true,
"wait_timeout": "300",
"zone": null
}
},
"item": {
"hn": "ddmtstsy01dxh1.dev.oclc.org",
"it": "t2.micro",
"sg": "[redacted]",
"sn": "[redacted]"
},
"tagged_instances": []
},
{
"_ansible_ignore_errors": null,
"_ansible_item_label": {
"hn": "ddmtstsy02dxh1.dev.oclc.org",
"it": "t2.micro",
"sg": "[redacted]",
"sn": "[redacted]"
},
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"failed": false,
"instance_ids": [
"i-0a642b9dc8a51c632"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"block_device_mapping": {
"/dev/sda1": {
"delete_on_termination": true,
"status": "attached",
"volume_id": "vol-05d3c2c53d48fb8d1"
}
},
"dns_name": "",
"ebs_optimized": false,
"groups": {
"[redacted]": "[redacted]"
},
"hypervisor": "xen",
"id": "i-0a642b9dc8a51c632",
"image_id": "[redacted]",
"instance_type": "t2.micro",
"kernel": null,
"key_name": "[redacted]",
"launch_time": "2019-01-10T19:11:29.000Z",
"placement": "us-east-2a",
"private_dns_name": "ip-10-3-16-105.us-east-2.compute.internal",
"private_ip": "10.3.16.105",
"public_dns_name": "",
"public_ip": null,
"ramdisk": null,
"region": "us-east-2",
"root_device_name": "/dev/sda1",
"root_device_type": "ebs",
"state": "running",
"state_code": 16,
"tags": {
"Name": "ddmtstsy02dxh1.dev.oclc.org"
},
"tenancy": "default",
"virtualization_type": "hvm"
}
],
"invocation": {
"module_args": {
"assign_public_ip": null,
"count": 1,
"count_tag": null,
"ebs_optimized": false,
"ec2_url": null,
"exact_count": null,
"group": null,
"group_id": [
"[redacted]"
],
"id": null,
"image": "[redacted]",
"instance_ids": null,
"instance_initiated_shutdown_behavior": null,
"instance_profile_name": null,
"instance_tags": {
"Name": "ddmtstsy02dxh1.dev.oclc.org"
},
"instance_type": "t2.micro",
"kernel": null,
"key_name": "[redacted]",
"monitoring": false,
"network_interfaces": null,
"placement_group": null,
"private_ip": null,
"profile": null,
"ramdisk": null,
"region": "us-east-2",
"security_token": null,
"source_dest_check": true,
"spot_launch_group": null,
"spot_price": null,
"spot_type": "one-time",
"spot_wait_timeout": "600",
"state": "present",
"tenancy": "default",
"termination_protection": null,
"user_data": "fqdn:ddmtstsy02dxh1.dev.oclc.org",
"validate_certs": true,
"volumes": null,
"vpc_subnet_id": "[redacted]",
"wait": true,
"wait_timeout": "300",
"zone": null
}
},
"item": {
"hn": "ddmtstsy02dxh1.dev.oclc.org",
"it": "t2.micro",
"sg": "[redacted]",
"sn": "[redacted]"
},
"tagged_instances": []
}
]
---
- hosts: localhost
gather_facts: false
vars_files:
- data.yml
tasks:
- debug:
msg: "ID: {{ item.instances.0.id }} Private IP: {{ item.instances.0.private_ip }}"
loop: "{{ ec2.results }}"
loop_control:
label: "{{ item.instances.0.id }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment