Hi.
I need to use a custom shell (/bin/bash wrapper with some additional options) when I need privilege escalation via sudo (become).
For non-root tasks (no beomce) standard sh is needed. I have hacked make_become_cmd in play_ontext.py to make it work but I would like to access a variable in there provided via cmd line arg (e.g. variable cause set via ansible-playbook --extra-vars “cause=reboot_service_after_change” ?).
I have added:
if self.become_user == ‘root’:
executable = ‘/usr/sbin/custom-root-sh’
else:
executable = ‘/usr/local/bin/custom-sh’
And changed
command = ‘%s -c %s’ % (executable, success_cmd)
to
command = ‘%s -c %s -v %s’ % (executable, success_cmd, shlex_quote('“reboot_service_after_change” '))
Instead, I want to read the example text “reboot_service_after_change” from an variable provided via command line.
How would that be possible?
thanks!
Christof