File dependency between multiple hosts

Hi I have a very specific deployment case and am not sure how to plan it using Ansible or even if it’s something doable with Ansible.

Deploying a MongoDB swarm on 3 servers, I have to deploy on 1 server first which generates a “secrets” file that must then be used to deploy the 2nd and 3rd nodes of the swarm.

Would the only way to do it be to run a role for the master, then collect the secrets file and inject it as an input to the role for the 2 others?

Thank you

Ideally you’d create such a secrets file yourself and use that to deploy all nodes, probably with that master node first of that is required.
But if the software does not allow that, then your proposed way is the best solution I think.