I have a playbook that will configure a redis cluster and nutcracker as a proxy. What hosts play, what roles are defined for each group. I would like to add a health check before completing tasks, namely:
- Is there only one proxy? (1 host in group A)
- Is there at least one redis node (> = 1 host in group B)
I already have a solution, although I find it pretty ugly and thought there should be something better, but I just can't find it. I am currently running a local task that calls the playbook again with the -list-hosts option and check the output.
- name: Make sure there is only one proxy defined shell: ansible-playbook -i {{ inventory_file }} redis-cluster.yml --tags "redis-proxy" --list-hosts register: test failed_when: test.stdout.find("host count=1\n") == -1 changed_when: 1 == 2
This works, but is there no easy way to check the number of hosts in a group without this extra call?
ansible ansible-playbook
udondan
source share