iterate over "failed" hosts?

40 views
Skip to first unread message

Dmitry Makovey

unread,
Oct 7, 2014, 3:07:53 PM10/7/14
to ansible...@googlegroups.com
I've got an interesting case: playbook is failing on certain hosts either due to SSH connection issues or because some things are not installed.

I realize that I should really just write a playbook that makes all my machines "compliant" with the playbook and then re-run it. However I am curious whether there is a way to do a "group_by" or something similar to pick up all the "failed" hosts, group them by cause and then run some actions against them: be it an addition of a record to DB indicating above failure or attempt at resolving an underlying problem. 

Dmitry Makovey

unread,
Oct 7, 2014, 3:12:53 PM10/7/14
to ansible...@googlegroups.com
BTW I did read http://docs.ansible.com/developing_api.html and http://jpmens.net/2012/12/13/obtaining-remote-data-with-ansible-s-api/ that provide fine examples of doing it via API code. I'm more curious whether I can sneak something in through the playbook...

Michael DeHaan

unread,
Oct 8, 2014, 8:42:34 AM10/8/14
to ansible...@googlegroups.com
When Ansible playbooks fail, Ansible generates a retry file to limit a playbook run to just failed hosts.

You can use this file to just target those specific hosts.


On Tue, Oct 7, 2014 at 3:12 PM, Dmitry Makovey <droop...@gmail.com> wrote:
BTW I did read http://docs.ansible.com/developing_api.html and http://jpmens.net/2012/12/13/obtaining-remote-data-with-ansible-s-api/ that provide fine examples of doing it via API code. I'm more curious whether I can sneak something in through the playbook...

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b020837e-952b-4c8a-af31-969603a30846%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dmitry Makovey

unread,
Oct 9, 2014, 11:13:18 AM10/9/14
to ansible...@googlegroups.com


On Wednesday, October 8, 2014 6:42:34 AM UTC-6, Michael DeHaan wrote:
When Ansible playbooks fail, Ansible generates a retry file to limit a playbook run to just failed hosts.

You can use this file to just target those specific hosts.

I was thinking more "inline" kind of action. While I have all the facts/vars loaded for the entire fleet (in case I need them). Kind of like "branch off to fix things that I know how to fix..." But I guess this goes more and more into the "use Ansible via API" kind of territory? 
Reply all
Reply to author
Forward
0 new messages