Forked from anonymous/gist:55f1cff79c72418c8e7172588e1d962b
Last active
July 11, 2017 13:23
-
-
Save lanky/e062dc55c463ea3c68d9a718927124e8 to your computer and use it in GitHub Desktop.
This file contains 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
admins: | |
- name: username1 | |
pass: <redacted> | |
- name: username2 | |
pass: <redacted> | |
home: "elephant" <-- means you'll get HOMEROOT/elephant rather that HOMEROOT/username2 |
This file contains 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
--- | |
home_root: /home |
This file contains 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
--- | |
# homedirs on host THISHOST are somewhere non-standard | |
home_root: /users/homes |
This file contains 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
- hosts: all | |
tasks: | |
- include_vars: "variables/adminusers.yml" | |
- include_vars: "variables/delusers.yml" | |
- name: Remove users | |
user: | |
name: "{{ item.name }}" | |
# uid: "{{ item.uid }}" | |
state: absent | |
remove: yes | |
with_items: "{{ delusers }}" | |
- name: Create admin users | |
user: | |
name: "{{ item.name }}" | |
password: "{{ item.pass }}" | |
uid: "{{ item.uid }}" | |
group: users | |
shell: "{{ item.shell }}" | |
state: present | |
groups: sudo | |
home: "{{ home_root|default('/home') }}/{{ item.home|default(item.name) }}" | |
createhome: yes | |
with_items: "{{ admins }}" | |
- name: Add SSH keys | |
authorized_key: | |
user: "{{ item.0.name }}" | |
state: present | |
manage_dir: yes | |
key: "{{ item.1 }}" | |
with_subelements: | |
- "{{ admins }}" | |
- authorized_keys | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment