Skip to content

Commit f0ee28b

Browse files
author
Colin Hoglund
authored
Merge pull request #51 from singleplatform-eng/make_uid_optional
making uid optional
2 parents d80c4e0 + 3779574 commit f0ee28b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following attributes are required for each user:
2727
* username - The user's username.
2828
* name - The full name of the user (gecos field)
2929
* home - the home directory of the user to create (optional, defaults to /home/username)
30-
* uid - The numeric user id for the user. This is required for uid consistency
30+
* uid - The numeric user id for the user (optional). This is required for uid consistency
3131
across systems.
3232
* gid - The numeric group id for the group (optional). Otherwise, the
3333
uid will be used
@@ -39,7 +39,7 @@ The following attributes are required for each user:
3939
* group - optional primary group override
4040
* groups - a list of supplementary groups for the user.
4141
* profile - a string block for setting custom shell profiles
42-
* ssh_key - This should be a list of ssh keys for the user. Each ssh key
42+
* ssh_key - This should be a list of ssh keys for the user (optional). Each ssh key
4343
should be included directly and should have no newlines.
4444
* generate_ssh_key - Whether to generate a SSH key for the user (optional, defaults to no).
4545

tasks/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- name: Per-user group creation
88
group: name="{{item.username}}"
9-
gid="{{item.gid if item.gid is defined else item.uid}}"
9+
gid="{{item.gid | default(item.uid) | default(omit)}}"
1010
with_items: "{{users}}"
1111
when: "'group' not in item and users_create_per_user_group"
1212
tags: ['users','configuration']
@@ -20,7 +20,7 @@
2020
shell: "{{item.shell if item.shell is defined else users_default_shell}}"
2121
password: "{{item.password if item.password is defined else '!'}}"
2222
comment: "{{item.name if item.name is defined else ''}}"
23-
uid: "{{item.uid}}"
23+
uid: "{{item.uid | default(omit)}}"
2424
home: "{{ item.home | default('/home/' + item.username) }}"
2525
createhome: "{{'yes' if users_create_homedirs else 'no'}}"
2626
generate_ssh_key: "{{ item.generate_ssh_key | default(omit) }}"
@@ -36,6 +36,7 @@
3636
with_subelements:
3737
- "{{users}}"
3838
- ssh_key
39+
- skip_missing: yes
3940
tags: ['users','configuration']
4041

4142
- name: Setup user profiles

0 commit comments

Comments
 (0)