mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix user module under python3 (#4560)
Using something like:
- name: Create ssh keys
user:
name: root
generate_ssh_key: yes
register: key
result into this traceback on F24
Traceback (most recent call last):
File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 2170, in <module>
main()
File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 2108, in main
(rc, out, err) = user.modify_user()
File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 660, in modify_user
return self.modify_user_usermod()
File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 417, in modify_user_usermod
has_append = self._check_usermod_append()
File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 405, in _check_usermod_append
lines = helpout.split('\\n')
TypeError: a bytes-like object is required, not 'str'
This commit is contained in:
committed by
Matt Clay
parent
898cf5b462
commit
f2b6c7b6a2
@@ -220,6 +220,7 @@ import grp
|
||||
import platform
|
||||
import socket
|
||||
import time
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
import spwd
|
||||
@@ -401,7 +402,7 @@ class User(object):
|
||||
helpout = data1 + data2
|
||||
|
||||
# check if --append exists
|
||||
lines = helpout.split('\n')
|
||||
lines = to_native(helpout).split('\n')
|
||||
for line in lines:
|
||||
if line.strip().startswith('-a, --append'):
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user