How to stop the play only for one hostgroup if any one host failed in that hostgroup ?

Hi,

Instead of passing to specific hostgroup, can i pass the regex to “hosts: ” for the play hosts ?.

eg:-

  • name: pre-step of the setup process
    hosts: cluster_.*
    gather_facts: false
    strategy: free
    any_errors_fatal: true
    tasks:
  • include : roles/setup_node/tasks/pre-setup.yml

Basically i have dynamic hosts group name prefix with “cluster_”. The above method of regex way is not working ?. any tricks or best practices to get the dynamic inventory.

another requirement:-
[cluster_x1]
host1
host2

[cluster_x2]
host3
host4

In the above host inventory file, if host2 fails on play, i would like to not to consider other tasks in the play for both host1, host2 for cluster cluster_x1. Is that possible ?.

Thanks
venkat

Never done it, but i think you can use limit:

https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/commands/

Hi ,

limit:1
max_fail_percent:0

This should help you as it will limit the number of hosts your playbook is run as well if it fails it will not run on any more hosts .

dynamic inventory i am still trying to understand it ,

Here is a link from which can help you

docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html

ta

True. I can make it to max_fail_percent:99 to get it fail if any one fails. but hosts regex part is still in question to me :frowning:

Thanks
venkat

It doesn't support regex but pattern, all about it in the docs
https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html