sudo and telnet

Looking to translate this to a playbook :

  1. In your SSH Client (Putty), Log into the server using your an account
  2. Become the LDAP User
    sudo -u dbuser -i (this prompts for the remote_user’s credentails
  3. run an command
    echo “logged in as dbuser”
  4. Perform an On-Line backup of the DB service

telnet localhost 4111

Welcome to the DB Console

dump db;
Starting dump

logout;

  1. cd /app/TSA/data/backups (as dbuser)

Appreciate any help and thanks in advance.