salt: State user.present will fail to create home if user exists and homedir doesn't
Ran into this today, it appears that in one of our installs, the user got created at some point, but their home dir didn’t. When I ran the highstate today, it errored out with the following: local:
ID: xxxxxxx
Function: user.present
Result: False
Comment: These values could not be changed: {'homeDoesNotExist': '/home/xxxxxxx'}
Started: 11:30:43.057275
Duration: 6.189 ms
Changes:
It looks like here the change doesn’t get made, but reports it back as a change that is remaining.
https://github.com/saltstack/salt/blob/2014.7/salt/states/user.py#L110
Should the user.add module be called to create the home dir or should user.chhome be modified to create a homedir if one doesn’t exist.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 34 (21 by maintainers)
Commits related to this issue
- fix #18843: usermod will not create a dir if old home does not exist usermod only MOVE old home to new path. So create home dir by salt. — committed to hvnsweeting/salt by deleted user 9 years ago
- fix #18843: usermod will not create a dir if old home does not exist usermod only MOVE old home to new path. So create home dir by salt. — committed to hvnsweeting/salt by deleted user 9 years ago
- fix #18843: usermod won't create a dir if old home does not exist usermod only MOVE old home to new path. So create home dir by salt. — committed to hvnsweeting/salt by deleted user 9 years ago
- add test for #18843 — committed to hvnsweeting/salt by deleted user 9 years ago
- add test for #18843 — committed to hvnsweeting/salt by deleted user 9 years ago
- Merge pull request #22933 from hvnsweeting/18843-test add test for #18843 — committed to saltstack/salt by deleted user 9 years ago
- Merge pull request #22887 from hvnsweeting/18843-fix-user-present-home fix #18843 — committed to saltstack/salt by thatch45 9 years ago
I’ve run into a similar issue, and in the hopes of helping folks stumbling across this bug report, I’ve documented the steps I took to resolve it.
In brief
Try manually changing the user home directory with
usermod
and see if any errors are given.To avoid this confusion, Salt could be more informative on why the values could not be changed.
Problem
Troubleshooting
I found out the root cause by trying to manually run the command:
Solution
In this case, I needed to make sure the service was stopped (and the user not in use) before changing the home directory:
This resulted in success!
Excerpt of Salt call output
If this does not fix your issue, try manually changing the home directory with
usermod
. There may be something else going on.Reviewed in Tuesday Triage, we do not believe this is a current issue, closing. If anyone on this issue does experience it or someone else, please open a new issue with details from the issue template. Thank you!
@digitalcircuit, that looks like the beginning of a fix, but I wonder if further corners are hiding as well. I agree that more articulate reporting that reaches closer to root causes comprises a major portion of the solution.
I am still having the same issue of changing an existing user’s home directory with 2017.7.5:
Any idea on a fix?