AWS dynamic inventory and filter out unreachable host

79 views
Skip to first unread message

Anthony Cheng

unread,
Jul 19, 2016, 6:59:48 AM7/19/16
to Ansible Project
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?

Alexey Vazhnov

unread,
Jul 19, 2016, 7:40:45 AM7/19/16
to Ansible Project
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.

Anthony Cheng

unread,
Jul 19, 2016, 8:48:45 AM7/19/16
to Ansible Project
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?
Reply all
Reply to author
Forward
0 new messages