@ -31,6 +31,7 @@ import string
from ansible . compat . six import iteritems , string_types
from ansible import constants as C
from ansible . errors import AnsibleError
from ansible . module_utils . _text import to_bytes
from ansible . playbook . attribute import FieldAttribute
from ansible . playbook . base import Base
from ansible . utils . boolean import boolean
@ -84,38 +85,38 @@ MAGIC_VARIABLE_MAPPING = dict(
module_compression = ( ' ansible_module_compression ' , ) ,
)
SU_PROMPT_LOCALIZATIONS = [
' Password ' ,
' 암호 ' ,
' パスワード ' ,
' Adgangskode ' ,
' Contraseña ' ,
' Contrasenya ' ,
' Hasło ' ,
' Heslo ' ,
' Jelszó ' ,
' Lösenord ' ,
' Mật khẩu ' ,
' Mot de passe ' ,
' Parola ' ,
' Parool ' ,
' Pasahitza ' ,
' Passord ' ,
' Passwort ' ,
' Salasana ' ,
' Sandi ' ,
' Senha ' ,
' Wachtwoord ' ,
' ססמה ' ,
' Лозинка ' ,
' Парола ' ,
' Пароль ' ,
' गुप्तशब्द ' ,
' शब्दकूट ' ,
' సంకేతపదము ' ,
' හස්පදය ' ,
' 密码 ' ,
' 密碼 ' ,
b_ SU_PROMPT_LOCALIZATIONS = [
to_bytes ( ' Password ' ) ,
to_bytes ( ' 암호 ' ) ,
to_bytes ( ' パスワード ' ) ,
to_bytes ( ' Adgangskode ' ) ,
to_bytes ( ' Contraseña ' ) ,
to_bytes ( ' Contrasenya ' ) ,
to_bytes ( ' Hasło ' ) ,
to_bytes ( ' Heslo ' ) ,
to_bytes ( ' Jelszó ' ) ,
to_bytes ( ' Lösenord ' ) ,
to_bytes ( ' Mật khẩu ' ) ,
to_bytes ( ' Mot de passe ' ) ,
to_bytes ( ' Parola ' ) ,
to_bytes ( ' Parool ' ) ,
to_bytes ( ' Pasahitza ' ) ,
to_bytes ( ' Passord ' ) ,
to_bytes ( ' Passwort ' ) ,
to_bytes ( ' Salasana ' ) ,
to_bytes ( ' Sandi ' ) ,
to_bytes ( ' Senha ' ) ,
to_bytes ( ' Wachtwoord ' ) ,
to_bytes ( ' ססמה ' ) ,
to_bytes ( ' Лозинка ' ) ,
to_bytes ( ' Парола ' ) ,
to_bytes ( ' Пароль ' ) ,
to_bytes ( ' गुप्तशब्द ' ) ,
to_bytes ( ' शब्दकूट ' ) ,
to_bytes ( ' సంకేతపదము ' ) ,
to_bytes ( ' හස්පදය ' ) ,
to_bytes ( ' 密码 ' ) ,
to_bytes ( ' 密碼 ' ) ,
]
TASK_ATTRIBUTE_OVERRIDES = (
@ -508,9 +509,9 @@ class PlayContext(Base):
elif self . become_method == ' su ' :
# passing code ref to examine prompt as simple string comparisson isn't good enough with su
def detect_su_prompt ( data) :
SU_PROMPT_LOCALIZATIONS_RE = re . compile ( " | " . join ( [ ' ( \ w+ \' s )? ' + x + ' ?: ? ' for x in SU_PROMPT_LOCALIZATIONS] ) , flags = re . IGNORECASE )
return bool ( SU_PROMPT_LOCALIZATIONS_RE. match ( data) )
def detect_su_prompt ( b_ data) :
b_ SU_PROMPT_LOCALIZATIONS_RE = re . compile ( b " | " . join ( [ b ' ( \ w+ \' s )? ' + x + b ' ?: ? ' for x in b_ SU_PROMPT_LOCALIZATIONS] ) , flags = re . IGNORECASE )
return bool ( b_ SU_PROMPT_LOCALIZATIONS_RE. match ( b_ data) )
prompt = detect_su_prompt
becomecmd = ' %s %s %s -c %s ' % ( exe , flags , self . become_user , pipes . quote ( command ) )
@ -521,8 +522,8 @@ class PlayContext(Base):
becomecmd = ' %s -b %s -u %s %s ' % ( exe , flags , self . become_user , success_cmd )
elif self . become_method == ' ksu ' :
def detect_ksu_prompt ( data) :
return re . match ( " Kerberos password for .*@.*: " , data)
def detect_ksu_prompt ( b_ data) :
return re . match ( b " Kerberos password for .*@.*: " , b_ data)
prompt = detect_ksu_prompt
becomecmd = ' %s %s %s -e %s ' % ( exe , self . become_user , flags , command )