Hello,
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..
Here is the play:
---
- name: Checkout new build
hosts: all
remote_user: blah
tasks:
- name: copy ssh key to remote host
authorized_key:
user: blah
key: "{{ lookup('file', '/home/blah/.ssh/id_rsa.pub') }}"
Here is the error I get:
TASK [setup] *******************************************************************
fatal: [hostname redacted]: UNREACHABLE! => {"changed": false, "msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}
Here is the command I am running:
ansible-playbook
-i /home/blah/ansible/inventory/newBuilds.hosts
/home/blah/ansible/playbooks/linuxCheckout/linuxCheckout.yml --ask-pass
Am I doing something wrong?
Best regards,
-C