File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ The following attributes are required for each user:
26
26
27
27
* username - The user's username.
28
28
* name - The full name of the user (gecos field)
29
+ * home - the home directory of the user to create (optional, defaults to /home/username)
29
30
* uid - The numeric user id for the user. This is required for uid consistency
30
31
across systems.
31
32
* gid - The numeric group id for the group (optional). Otherwise, the
@@ -51,6 +52,7 @@ Example:
51
52
name: Foo Barrington
52
53
groups: ['wheel','systemd-journal']
53
54
uid: 1001
55
+ home: /local/home/foo
54
56
profile: |
55
57
alias ll='ls -lah'
56
58
ssh_key:
Original file line number Diff line number Diff line change 21
21
password : " {{item.password if item.password is defined else '!'}}"
22
22
comment : " {{item.name if item.name is defined else ''}}"
23
23
uid : " {{item.uid}}"
24
+ home : " {{ item.home | default('/home/' + item.username) }}"
24
25
createhome : " {{'yes' if users_create_homedirs else 'no'}}"
25
26
with_items : " {{users}}"
26
27
tags : ['users','configuration']
29
30
authorized_key :
30
31
user : " {{item.0.username}}"
31
32
key : " {{item.1}}"
32
- path : " /home/{{ item.0.username}}/.ssh/authorized_keys"
33
+ path : " {{ item.0.home | default(' /home/' + item.0.username) }}/.ssh/authorized_keys"
33
34
with_subelements :
34
35
- " {{users}}"
35
36
- ssh_key
38
39
- name : Setup user profiles
39
40
blockinfile :
40
41
block : " {{item.profile}}"
41
- dest : " /home/{{ item.username}}/.profile"
42
+ dest : " {{ item.home | default(' /home/' + item.username) }}/.profile"
42
43
owner : " {{item.username}}"
43
44
group : " {{item.username}}"
44
45
mode : 0644
Original file line number Diff line number Diff line change 17
17
18
18
roles :
19
19
- ansible-users
20
+
21
+ - hosts : localhost
22
+ remote_user : root
23
+ vars :
24
+ users :
25
+ - name : Ansible Test User2
26
+ username : ansibletestuser2
27
+ uid : 2222
28
+ groups : [users, bin]
29
+ shell : /bin/sh
30
+ home : /home/otherdirectory
31
+ profile : |
32
+ alias ll='ls -lah'
33
+ alias cp='cp -iv'
34
+ ssh_key :
35
+ -
" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd [email protected] "
36
+
37
+ roles :
38
+ - ansible-users
You can’t perform that action at this time.
0 commit comments