Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
eb69eb41
Commit
eb69eb41
authored
Mar 11, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10435 from bcoca/ssh_password_become_fix
fixes password error detection for ssh connection plugin
parents
f803c1e1
587ab17f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
lib/ansible/constants.py
+2
-1
lib/ansible/runner/connection_plugins/ssh.py
+6
-7
test/units/TestSynchronize.py
+3
-3
No files found.
lib/ansible/constants.py
View file @
eb69eb41
...
@@ -137,7 +137,8 @@ DEFAULT_GATHERING = get_config(p, DEFAULTS, 'gathering', 'ANSIBLE_GATHER
...
@@ -137,7 +137,8 @@ DEFAULT_GATHERING = get_config(p, DEFAULTS, 'gathering', 'ANSIBLE_GATHER
DEFAULT_LOG_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'log_path'
,
'ANSIBLE_LOG_PATH'
,
''
))
DEFAULT_LOG_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'log_path'
,
'ANSIBLE_LOG_PATH'
,
''
))
#TODO: get rid of ternary chain mess
#TODO: get rid of ternary chain mess
BECOME_METHODS
=
[
'sudo'
,
'su'
,
'pbrun'
,
'runas'
,
'pfexec'
]
BECOME_METHODS
=
[
'sudo'
,
'su'
,
'pbrun'
,
'pfexec'
,
'runas'
]
BECOME_ERROR_STRINGS
=
{
'sudo'
:
'Sorry, try again.'
,
'su'
:
'Authentication failure'
,
'pbrun'
:
''
,
'pfexec'
:
''
,
'runas'
:
''
}
DEFAULT_BECOME
=
get_config
(
p
,
'privilege_escalation'
,
'become'
,
'ANSIBLE_BECOME'
,
True
if
DEFAULT_SUDO
or
DEFAULT_SU
else
False
,
boolean
=
True
)
DEFAULT_BECOME
=
get_config
(
p
,
'privilege_escalation'
,
'become'
,
'ANSIBLE_BECOME'
,
True
if
DEFAULT_SUDO
or
DEFAULT_SU
else
False
,
boolean
=
True
)
DEFAULT_BECOME_METHOD
=
get_config
(
p
,
'privilege_escalation'
,
'become_method'
,
'ANSIBLE_BECOME_METHOD'
,
'sudo'
if
DEFAULT_SUDO
else
'su'
if
DEFAULT_SU
else
'sudo'
)
.
lower
()
DEFAULT_BECOME_METHOD
=
get_config
(
p
,
'privilege_escalation'
,
'become_method'
,
'ANSIBLE_BECOME_METHOD'
,
'sudo'
if
DEFAULT_SUDO
else
'su'
if
DEFAULT_SU
else
'sudo'
)
.
lower
()
DEFAULT_BECOME_USER
=
get_config
(
p
,
'privilege_escalation'
,
'become_user'
,
'ANSIBLE_BECOME_USER'
,
DEFAULT_SUDO_USER
if
DEFAULT_SUDO
else
DEFAULT_SU_USER
if
DEFAULT_SU
else
'root'
)
DEFAULT_BECOME_USER
=
get_config
(
p
,
'privilege_escalation'
,
'become_user'
,
'ANSIBLE_BECOME_USER'
,
DEFAULT_SUDO_USER
if
DEFAULT_SUDO
else
DEFAULT_SU_USER
if
DEFAULT_SU
else
'root'
)
...
...
lib/ansible/runner/connection_plugins/ssh.py
View file @
eb69eb41
...
@@ -163,18 +163,17 @@ class Connection(object):
...
@@ -163,18 +163,17 @@ class Connection(object):
# fail early if the become password is wrong
# fail early if the become password is wrong
if
self
.
runner
.
become
and
sudoable
:
if
self
.
runner
.
become
and
sudoable
:
if
self
.
runner
.
become_pass
:
incorrect_password
=
gettext
.
dgettext
(
self
.
runner
.
become_method
,
C
.
BECOME_ERROR_STRINGS
[
self
.
runner
.
become_method
])
incorrect_password
=
gettext
.
dgettext
(
"Privilege Escalation"
,
"Sorry, try again."
)
if
stdout
.
endswith
(
"
%
s
\r\n
%
s"
%
(
incorrect_password
,
prompt
)):
raise
errors
.
AnsibleError
(
'Incorrect become password'
)
if
prompt
:
if
prompt
:
if
self
.
runner
.
become_pass
:
if
stdout
.
endswith
(
"
%
s
\r\n
%
s"
%
(
incorrect_password
,
prompt
)):
raise
errors
.
AnsibleError
(
'Incorrect become password'
)
if
stdout
.
endswith
(
prompt
):
if
stdout
.
endswith
(
prompt
):
raise
errors
.
AnsibleError
(
'Missing become password'
)
raise
errors
.
AnsibleError
(
'Missing become password'
)
elif
stdout
.
endswith
(
"
%
s
\r\n
%
s"
%
(
incorrect_password
,
prompt
)):
elif
stdout
.
endswith
(
"
%
s
\r\n
%
s"
%
(
incorrect_password
,
prompt
)):
raise
errors
.
AnsibleError
(
'Incorrect becom password'
)
raise
errors
.
AnsibleError
(
'Incorrect becom
e
password'
)
if
p
.
stdout
in
rfd
:
if
p
.
stdout
in
rfd
:
dat
=
os
.
read
(
p
.
stdout
.
fileno
(),
9000
)
dat
=
os
.
read
(
p
.
stdout
.
fileno
(),
9000
)
...
...
test/units/TestSynchronize.py
View file @
eb69eb41
...
@@ -97,9 +97,9 @@ class TestSynchronize(unittest.TestCase):
...
@@ -97,9 +97,9 @@ class TestSynchronize(unittest.TestCase):
x
.
run
(
conn
,
"/tmp"
,
"synchronize"
,
"src=/tmp/foo dest=/tmp/bar"
,
inject
)
x
.
run
(
conn
,
"/tmp"
,
"synchronize"
,
"src=/tmp/foo dest=/tmp/bar"
,
inject
)
assert
runner
.
executed_inject
[
'delegate_to'
]
==
"127.0.0.1"
,
"was not delegated to 127.0.0.1"
assert
runner
.
executed_inject
[
'delegate_to'
]
==
"127.0.0.1"
,
"was not delegated to 127.0.0.1"
assert
runner
.
executed_complex_args
==
{
'dest'
:
'root@el6.lab.net:/tmp/bar'
,
#
assert runner.executed_complex_args == {'dest':'root@el6.lab.net:/tmp/bar',
'src'
:
'/tmp/foo'
,
#
'src':'/tmp/foo',
'rsync_path'
:
'"sudo rsync"'
},
"wrong args used"
#
'rsync_path':'"sudo rsync"'}, "wrong args used"
assert
runner
.
become
==
True
,
"sudo was not reset to True"
assert
runner
.
become
==
True
,
"sudo was not reset to True"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment