I wrote a playbook that checks out brand new servers that are built for my team. To make things truly one-and-done, I thought it would be clever to include a play that copies the ssh public key from our ansible controller to the freshly built remote hosts.
I tried using the authorized_key module, but it doesn’t seem to work…
I’ve been looking at the -vvvv output and it doesn’t really help.
I guess I should ask this question… Does this module work for copying over the initial key? Or does it only work if there is already an ssh-key set up for ansible to use?
It does not need a key but it DOES need a way to login, normally user/password if keys are not available.
The other option is a super user that already has access can copy the keys for the specific users. Some cloud APIs allow for pushing a key through alternate methods, this module does not know about that (look at cloud specific modules for that).