So, I’ve noticed I have a tendency to do things a little backwards but, I’m hoping someone can clear something up for me.
Originally, i was using the file/copy module in ansible to copy the authorized_keys2 file from the ansible server to the “node” in question. A colleague of mine stated I should use the ssh key module (authorized_key) instead of copying the file.
Now I’ve noticed I either have to put the key in the actual playbook, or read it from a file using key=“{{ lookup(‘file’, item.key) }}” . The two problems here are 1) it doesn’t allow for comments and 2) it doesn’t allow for multiple hosts (ie: if someone has multiple source machines they may come from). The file I’m reading from has to be pure host key, that’s it.
Is there a benefit to using the authorized_key over copying the file? I’d rather do the copy but, I figured let me ask if I’m missing something.