Skip to content

Instantly share code, notes, and snippets.

@wu-lee
Created February 26, 2013 10:12
Show Gist options
  • Save wu-lee/5037444 to your computer and use it in GitHub Desktop.
Save wu-lee/5037444 to your computer and use it in GitHub Desktop.
--- # create_userA.yml tasks:
- name: Create the "${user}" user
action: user
state=present
name="${user}"
createhome=yes
- name: Insert authorized_keys for user "$user"
action: authorized_key
state=present
user="${user}"
key="${pubkey}"
--- # users.yml
- name: Create users
user: root
hosts: all
vars:
users: # This would be in group_vars
- alice
- bob
userdefs: # This would be a shared list
alice:
pubkey: sdfjwkfuqwerw
# More attributes here....
bob:
pubkey: ajdfhUHFWJWRWE
# More attributes here....
tasks:
- include: create_userA.yml user="${item}" pubkey="${userdefs.${item}.pubkey}"
with_items: ${users}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment