fabric/fabric — Issue #523: upload_template with use_sudo flag error
Author: vectorfrog
Created: 2012-01-06 00:32:18+00:00
State: open

I'm getting the following error when I try to use the upload_template command with the use_sudo flag set to True:

Fatal error: sudo() encountered an error (return code 1) while executing 'mv "158bea5b91b5ba5cc13a2238016bd28dcdb6eb01" "/etc/uwsgi/vassals/2345.ini"'

When I run the upload_template command as root without the use_sudo flag, everything works just fine. The upload_template command is not nested within a cd. Here is the offending code:

def _uwsgi_config(template, projectID):
path_to_virtualenv = '/home/%s/virtualenvs/%s' % (env.user, projectID)
path_to_project = os.path.join(path_to_virtualenv, template)

upload_template(os.path.join(env.local_template_dir, "uwsgi_config.py"),
os.path.join(path_to_project, "wsgi.py"))
sed(os.path.join(path_to_project, 'wsgi.py'), '\$\{virtualenv_path\}', path_to_virtualenv)

upload_template(os.path.join(env.local_template_dir, 'uwsgi_vassal.ini'),
os.path.join('/', 'etc', 'uwsgi', 'vassals', projectID + '.ini'), use_sudo=True)
sed(os.path.join('/', 'etc', 'uwsgi', 'vassals', projectID + ".ini"),
"\$\{project_path\}", path_to_project, use_sudo=True)
sed(os.path.join('/', 'etc', 'uwsgi', 'vassals', projectID + ".ini"),
"\$\{socket\}", projectID, use_sudo=True)
The first upload_template runs just fine, it's the second that uses the use_sudo flag that causes the problem