# AWS dynamic inventory and filter out unreachable host

**URL:** <https://forum.ansible.com/t/aws-dynamic-inventory-and-filter-out-unreachable-host/22045>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [July 19, 2016, 10:59am UTC](https://forum.ansible.com/t/aws-dynamic-inventory-and-filter-out-unreachable-host/22045 "2016-07-19T10:59:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [July 19, 2016, 10:59am UTC](https://forum.ansible.com/t/aws-dynamic-inventory-and-filter-out-unreachable-host/22045/1 "2016-07-19T10:59:47Z")

</div>

I want to use the ec2\_facts module to gather info, e.g.

`

- hosts: all  
gather\_facts: false  
become: no  
tasks:
- name: Get instance ec2 facts  
action: ec2\_facts  
register: ec2\_facts

`

Is there a way to filter out the SSH unreachable (maybe not on first run) but maybe give them a specific tag; so check for error message and then I can tag those ec2 instance to filter them out next run?

---

<div class="post-metadata">

**Author:** ![alexey.vazhnov](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@alexey.vazhnov](https://forum.ansible.com/u/alexey.vazhnov)\
**Post date:** [July 19, 2016, 11:40am UTC](https://forum.ansible.com/t/aws-dynamic-inventory-and-filter-out-unreachable-host/22045/2 "2016-07-19T11:40:45Z")

</div>

I know only «all\_instances = False» (by default) in ec2.ini, to exclude stopped.  
Unreachable hosts will be skipped by Ansible, but error messages will be displayed.

---

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [July 19, 2016, 12:48pm UTC](https://forum.ansible.com/t/aws-dynamic-inventory-and-filter-out-unreachable-host/22045/3 "2016-07-19T12:48:45Z")

</div>

For larger environment that seems a bit unwieldy; I am wondering what would be the best practice here? E.g. are people running this sort of playbook automatically every x minutes and then use the cache facts?
