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
1b5d039b
Commit
1b5d039b
authored
Jan 08, 2013
by
Daniel Hokka Zakrisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend executable= support in raw to include no execuable
Useful for managing not-UNIX things.
parent
4955587d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
16 deletions
+25
-16
lib/ansible/runner/__init__.py
+1
-1
lib/ansible/runner/action_plugins/raw.py
+4
-9
lib/ansible/runner/connection_plugins/paramiko_ssh.py
+10
-3
lib/ansible/runner/connection_plugins/ssh.py
+10
-3
No files found.
lib/ansible/runner/__init__.py
View file @
1b5d039b
...
...
@@ -441,7 +441,7 @@ class Runner(object):
def
_low_level_exec_command
(
self
,
conn
,
cmd
,
tmp
,
sudoable
=
False
,
executable
=
None
):
''' execute a command string over SSH, return the output '''
if
not
executabl
e
:
if
executable
is
Non
e
:
executable
=
'/bin/sh'
sudo_user
=
self
.
sudo_user
...
...
lib/ansible/runner/action_plugins/raw.py
View file @
1b5d039b
...
...
@@ -15,16 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import
os
import
pwd
import
random
import
traceback
import
tempfile
import
shlex
import
ansible.constants
as
C
from
ansible
import
utils
from
ansible
import
errors
from
ansible
import
module_common
from
ansible.runner.return_data
import
ReturnData
class
ActionModule
(
object
):
...
...
@@ -36,12 +31,12 @@ class ActionModule(object):
def
run
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
):
executable
=
None
args
=
[]
for
arg
in
module_args
.
split
(
' '
):
for
arg
in
shlex
.
split
(
module_args
.
encode
(
"utf-8"
)
):
if
arg
.
startswith
(
'executable='
):
executable
=
'='
.
join
(
arg
.
split
(
'='
)[
1
:])
executable
=
arg
.
split
(
'='
,
1
)[
1
]
else
:
args
.
append
(
arg
)
module_args
=
' '
.
join
(
args
)
.
encode
(
'utf-8'
)
module_args
=
' '
.
join
(
args
)
return
ReturnData
(
conn
=
conn
,
result
=
self
.
runner
.
_low_level_exec_command
(
conn
,
module_args
,
tmp
,
sudoable
=
True
,
executable
=
executable
)
...
...
lib/ansible/runner/connection_plugins/paramiko_ssh.py
View file @
1b5d039b
...
...
@@ -110,7 +110,10 @@ class Connection(object):
chan
.
get_pty
()
if
not
self
.
runner
.
sudo
or
not
sudoable
:
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
if
executable
:
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
else
:
quoted_command
=
cmd
vvv
(
"EXEC
%
s"
%
quoted_command
,
host
=
self
.
host
)
chan
.
exec_command
(
quoted_command
)
else
:
...
...
@@ -123,8 +126,12 @@ class Connection(object):
# the -p option.
randbits
=
''
.
join
(
chr
(
random
.
randint
(
ord
(
'a'
),
ord
(
'z'
)))
for
x
in
xrange
(
32
))
prompt
=
'[sudo via ansible, key=
%
s] password: '
%
randbits
sudocmd
=
'sudo -k && sudo -p "
%
s" -u
%
s
%
s -c
%
s'
%
(
prompt
,
sudo_user
,
executable
,
pipes
.
quote
(
cmd
))
sudocmd
=
'sudo -k && sudo -p "
%
s" -u
%
s '
%
(
prompt
,
sudo_user
)
if
executable
:
sudocmd
+=
"
%
s -c
%
s"
%
(
executable
,
pipes
.
quote
(
cmd
))
else
:
sudocmd
+=
cmd
shcmd
=
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
)
vvv
(
"EXEC
%
s"
%
shcmd
,
host
=
self
.
host
)
sudo_output
=
''
...
...
lib/ansible/runner/connection_plugins/ssh.py
View file @
1b5d039b
...
...
@@ -88,7 +88,10 @@ class Connection(object):
ssh_cmd
+=
[
"ssh"
,
"-tt"
,
"-q"
]
+
self
.
common_args
+
[
self
.
host
]
if
not
self
.
runner
.
sudo
or
not
sudoable
:
ssh_cmd
.
append
(
executable
+
' -c '
+
pipes
.
quote
(
cmd
))
if
executable
:
ssh_cmd
.
append
(
executable
+
' -c '
+
pipes
.
quote
(
cmd
))
else
:
ssh_cmd
.
append
(
cmd
)
else
:
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required.
...
...
@@ -99,8 +102,12 @@ class Connection(object):
# the -p option.
randbits
=
''
.
join
(
chr
(
random
.
randint
(
ord
(
'a'
),
ord
(
'z'
)))
for
x
in
xrange
(
32
))
prompt
=
'[sudo via ansible, key=
%
s] password: '
%
randbits
sudocmd
=
'sudo -k && sudo -p "
%
s" -u
%
s
%
s -c
%
s'
%
(
prompt
,
sudo_user
,
executable
,
pipes
.
quote
(
cmd
))
sudocmd
=
'sudo -k && sudo -p "
%
s" -u
%
s '
%
(
prompt
,
sudo_user
)
if
executable
:
sudocmd
+=
"
%
s -c
%
s"
%
(
executable
,
pipes
.
quote
(
cmd
))
else
:
sudocmd
+=
cmd
ssh_cmd
.
append
(
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
))
vvv
(
"EXEC
%
s"
%
ssh_cmd
,
host
=
self
.
host
)
...
...
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