# ansible-inventory  --list .. how to get part of info

**URL:** <https://forum.ansible.com/t/ansible-inventory-list-how-to-get-part-of-info/35093>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [May 2, 2021, 3:04am UTC](https://forum.ansible.com/t/ansible-inventory-list-how-to-get-part-of-info/35093 "2021-05-02T03:04:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [May 2, 2021, 3:04am UTC](https://forum.ansible.com/t/ansible-inventory-list-how-to-get-part-of-info/35093/1 "2021-05-02T03:04:26Z")

</div>

hello

i am using ansible-inventory with AWS

I see all EC2 details … great

Is it possible from the output to extract only some info

eg

To list AWS resources execute the below command:

1

./ec2.py --list

This will return the entire list of AWS resources in JSON.

{  
“\_meta”: {  
“hostvars”: {  
“65.201.11.219”: {  
“ansible\_host”: “34.201.11.219”,  
“ec2\_\_in\_monitoring\_element”: false,  
“ec2\_account\_id”: “209518873002”,  
“ec2\_ami\_launch\_index”: “0”,  
“ec2\_architecture”: “x86\_64”,  
“ec2\_block\_devices”: {  
“xvda”: “vol-008e156f7bc2d99ad”  
},  
“ec2\_client\_token”: “”,  
“ec2\_dns\_name”: “[ec2-65-201-11-219.compute-1.amazonaws.com](http://ec2-65-201-11-219.compute-1.amazonaws.com)”,  
“ec2\_ebs\_optimized”: false,  
“ec2\_eventsSet”: “”,  
“ec2\_group\_name”: “”,  
“ec2\_hypervisor”: “xen”,  
“ec2\_id”: “i-09689b6635c10f3cf2”,  
“ec2\_image\_id”: “ami-467ca739”,  
“ec2\_instance\_profile”: “”,  
“ec2\_instance\_type”: “t2.micro”,  
“ec2\_ip\_address”: “34.222.11.219”,  
“ec2\_item”: “”,  
“ec2\_kernel”: “”,  
“ec2\_key\_name”: “ec2\_private.pem”,  
“ec2\_launch\_time”: “2018-07-04T20:10:57.000Z”  
}}}}

so say i need only below

ansible\_host": “34.201.11.219”,  
“ec2\_image\_id”: “ami-467ca739”,  
“ec2\_instance\_type”: “t2.micro”,  
“ec2\_ip\_address”: “34.222.11.219”,

Any suggestions Please

I think some of you may say use other modules for that …

Just wanted to know if that is the way or we can do anything else

As i know there are functions/tools to manipulate the jason o/p … but that be a overkill & hence use other modules like community.aws.ec2\_instance\_info

thanks

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [May 2, 2021, 4:21am UTC](https://forum.ansible.com/t/ansible-inventory-list-how-to-get-part-of-info/35093/2 "2021-05-02T04:21:19Z")

</div>

ec2.py is deprecated. Please use [https://github.com/ansible-collections/amazon.aws/blob/main/plugins/inventory/aws\_ec2.py](https://github.com/ansible-collections/amazon.aws/blob/main/plugins/inventory/aws_ec2.py)

You can specify filters to keep only the information you require. Check example section for more information - [https://github.com/ansible-collections/amazon.aws/blob/c5d31d709487afc5df19c60245698532352d80e3/plugins/inventory/aws\_ec2.py#L104](https://github.com/ansible-collections/amazon.aws/blob/c5d31d709487afc5df19c60245698532352d80e3/plugins/inventory/aws_ec2.py#L104)

---

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [May 2, 2021, 6:22am UTC](https://forum.ansible.com/t/ansible-inventory-list-how-to-get-part-of-info/35093/3 "2021-05-02T06:22:04Z")

</div>

Thanks Abhijeet
