Skip to content

Instantly share code, notes, and snippets.

@tjbenator
Created April 19, 2019 14:31
Show Gist options
  • Save tjbenator/b5c8df7d25ff14a5ea09096839bf2b56 to your computer and use it in GitHub Desktop.
Save tjbenator/b5c8df7d25ff14a5ea09096839bf2b56 to your computer and use it in GitHub Desktop.
Distribute SSH keys from your Github Account
- hosts: all
tasks:
- name: Get SSH Keys
uri:
url: https://api.github.com/users/tjbenator/keys
method: GET
return_content: yes
register: ssh_keys
- name: Add keys to authorized_keys file
lineinfile:
path: "/home/travis/.ssh/authorized_keys"
line: "{{ item['key'] }}"
create: yes
validate: 'ssh-keygen -lf %s'
with_items: "{{ (ssh_keys.content|from_json) }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment