|
|
|
@ -33,7 +33,7 @@ from ansible.module_utils.six import iteritems, string_types
|
|
|
|
|
from ansible.module_utils.common._collections_compat import Mapping
|
|
|
|
|
from ansible.errors import AnsibleError, AnsibleFilterError
|
|
|
|
|
from ansible.utils.display import Display
|
|
|
|
|
from ansible.utils.encrypt import random_password
|
|
|
|
|
from ansible.utils.encrypt import passlib_or_crypt, random_password
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
import yaml
|
|
|
|
@ -47,12 +47,6 @@ try:
|
|
|
|
|
except ImportError:
|
|
|
|
|
HAS_TEXTFSM = False
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from passlib.hash import md5_crypt
|
|
|
|
|
HAS_PASSLIB = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
HAS_PASSLIB = False
|
|
|
|
|
|
|
|
|
|
display = Display()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -357,9 +351,6 @@ def parse_xml(output, tmpl):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def type5_pw(password, salt=None):
|
|
|
|
|
if not HAS_PASSLIB:
|
|
|
|
|
raise AnsibleFilterError('type5_pw filter requires PassLib library to be installed')
|
|
|
|
|
|
|
|
|
|
if not isinstance(password, string_types):
|
|
|
|
|
raise AnsibleFilterError("type5_pw password input should be a string, but was given a input of %s" % (type(password).__name__))
|
|
|
|
|
|
|
|
|
@ -375,7 +366,7 @@ def type5_pw(password, salt=None):
|
|
|
|
|
elif not set(salt) <= set(salt_chars):
|
|
|
|
|
raise AnsibleFilterError("type5_pw salt used inproper characters, must be one of %s" % (salt_chars))
|
|
|
|
|
|
|
|
|
|
encrypted_password = md5_crypt.encrypt(password, salt=salt)
|
|
|
|
|
encrypted_password = passlib_or_crypt(password, "md5_crypt", salt=salt)
|
|
|
|
|
|
|
|
|
|
return encrypted_password
|
|
|
|
|
|
|
|
|
|