- name:Try to remove user 'janet' that doesn't exist
community.general.homectl:
name:janet
state:absent
register:user_not_exist
ignore_errors:yes
- name:Use check_mode to try and create user 'diana'
community.general.homectl:
name:diana
password:helloworld123!@
state:present
check_mode:yes
register:diana_create_checkmode_out
- name:Verify user 'diana' was not created with check_mode
command:homectl inspect diana
register:user_diana_exists
ignore_errors:yes
- name:Try to modify user 'jake' with only noexec mount option in check_mode
community.general.homectl:
name:jake
password:myreallysecurepassword12!
state:present
mountopts:noexec
check_mode:yes
register:jake_checkmode_out
- name:Verify user 'jake' was not modified and still has all mount options
command:homectl inspect jake
register:user_jake_details_out
- name:Modify user 'jake' with only noexec mount option
community.general.homectl:
name:jake
password:myreallysecurepassword12!
state:present
mountopts:noexec
register:jake_modify_out
- name:modify user 'jake' again with only noexec mount option to make sure changed is false as nothing has changed.
community.general.homectl:
name:jake
password:myreallysecurepassword12!
state:present
mountopts:noexec
register:jake_modify_again_out
- name:Try to modify user 'jake' with an incorrect password
community.general.homectl:
name:jake
password:incorrectPassword!
state:present
mountopts:noexec
locked:yes
ignore_errors:yes
register:jake_incorrect_pass_out
- assert:
that:
- james_info.rc == 0
- tom_userinfo.data['gid'] == 1000 and tom_userinfo.data['uid'] == 1000
- user_exists is changed and user_exists.data['shell'] == '/bin/ksh'
- resize_out is not changed
- disk_out is changed
- delete_foobar_out is changed
- danielle_out is not changed
- lukuser_modify_out.data['timeZone'] == "America/New_York" and lukuser_modify_out.data['shell'] == "/bin/zsh"
- user_not_exist is not changed and user_not_exist.msg == "User does not exist!"
- jake_out is changed and jake_out.data['mountNoDevices'] == True and jake_out.data['mountNoSuid'] == True and jake_out.data['mountNoExecute'] == True
- diana_create_checkmode_out is changed and 'No home for user diana known' in user_diana_exists.stderr
- "jake_checkmode_out is changed and 'Mount Flags: nosuid nodev noexec' in user_jake_details_out.stdout"
- jake_modify_out is changed and jake_modify_out.data['privileged']['sshAuthorizedKeys'] is not none
- jake_modify_out.data['mountNoDevices'] == False and jake_modify_out.data['mountNoExecute'] == True and jake_modify_out.data['mountNoSuid'] == False
- jake_modify_again_out is not changed
- jake_incorrect_pass_out is not changed and jake_incorrect_pass_out is failed and jake_incorrect_pass_out.msg == 'User exists but password is incorrect!'
# homectl was first introduced in systemd 245 so check version >= 245 and make sure system has systemd and homectl command