Skip to content

Instantly share code, notes, and snippets.

@dbnicholson
Created May 29, 2018 18:08
Show Gist options
  • Save dbnicholson/7097a9ef3c12139d4163d958f747afa5 to your computer and use it in GitHub Desktop.
Save dbnicholson/7097a9ef3c12139d4163d958f747afa5 to your computer and use it in GitHub Desktop.
diff --git a/ansible/tasks/create_user_account.yaml b/ansible/tasks/create_user_account.yaml
index f62350f6..53b5a4fa 100644
--- a/ansible/tasks/create_user_account.yaml
+++ b/ansible/tasks/create_user_account.yaml
@@ -3,7 +3,9 @@
#
# vars:
# user: User to be created
+# user_id: [optional] User ID for new user
# group: [optional] Group that the user belongs to
+# group_id: [optional] Group ID for new group
# extra_groups: [optional] Additional groups that the user belongs to
# append_groups: [optional] If yes, will only add groups, not set them
# to just the list in groups
@@ -17,10 +19,13 @@
# sudoers_file: [optional] Name for the installed sudoers_template
- name: "Creating group (if missing) - {{ group | default(user) }}"
- group: name={{ group | default(user) }} state=present
+ group: name={{ group | default(user) }}
+ gid={{ group_id | default(omit) }}
+ state=present
- name: "Setting up account (if missing) - {{ user }}@{{ group | default(user) }}"
user: name={{ user }}
+ uid={{ user_id | default(omit) }}
generate_ssh_key=yes
ssh_key_bits=4096
createhome=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment