Last active
August 29, 2015 14:01
-
-
Save hostmaster/c4b1111e3a8eddda3c95 to your computer and use it in GitHub Desktop.
Use public keys from github accounts for authorized_key file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.