mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
some fixes to become/sudo
* now it uses -n to get immediate error if no password is supplied and one is needed, this should fix the issue with sudo hanging waiting for input. * made -k configurable, this can break changing become_users in play if left out, but opens up the possiblity of OTP support.
This commit is contained in:
parent
4836641683
commit
49eb95e2d1
2 changed files with 10 additions and 5 deletions
|
@ -346,9 +346,13 @@ class PlayContext(Base):
|
|||
# sudo prompt set with the -p option.
|
||||
prompt = '[sudo via ansible, key=%s] password: ' % randbits
|
||||
exe = self.become_exe or self.sudo_exe or 'sudo'
|
||||
flags = self.become_flags or self.sudo_flags or ''
|
||||
becomecmd = '%s -k && %s %s -S -p "%s" -u %s %s -c %s' % \
|
||||
(exe, exe, flags or C.DEFAULT_SUDO_FLAGS, prompt, self.become_user, executable, success_cmd)
|
||||
flags = self.become_flags or self.sudo_flags or C.DEFAULT_SUDO_FLAGS
|
||||
|
||||
# force quick error if password is required but not supplied, should prevent sudo hangs.
|
||||
if not self.become_pass:
|
||||
flags += " -n "
|
||||
|
||||
becomecmd = '%s %s -S -p "%s" -u %s %s -c %s' % (exe, flags, prompt, self.become_user, executable, success_cmd)
|
||||
|
||||
elif self.become_method == 'su':
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue