I like to use atop at the first step during investigation : https://www.atoptool.nl/
Just for you to known, they store the compose file. It’s in their compose folder on the data volume.
I 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}\"}
Not sure if i really get what you are trying to do but you can check for the pre_task keyword. It’s seems you are overengineering something. Try to think about idempotency
They will don’t care, not their money, not their job. Can’t blame them
Don’t think git as a sync storage, more like to merge works.
If you need to share files between computers use a shared storage.
Always use the right tool for the job. Mount a shared storage or use synctools rsync, etc