- hosts: some_hosts
gather_facts: False
tasks:
- block:
- name: Run puppet agent
puppet:
register: puppet_run
failed_when: puppet_run.stdout.find('Finished catalog run in') == -1 and puppet_run.stdout.find('configuration client already in progress') == -1
rescue:
- name: add host to the list of failed puppets
add_host: name={{ inventory_hostname }} group=failed_puppets