diff --git a/changelogs/fragments/user_missing_etc_shadow.yml b/changelogs/fragments/user_missing_etc_shadow.yml new file mode 100644 index 00000000000..5139e680505 --- /dev/null +++ b/changelogs/fragments/user_missing_etc_shadow.yml @@ -0,0 +1,2 @@ +bugfixes: +- Handle exception when /etc/shadow file is missing or not found, while operating user operation in user module (https://github.com/ansible/ansible/issues/63490). diff --git a/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index 00dec5f8978..255d6e309a7 100644 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -911,7 +911,7 @@ class User(object): # Python 3.6 raises PermissionError instead of KeyError # Due to absence of PermissionError in python2.7 need to check # errno - if e.errno in (errno.EACCES, errno.EPERM): + if e.errno in (errno.EACCES, errno.EPERM, errno.ENOENT): return passwd, expires raise