Trying to add two people's Github public keys to a user's authorized users file. I am able to successfully retrieve the SSH keys:
---
- hosts: 127.0.0.1
connection: local
vars:
my_users:
belminf: "belminf"
bob: "tmessins"
tasks:
- name: Retrieving all keys from GitHub
shell: /usr/bin/curl https://github.com/{{ item.value }}.keys 2> /dev/null
register: ssh_keys
with_dict: my_users
- debug: var=ssh_keys
However, I'm unsure how to loop through ssh_keys
results and use authorized_keys
task to add the retrieved keys.
My ridiculous attempt:
- name: Adding keys to authorized_keys
authorized_key: user=belminf key="{{ item }}" path=/home/belminf/test_auth state=present
with_items: ssh_keys.results
Results in invalid key specified
. Understandably but I'm out of ideas. Anyone?