Skip to content

Commit

Permalink
feat: add users_user_create and user.user_create option
Browse files Browse the repository at this point in the history
closes: #46
resolves: #47
resolves: #48
  • Loading branch information
franklinkim committed Nov 5, 2020
1 parent 038d8c0 commit daa876e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
# id_rsa_2: "xxx" or "{{ lookup('file', '/path/to/id_rsa') }}"
# shell: /bin/bash
# update_password: always
# user_create: yes
#
# users_remove:
# - foobar
# - { username: foobar, remove: no }

# list of users to add
users: []
# create the users
users_user_create: yes
# default user's dotfiles
users_home_files: []
# users home directory
Expand Down
1 change: 0 additions & 1 deletion tasks/manage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
- name: Configure users
include_tasks: manage_user.yml
with_items: "{{ users }}"
when: user.username != 'root'
loop_control:
loop_var: user

Expand Down
1 change: 1 addition & 0 deletions tasks/manage_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
createhome: "{{ user.home_create | default(users_home_create) }}"
shell: "{{ user.shell | default(users_shell | default(omit)) }}"
update_password: "{{ user.update_password | default(omit) }}"
when: user.user_create | default(users_user_create)

- name: Configuring user's home
import_tasks: manage_user_home.yml
Expand Down
5 changes: 5 additions & 0 deletions tests/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
vars:
users:
- username: root
home: /root
group: root
authorized_keys:
- "{{ lookup('file', 'tests/id_rsa.pub') }}"
user_create: no
- username: foobar
name: Foo Bar 1
- username: foobar_authorized_keys
Expand Down

0 comments on commit daa876e

Please sign in to comment.