title: How can I run commands in sudo mode with ansible playbook?
body: <p>I am trying to run a "folder creation" command with my ansible playbook. (Code is below)</p>
  
  <p>The creation requires sudo login to execute.</p>
  
  <p>I run the playbook as follows:</p>
  
  <p><code>ansible-playbook myfile.yml --ask-pass</code></p>
  
  <p>This prompts for user account password of remote machine.
  The ssh connection gets established, but commands fail with permission denied since its not taking super user password. </p>
  
  <p>How can I fix my issue?</p>
  
  <pre><code> hosts: GSP
   tasks:
     - name: "make build directory"
       command: mkdir -p /home/build/
       become: true
       become_user: root
     - name: "change permissions on the directory"
       command: chmod 777 -R /home/
       become: true
       become_user: root
  </code></pre>