Extend executable= support in raw to include no execuable

Useful for managing not-UNIX things.
This commit is contained in:
Daniel Hokka Zakrisson 2013-01-08 17:45:37 +01:00
parent 4955587d8c
commit 1b5d039bf4
4 changed files with 25 additions and 16 deletions

View file

@ -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)