Module user : Unable to manage local system user when it exists in LDAP, even if option "local" is set to "yes" #38206
Labels
affects_2.4
This issue/PR affects Ansible v2.4
bug
This issue/PR relates to a bug.
module
This issue/PR relates to a module.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
system
System category
ISSUE TYPE
COMPONENT NAME
module: user
ANSIBLE VERSION
CONFIGURATION
ANSIBLE_SSH_CONTROL_PATH(/etc/ansible/ansible.cfg) = %(directory)s/%%h-%%r
DEFAULT_CALLBACK_PLUGIN_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/ansible/plugins/callback', u'/local/ansible/data/plugins/callback']
DEFAULT_CALLBACK_WHITELIST(/etc/ansible/ansible.cfg) = ['timer', 'profile_tasks', 'my_log_plays']
DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = explicit
DEFAULT_KEEP_REMOTE_FILES(env: ANSIBLE_KEEP_REMOTE_FILES) = True
DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = #! ANSIBLE MANAGED: {file} modified by {uid} on {host} !#
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_modules', u'/local/ansible/data/plugins/custom_modules']
DEFAULT_REMOTE_TMP(/etc/ansible/ansible.cfg) = /tmp/.ansible-${USER}/tmp
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
RETRY_FILES_SAVE_PATH(/etc/ansible/ansible.cfg) = /tmp/.ansible-e821580-retry
OS / ENVIRONMENT
Ansible server : RHEL 7.4
Managed servers: RHEL 6.x and 7.x
SUMMARY
Unable to manage (add/remove) a local system user when it exists in LDAP, even if option "local" is set to "yes"
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
After a quick look in the user module file, I found that the Python function responsible of checking for user existence uses pwd.getpwnam(). But this Python function does not distinguish between local and LDAP users. Then I wrote a little patch to make this function looking for the user to create/remove in /etc/passwd if "local" argument is set to "yes". The attached ZIP file contains the modified module and a diff patch file.
ansible_user_patch.zip
The text was updated successfully, but these errors were encountered: