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
0a52913d
Commit
0a52913d
authored
Dec 03, 2014
by
Toshio Kuratomi
Committed by
James Cammarata
Dec 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have remote_expanduser honor sudo and su users.
Fixes #9663
parent
13932726
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
1 deletions
+57
-1
lib/ansible/runner/__init__.py
+9
-1
test/integration/destructive.yml
+2
-0
test/integration/roles/test_sudo/tasks/main.yml
+44
-0
test/integration/roles/test_sudo/templates/bar.j2
+1
-0
test/integration/roles/test_sudo/vars/default.yml
+1
-0
No files found.
lib/ansible/runner/__init__.py
View file @
0a52913d
...
...
@@ -1196,8 +1196,16 @@ class Runner(object):
''' takes a remote path and performs tilde expansion on the remote host '''
if
not
path
.
startswith
(
'~'
):
return
path
split_path
=
path
.
split
(
os
.
path
.
sep
,
1
)
cmd
=
conn
.
shell
.
expand_user
(
split_path
[
0
])
expand_path
=
split_path
[
0
]
if
expand_path
==
'~'
:
if
self
.
sudo
and
self
.
sudo_user
:
expand_path
=
'~
%
s'
%
self
.
sudo_user
elif
self
.
su
and
self
.
su_user
:
expand_path
=
'~
%
s'
%
self
.
su_user
cmd
=
conn
.
shell
.
expand_user
(
expand_path
)
data
=
self
.
_low_level_exec_command
(
conn
,
cmd
,
tmp
,
sudoable
=
False
,
su
=
False
)
initial_fragment
=
utils
.
last_non_blank_line
(
data
[
'stdout'
])
...
...
test/integration/destructive.yml
View file @
0a52913d
-
hosts
:
testhost
gather_facts
:
True
roles
:
# In destructive because it creates and removes a user
-
{
role
:
test_sudo
,
tags
:
test_sudo
}
-
{
role
:
test_service
,
tags
:
test_service
}
# Current pip unconditionally uses md5. We can re-enable if pip switches
# to a different hash or allows us to not check md5
...
...
test/integration/roles/test_sudo/tasks/main.yml
0 → 100644
View file @
0a52913d
-
include_vars
:
default.yml
-
name
:
Create test user
user
:
name
:
"
{{
sudo_test_user
}}"
-
name
:
tilde expansion honors sudo in file
sudo
:
True
sudo_user
:
"
{{
sudo_test_user
}}"
file
:
path
:
"
~/foo.txt"
state
:
touch
-
name
:
check that the path in the user's home dir was created
stat
:
path
:
"
~{{
sudo_test_user
}}/foo.txt"
register
:
results
-
assert
:
that
:
-
"
results.stat.exists
==
True"
-
name
:
tilde expansion honors sudo in template
sudo
:
True
sudo_user
:
"
{{
sudo_test_user
}}"
template
:
src
:
"
bar.j2"
dest
:
"
~/bar.txt"
-
name
:
check that the path in the user's home dir was created
stat
:
path
:
"
~{{
sudo_test_user
}}/bar.txt"
register
:
results
-
assert
:
that
:
-
"
results.stat.exists
==
True"
-
name
:
Remove test user and their home dir
user
:
name
:
"
{{
sudo_test_user
}}"
state
:
"
absent"
remove
:
"
yes"
test/integration/roles/test_sudo/templates/bar.j2
0 → 100644
View file @
0a52913d
{{ sudo_test_user }}
test/integration/roles/test_sudo/vars/default.yml
0 → 100644
View file @
0a52913d
sudo_test_user
:
ansibletest1
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