Kkmou@lemm.eetoAnsible@lemmy.world•pick a leader from all the hosts in the inventoryEnglish
1·
26 days agoI think the idea to register the leader status during a dedicated task like Matt said is the better move.
You got this module if you want to create dynamic group during play :
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/add_host_module.html
And during gather_facts, you could add your own custom facts :
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html#adding-custom-facts
Bash script example returning json :
#!/bin/bash
leader_status=$(curl http://127.0.0.1/leader_status)
echo {\"leader\" : \"${leader_status}\"}
Just for you to known, they store the compose file. It’s in their compose folder on the data volume.