AWS dynamic inventory and filter out unreachable host

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?

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.

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?