Properly handle runas on pip module. Refs #1959 and #1891.

This commit is contained in:
Pedro Algarvio 2012-09-30 13:40:02 +01:00
parent b93d2ca008
commit 4565d64cc6

View File

@ -182,6 +182,13 @@ def install(pkgs=None,
cmd = '{cmd} --requirement "{requirements}" '.format(
cmd=cmd, requirements=treq or requirements)
if treq is not None and runas:
log.debug(
'Changing ownership of requirements file \'{0}\' to '
'user \'{1}\''.format(treq, runas)
)
__salt__['file.chown'](treq, runas, None)
if log:
try:
# TODO make this check if writeable
@ -282,13 +289,14 @@ def install(pkgs=None,
cmd = '{cmd} --install-options={install_options} '.format(
cmd=cmd, install_options=install_options)
result = __salt__['cmd.run_all'](cmd, runas=runas, cwd=cwd)
if treq:
try:
os.remove(treq)
except Exception:
pass
try:
result = __salt__['cmd.run_all'](cmd, runas=runas, cwd=cwd)
finally:
if treq:
try:
os.remove(treq)
except Exception:
pass
return result