Hi all -
I’m trying to gather facts from an ec2 instance. Specially, the operating system release (i.e. /etc/redhat-release). I can gather the info from local VMs, but Ansible doesn’t seem to return the OS when I gather facts from an EC2 instance. I tried the ec2_instance_facts module (https://docs.ansible.com/ansible/latest/modules/ec2_instance_facts_module.html#ec2-instance-facts-module), but that doesn’t seem to return it (at least, it doesn’t return it for the Amazon Linux distro).
Does anyone have any idea how to gather this info from ec2 instances? Is it just a limitation with Amazon Linux? If so, then I can hardcode values if I have a way of knowing it’s Amazon Linux, but I can’t seem to figure out a way to find that out either.
Here’s a sample of when I pulled the facts from the instance:
“item”: {
“ami_launch_index”: 0,
“architecture”: “x86_64”,
“block_device_mappings”: [
{
“device_name”: “/dev/xvda”,
“ebs”: {
“attach_time”: “2019-05-21T17:34:55+00:00”,
“delete_on_termination”: true,
“status”: “attached”,
“volume_id”: “xxx”
}
}
],
“client_token”: “”,
“ebs_optimized”: false,
“ena_support”: true,
“hypervisor”: “xen”,
“image_id”: “ami-02c6024b3d5467e4a”,
“instance_id”: “xxx”,
“instance_type”: “r5d.2xlarge”,
“key_name”: “xxx”,
“launch_time”: “2019-05-21T17:34:55+00:00”,
“monitoring”: {
“state”: “disabled”
},
“network_interfaces”: [
{
“attachment”: {
“attach_time”: “2019-05-21T17:34:55+00:00”,
“attachment_id”: “xxx”,
“delete_on_termination”: true,
“device_index”: 0,
“status”: “attached”
},
“description”: “”,
“groups”: [
{
“group_id”: “xxx”,
“group_name”: “xxx”
}
],
“ipv6_addresses”: ,
“mac_address”: “xxx”,
“network_interface_id”: “xxx”,
“owner_id”: “xxx”,
“private_dns_name”: “xxx”,
“private_ip_address”: “xxx”,
“private_ip_addresses”: [
{
“primary”: true,
“private_dns_name”: “xxx”,
“private_ip_address”: “xxx”
}
],
“source_dest_check”: true,
“status”: “in-use”,
“subnet_id”: “xxx”,
“vpc_id”: “xxx”
}
],
“placement”: {
“availability_zone”: “us-east-1a”,
“group_name”: “”,
“tenancy”: “default”
},
“private_dns_name”: “xxx”,
“private_ip_address”: “xxx”,
“product_codes”: ,
“public_dns_name”: “”,
“root_device_name”: “/dev/xvda”,
“root_device_type”: “ebs”,
“security_groups”: [
{
“group_id”: “xxx”,
“group_name”: “xxx”
}
],
“source_dest_check”: true,
“state”: {
“code”: 16,
“name”: “running”
},
“state_transition_reason”: “”,
“subnet_id”: “xxx”,
“tags”: {
“Name”: “xxx”,
“class”: “xxx”
},
“virtualization_type”: “hvm”,
“vpc_id”: “xxx”
}