Skip to content

Instantly share code, notes, and snippets.

@patio11
Created July 9, 2015 02:44
Show Gist options
  • Save patio11/24a3a68fd26f65e484e1 to your computer and use it in GitHub Desktop.
Save patio11/24a3a68fd26f65e484e1 to your computer and use it in GitHub Desktop.
Create an account on every box using the list of employees; initialize with their Github SSH keys
vars:
starfighters:
- username: patrick
github: patio11
name: "Patrick McKenzie"
- username: thomas
github: tqbf
name: "Thomas Ptacek"
- username: erin
github: boboTjones
name: "Erin Ptacek"
tasks:
- shell: rm -rf /tmp/*.authorized_keys #Cleans up temporary authorized keys on your local machine
- name: Create group for the starfighters
group: name=fighters
- name: Create founder accounts and grant us sudo privileges
user: name={{item.username}} comment="{{item.name}}" groups=fighters,admin shell=/bin/bash
with_items: starfighters
- name: Copy founders' public keys from Github
delegate_to: 127.0.0.1
sudo: no
get_url: url=https://github.com/{{item.github}}.keys dest=/tmp/{{item.github}}.authorized_keys
with_items: "{{ starfighters }}"
- name: Install those public keys
authorized_key: user={{item.username}} key="{{ lookup('file', '/tmp/' + item.github + '.authorized_keys') }}"
with_items: "{{ starfighters }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment