add support for ssh keys
This commit is contained in:
parent
5130e07acc
commit
fbb20fdf1d
3 changed files with 19 additions and 7 deletions
|
|
@ -5,9 +5,9 @@
|
||||||
gid: "{{ omit }}"
|
gid: "{{ omit }}"
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
group: "{{ defaultgroup|combine(item.value|d({}), {'name': item.key} ) }}"
|
group: "{{ defaultgroup|combine(currentgroup.value|d({}), {'name': currentgroup.key} ) }}"
|
||||||
|
|
||||||
- name: create groupss
|
- name: create groups
|
||||||
group:
|
group:
|
||||||
name: "{{ group.name }}"
|
name: "{{ group.name }}"
|
||||||
system: "{{ group.system }}"
|
system: "{{ group.system }}"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
- name: handle groups
|
- name: handle groups
|
||||||
with_dict: "{{ accounts.groups }}"
|
loop: "{{ accounts.groups|dict2items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: currentgroup
|
||||||
include_tasks:
|
include_tasks:
|
||||||
file: groups.yml
|
file: groups.yml
|
||||||
|
|
||||||
- name: handle users
|
- name: handle users
|
||||||
with_dict: "{{ accounts.users }}"
|
loop: "{{ accounts.users|dict2items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: currentuser
|
||||||
include_tasks:
|
include_tasks:
|
||||||
file: users.yml
|
file: users.yml
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,18 @@
|
||||||
genssh: false
|
genssh: false
|
||||||
group: ~
|
group: ~
|
||||||
groups: []
|
groups: []
|
||||||
home: "{{ ('/var/lib/'+item.key) if (item.value.system|d(True)) else ('/home/'+item.key) }}"
|
home: "{{ ('/var/lib/'+currentuser.key) if (currentuser.value.system|d(True)) else ('/home/'+currentuser.key) }}"
|
||||||
system: true
|
system: true
|
||||||
state: present
|
state: present
|
||||||
uid: "{{ omit }}"
|
uid: "{{ omit }}"
|
||||||
password: "*"
|
password: "*"
|
||||||
shell: "/usr/sbin/nologin"
|
shell: "/usr/sbin/nologin"
|
||||||
|
authorized_keys: {}
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
user: "{{ defaultuser|combine(item.value|d({}), {'name': item.key} ) }}"
|
user: "{{ defaultuser|combine(currentuser.value|d({}), {'name': currentuser.key} ) }}"
|
||||||
|
|
||||||
- name: create users
|
- name: "create user ({{ user.name }})"
|
||||||
user:
|
user:
|
||||||
name: "{{ user.name }}"
|
name: "{{ user.name }}"
|
||||||
generate_ssh_key: "{{ user.genssh }}"
|
generate_ssh_key: "{{ user.genssh }}"
|
||||||
|
|
@ -26,3 +27,10 @@
|
||||||
uid: "{{ user.uid|d(omit) }}"
|
uid: "{{ user.uid|d(omit) }}"
|
||||||
password: "{{ user.password }}"
|
password: "{{ user.password }}"
|
||||||
shell: "{{ user.shell }}"
|
shell: "{{ user.shell }}"
|
||||||
|
|
||||||
|
- name: "setup ssh key(s) ({{ user.name }})"
|
||||||
|
loop: "{{ user.authorized_keys|dict2items }}"
|
||||||
|
authorized_key:
|
||||||
|
user: "{{ user.name }}"
|
||||||
|
key: "{{ item.value }}"
|
||||||
|
comment: "{{ item.key }}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue