Fetch public key of host A and put it in .ssh/authorized_keys of host B

Each one of our customers has at least two hosts, A and B. The public
ssh key for user foo on A has to be on authorized_keys of user foo on
B.

How to ensure this gets done on one run? The jobs are launched in
parallell, and we have no guarantee that the playbook run on A will
have fetched the key by the time the playbook run on B attempts to
upload it.

Thanks,

Javier

I’d say you would have to make two plays in 1 playbook.

Play 1 would create the desired user and create it’s ssh-keys.
It would also copy it’s keys to a local folder.

Play 2 would then distribute that key to all other servers that need it.

Of course, thanks.

J