become flags are primary

with new configuration the sudo flags are always set and become cannot override,
switching to simle 'or' will result in become_flags working.

also sudo_flags are deprecated.
also changed from YAML null causing a 'None' str

fixes #30629
pull/30704/head
Brian Coca 7 years ago committed by Brian Coca
parent 0eb0d96286
commit 236d13ac3a

@ -400,7 +400,7 @@ DEFAULT_BECOME_EXE:
- {key: become_exe, section: privilege_escalation} - {key: become_exe, section: privilege_escalation}
DEFAULT_BECOME_FLAGS: DEFAULT_BECOME_FLAGS:
name: Set 'become' executable options name: Set 'become' executable options
default: ~ default: ''
description: Flags to pass to the privilege escalation executable. description: Flags to pass to the privilege escalation executable.
env: [{name: ANSIBLE_BECOME_FLAGS}] env: [{name: ANSIBLE_BECOME_FLAGS}]
ini: ini:
@ -1001,7 +1001,7 @@ DEFAULT_SU_EXE:
- {key: su_exe, section: defaults} - {key: su_exe, section: defaults}
DEFAULT_SU_FLAGS: DEFAULT_SU_FLAGS:
name: su flags name: su flags
default: ~ default: ''
deprecated: deprecated:
why: In favor of become which is a generic framework why: In favor of become which is a generic framework
version: "2.8" version: "2.8"

@ -528,19 +528,13 @@ class PlayContext(Base):
command = success_cmd command = success_cmd
# set executable to use for the privilege escalation method, with various overrides # set executable to use for the privilege escalation method, with various overrides
exe = self.become_method exe = self.become_exe or getattr(self, '%s_exe' % self.become_method, self.become_method)
for myexe in (getattr(self, '%s_exe' % self.become_method, None), self.become_exe):
if myexe:
exe = myexe
break
# set flags to use for the privilege escalation method, with various overrides # set flags to use for the privilege escalation method, with various overrides
flags = '' flags = self.become_flags or getattr(self, '%s_flags' % self.become_method, '')
for myflag in (getattr(self, '%s_flags' % self.become_method, None), self.become_flags):
if myflag is not None:
flags = myflag
break
print(exe)
print(flags)
if self.become_method == 'sudo': if self.become_method == 'sudo':
# If we have a password, we run sudo with a randomly-generated # If we have a password, we run sudo with a randomly-generated
# prompt set using -p. Otherwise we run it with default -n, which makes # prompt set using -p. Otherwise we run it with default -n, which makes

Loading…
Cancel
Save