Ansible makes it easy enough to ensure that a process is running on every host.
I could do something like:
---
- hosts: app_cluster
tasks:
- name: Look for the "foo" process
shell: ps -ef | grep foo | grep -v grep
register: process_list
changed_when: false
- name: Start "foo" if needed
shell: nohup /bin/foo &
when: "process_list.stdout.find('foo') == -1"
However, I need to have exactly one instance of a certain process across the cluster. Ie. it can run on any host, just as long as it is running somewhere and so long as there is only one such process anywhere in the cluster.
Might there be a convenient way to do this in an ansible playbook?