Skip to content

Instantly share code, notes, and snippets.

@zwned
Last active January 3, 2016 12:09
Show Gist options
  • Save zwned/8460581 to your computer and use it in GitHub Desktop.
Save zwned/8460581 to your computer and use it in GitHub Desktop.
multiple ssh keys in ansible
task:
...
- name: Add authorized_key file
authorized_key: user={{item.username}} key='{{ "\n".join(item.authkey) | string }}'
with_items: users
...
vars:
users:
- bob:
username: bob
group: group
groups: sudo
comment: bob-the-builder
authkey: ['ssh-rsa AAAA... comment','ssh-rsa AAAA... comment']
- jane:
username: jane
group: group
groups: sudo
comment: jane-doe
authkey: ['ssh-rsa AAAA... comment']
- john:
username: john
group: group
groups: sudo
comment: john-doe
authkey: ['ssh-rsa AAAA...']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment