From 37795741d3c41642aa23abbadeee6c491274e6e3 Mon Sep 17 00:00:00 2001 From: Colin Hoglund Date: Mon, 12 Jun 2017 13:37:58 -0400 Subject: [PATCH] making uid optional --- README.md | 4 ++-- tasks/main.yml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d286746..31a41f2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The following attributes are required for each user: * username - The user's username. * name - The full name of the user (gecos field) * home - the home directory of the user to create (optional, defaults to /home/username) -* uid - The numeric user id for the user. This is required for uid consistency +* uid - The numeric user id for the user (optional). This is required for uid consistency across systems. * gid - The numeric group id for the group (optional). Otherwise, the uid will be used @@ -39,7 +39,7 @@ The following attributes are required for each user: * group - optional primary group override * groups - a list of supplementary groups for the user. * profile - a string block for setting custom shell profiles -* ssh_key - This should be a list of ssh keys for the user. Each ssh key +* ssh_key - This should be a list of ssh keys for the user (optional). Each ssh key should be included directly and should have no newlines. * generate_ssh_key - Whether to generate a SSH key for the user (optional, defaults to no). diff --git a/tasks/main.yml b/tasks/main.yml index 738105d..c0348a2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ - name: Per-user group creation group: name="{{item.username}}" - gid="{{item.gid if item.gid is defined else item.uid}}" + gid="{{item.gid | default(item.uid) | default(omit)}}" with_items: "{{users}}" when: "'group' not in item and users_create_per_user_group" tags: ['users','configuration'] @@ -20,7 +20,7 @@ shell: "{{item.shell if item.shell is defined else users_default_shell}}" password: "{{item.password if item.password is defined else '!'}}" comment: "{{item.name if item.name is defined else ''}}" - uid: "{{item.uid}}" + uid: "{{item.uid | default(omit)}}" home: "{{ item.home | default('/home/' + item.username) }}" createhome: "{{'yes' if users_create_homedirs else 'no'}}" generate_ssh_key: "{{ item.generate_ssh_key | default(omit) }}" @@ -36,6 +36,7 @@ with_subelements: - "{{users}}" - ssh_key + - skip_missing: yes tags: ['users','configuration'] - name: Setup user profiles