How to customise privilege escalation using sudo

Hi,

I think I need to create my own privilege escalation module for ansible. The problem I am trying to address is that due to security concerns, the process of becoming a privileged user requires the following steps.

  1. Log into the server, with your normal account
  2. run a sudo wrapper script which requires an incident number
  3. su to the account you actually need, this may be root (if you have access) or another user account that application runs as.

Can someone tell me … can ansible be customised to do this with options, or do I need to write some Python and if so, can somebody point me in the right direction. I am new to Ansible so maybe I will find something, and can manage the Python if I need to,

BTW I cant change the above login process.

Regards,

Nigel