Created
July 11, 2017 12:49
-
-
Save anonymous/55f1cff79c72418c8e7172588e1d962b 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
- 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: "{{ item.home }}" | |
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
so I would....
host_vars
andgroup_vars
dirs in the same location as your playbookgroup_vars/all
I'd havehome_root: /home
host_vars/SOMEHOST
I'd havehome_root: /someotherhome
and then in your variables files, wherever it says
home:
admins:
- name: username
home: "{{ home_root|default('/home') }}/username
...