user.py fails on generate_ssh_key under Python3.6 #39472
Labels
affects_2.5
This issue/PR affects Ansible v2.5
bug
This issue/PR relates to a bug.
module
This issue/PR relates to a module.
python3
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
ISSUE TYPE
COMPONENT NAME
user.py
ANSIBLE VERSION
CONFIGURATION
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 100
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /var/log/ansible.log
DEFAULT_SSH_TRANSFER_METHOD(/etc/ansible/ansible.cfg) = scp
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 20
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT
Running from: Ubuntu 16.04.4 LTS
Managing: Ubuntu 18.04 LTS with Python 3.6
SUMMARY
User module fails when using Python3.6 and generate_ssh_key=yes.
STEPS TO REPRODUCE
With an SSH key already generated:
ansible myhost -vvv -m user -a "name=myuser generate_ssh_key=yes" -e ansible_python_interpreter=/usr/bin/python3
EXPECTED RESULTS
With Python2 (using -e ansible_python_interpreter=/usr/bin/python)
ACTUAL RESULTS
With Python3:
If the -b flag is used then it works successfully.
FURTHER TESTING
Looking into this a bit more, the behaviour of spwd.getspnam has changed in Python 3.6. From the docs: Raises a PermissionError instead of KeyError if the user doesn’t have privileges.
Python2 non-root:
Python3 non-root:
The text was updated successfully, but these errors were encountered: