Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Last active August 29, 2015 14:01
Show Gist options
  • Save hostmaster/c4b1111e3a8eddda3c95 to your computer and use it in GitHub Desktop.
Save hostmaster/c4b1111e3a8eddda3c95 to your computer and use it in GitHub Desktop.
Use public keys from github accounts for authorized_key file
# github_pub_keys:
# - username1
# - username2
- shell: curl -s "https://github.com/{{ item }}.keys"
with_items: github_pub_keys
register: pub_keys
changed_when: False
tags: keys
- name: Check curl return codes
fail:
msg: "The command ({{ item.cmd }}) did not have a 0 return code"
when: item.rc != 0
with_items: pub_keys.results
tags: keys
- name: Deploy ssh public key
authorized_key: >
user="{{ admin_user }}"
key="{{ item.stdout }}"
with_items: pub_keys.results
tags: keys
@hostmaster
Copy link
Author

A follow up for this gist https://gist.github.com/hostmaster/fc4bb8a2a9301bc2285f
Keeping only managed by ansible ssh public keys all other (unmanaged) keys will be wiped out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment