Trying to push locally stored .pub keys to the "authorized_keys" on a remote host

Hi,

I’m looking at the Ansible ‘authorized_key’ module and I’m unable to figure out whether it’s possible to push locally stored .pub keys to the authorized_keys file on a remote host. I don’t want to go the route of uploading .pub keys to a webserver and use URL links to transfer the keys to the target machine’s ‘authorized_key’ file. Is there another way to achieve this via Ansible? Please let me know if I’m not making much sense.

thanks,

The docs for the authorized_key module has an example that covers this exact case:

http://docs.ansible.com/ansible/latest/authorized_key_module.html

  • name: Set authorized key took from file
    authorized_key:
    user: charlie
    state: present
    key: “{{ lookup(‘file’, ‘/home/charlie/.ssh/id_rsa.pub’) }}”

That's what the first example in the module documentation does.

I see. I’m not thinking abstractly enough. Thanks!