title: How to achieve sudo su - root and run all command in ansible
body: <p>We are not able to switch the ansible playbook connection to root id. eg. &quot;sudo su -&quot; and then execute the privilege commands. Kindly check and advice on correct approach. It works correctly using raw module but fails in a playbook</p>
  <p>The below mention command is working fine with command prompt... How to configure the same via playbook.</p>
  <pre><code>ansible 13.127.x.x -e &quot;ansible_user=ec2-user&quot; --private-key ~/Downloads/test.pem  -m shell -a &quot;sudo su - root ; cd /data/xyz/ ; ./start-xyz.sh&quot;   -vvvv
  </code></pre>
  <p>Playbook Sample</p>
  <pre><code>  - name: Start 18 Service
      shell: sudo su - root ; cd /data/xyz/ ; ./xyz.sh
  </code></pre>