Add a 'machinectl shell' become_method (#39826)

* Add a 'machinectl shell' become_method

* docs: add explanations for the machinectl become_method

* docs: machinectl become_method: specify this part is specific to Linux+systemd setups
This commit is contained in:
Antoine Pietri
2018-05-25 17:52:53 +02:00
committed by Adam Miller
parent 174d7f8ea2
commit 313a46744d
4 changed files with 39 additions and 5 deletions

View File

@@ -557,6 +557,11 @@ class PlayContext(Base):
prompt = 'Enter UPM user password:'
becomecmd = '%s %s %s' % (exe, flags, shlex_quote(command))
elif self.become_method == 'machinectl':
exe = self.become_exe or 'machinectl'
becomecmd = '%s shell -q %s %s@ %s' % (exe, flags, self.become_user, command)
else:
raise AnsibleError("Privilege escalation method not found: %s" % self.become_method)